@trops/dash-core 0.1.944 → 0.1.945

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.
@@ -1211,6 +1211,11 @@ const BOTS_LIST_DASH_TEAM$1 = "bots-list-dash-team";
1211
1211
  // Tasks via MCP (bot-teams TEAM-016): a team's tasks, the Dash Lead's
1212
1212
  // routing log, which teams take tasks, and the task passphrase.
1213
1213
  const BOTS_LIST_MCP_TASKS$1 = "bots-list-mcp-tasks";
1214
+ // Jobs: each chain of work through a team lead (DASH-28, DASH-31).
1215
+ const BOTS_LIST_JOBS$1 = "bots-list-jobs";
1216
+ const BOTS_GET_JOB$1 = "bots-get-job";
1217
+ const BOTS_STOP_JOB$1 = "bots-stop-job";
1218
+ const BOTS_DELETE_JOB$1 = "bots-delete-job";
1214
1219
  const BOTS_LIST_MCP_ROUTES$1 = "bots-list-mcp-routes";
1215
1220
  const BOTS_LIST_MCP_TASK_TEAMS$1 = "bots-list-mcp-task-teams";
1216
1221
  const BOTS_SET_TAKES_MCP_TASKS$1 = "bots-set-takes-mcp-tasks";
@@ -1278,6 +1283,7 @@ const BOT_OPEN_REQUEST$2 = "bot-open-request"; // {}
1278
1283
  const BOT_PLAN_BUILD_PROGRESS$2 = "bot-plan-build-progress"; // { buildId, state }
1279
1284
  // Tasks via MCP, the routing log, the passphrase or the lock changed.
1280
1285
  const BOT_MCP_TASKS_CHANGED$2 = "bot-mcp-tasks-changed"; // {}
1286
+ const BOT_JOBS_CHANGED$2 = "bot-jobs-changed"; // { jobId, workspaceId, status }
1281
1287
 
1282
1288
  var botEvents$2 = {
1283
1289
  BOTS_LIST: BOTS_LIST$1,
@@ -1324,6 +1330,10 @@ var botEvents$2 = {
1324
1330
  BOTS_LIST_LEADS: BOTS_LIST_LEADS$1,
1325
1331
  BOTS_LIST_DASH_TEAM: BOTS_LIST_DASH_TEAM$1,
1326
1332
  BOTS_LIST_MCP_TASKS: BOTS_LIST_MCP_TASKS$1,
1333
+ BOTS_LIST_JOBS: BOTS_LIST_JOBS$1,
1334
+ BOTS_GET_JOB: BOTS_GET_JOB$1,
1335
+ BOTS_STOP_JOB: BOTS_STOP_JOB$1,
1336
+ BOTS_DELETE_JOB: BOTS_DELETE_JOB$1,
1327
1337
  BOTS_LIST_MCP_ROUTES: BOTS_LIST_MCP_ROUTES$1,
1328
1338
  BOTS_LIST_MCP_TASK_TEAMS: BOTS_LIST_MCP_TASK_TEAMS$1,
1329
1339
  BOTS_SET_TAKES_MCP_TASKS: BOTS_SET_TAKES_MCP_TASKS$1,
@@ -1370,6 +1380,7 @@ var botEvents$2 = {
1370
1380
  BOT_OPEN_REQUEST: BOT_OPEN_REQUEST$2,
1371
1381
  BOT_PLAN_BUILD_PROGRESS: BOT_PLAN_BUILD_PROGRESS$2,
1372
1382
  BOT_MCP_TASKS_CHANGED: BOT_MCP_TASKS_CHANGED$2,
1383
+ BOT_JOBS_CHANGED: BOT_JOBS_CHANGED$2,
1373
1384
  };
1374
1385
 
1375
1386
  /**
@@ -1554,7 +1565,7 @@ var secureStoreController$1 = {
1554
1565
  decryptString,
1555
1566
  };
1556
1567
 
1557
- const path$y = require$$1$1;
1568
+ const path$z = require$$1$1;
1558
1569
  const {
1559
1570
  readFileSync,
1560
1571
  writeFileSync: writeFileSync$3,
@@ -1572,7 +1583,7 @@ const {
1572
1583
  function ensureDirectoryExistence$1(filePath) {
1573
1584
  try {
1574
1585
  // isDirectory
1575
- var dirname = path$y.dirname(filePath);
1586
+ var dirname = path$z.dirname(filePath);
1576
1587
  // check if the directory exists...return true
1577
1588
  // if not, we can pass in the dirname as the filepath
1578
1589
  // and check each directory recursively.
@@ -1687,7 +1698,7 @@ function removeFilesFromDirectory(directory, excludeFiles = []) {
1687
1698
 
1688
1699
  for (const file of files) {
1689
1700
  if (!excludeFiles.includes(file)) {
1690
- unlinkSync(path$y.join(directory, file), (err) => {
1701
+ unlinkSync(path$z.join(directory, file), (err) => {
1691
1702
  if (err) throw err;
1692
1703
  });
1693
1704
  }
@@ -1713,16 +1724,16 @@ var file$1 = {
1713
1724
  */
1714
1725
 
1715
1726
  const { app: app$d } = require$$0$2;
1716
- const path$x = require$$1$1;
1727
+ const path$y = require$$1$1;
1717
1728
 
1718
1729
  const appName$3 = "Dashboard";
1719
1730
 
1720
1731
  function getAppDataDir$1(appId) {
1721
- return path$x.join(app$d.getPath("userData"), appName$3, appId);
1732
+ return path$y.join(app$d.getPath("userData"), appName$3, appId);
1722
1733
  }
1723
1734
 
1724
1735
  function getAppFilePath$7(appId, filename) {
1725
- return path$x.join(getAppDataDir$1(appId), filename);
1736
+ return path$y.join(getAppDataDir$1(appId), filename);
1726
1737
  }
1727
1738
 
1728
1739
  var appPaths = { getAppDataDir: getAppDataDir$1, getAppFilePath: getAppFilePath$7 };
@@ -1750,8 +1761,8 @@ var profileStore$5 = {exports: {}};
1750
1761
  */
1751
1762
 
1752
1763
  const { app: app$c } = require$$0$2;
1753
- const path$w = require$$1$1;
1754
- const fs$u = require$$0$3;
1764
+ const path$x = require$$1$1;
1765
+ const fs$v = require$$0$3;
1755
1766
 
1756
1767
  const appName$2 = "Dashboard";
1757
1768
  const storeFilename = "profiles.json";
@@ -1769,7 +1780,7 @@ function getStorePath(appId) {
1769
1780
  if (!appId || typeof appId !== "string") {
1770
1781
  throw new Error("profileStore: appId is required");
1771
1782
  }
1772
- return path$w.join(app$c.getPath("userData"), appName$2, appId, storeFilename);
1783
+ return path$x.join(app$c.getPath("userData"), appName$2, appId, storeFilename);
1773
1784
  }
1774
1785
 
1775
1786
  function emptyItems() {
@@ -1838,7 +1849,7 @@ function readStore(appId) {
1838
1849
  if (cache$3.has(appId)) return cache$3.get(appId);
1839
1850
  let raw = null;
1840
1851
  try {
1841
- raw = JSON.parse(fs$u.readFileSync(getStorePath(appId), "utf8"));
1852
+ raw = JSON.parse(fs$v.readFileSync(getStorePath(appId), "utf8"));
1842
1853
  } catch (e) {
1843
1854
  raw = null;
1844
1855
  }
@@ -1850,8 +1861,8 @@ function readStore(appId) {
1850
1861
  function writeStore(appId, store) {
1851
1862
  const file = getStorePath(appId);
1852
1863
  const { explicit, ...onDisk } = store;
1853
- fs$u.mkdirSync(path$w.dirname(file), { recursive: true });
1854
- fs$u.writeFileSync(file, JSON.stringify(onDisk, null, 2));
1864
+ fs$v.mkdirSync(path$x.dirname(file), { recursive: true });
1865
+ fs$v.writeFileSync(file, JSON.stringify(onDisk, null, 2));
1855
1866
  const next = { ...store, explicit: true };
1856
1867
  cache$3.set(appId, next);
1857
1868
  return next;
@@ -2483,7 +2494,7 @@ const CAUSES = new Set([
2483
2494
  const RAW_LIMIT = 4000;
2484
2495
  const SECRET_KEY = /key|token|secret|password|passwd|credential|auth|cookie/i;
2485
2496
 
2486
- const clip$5 = (s, n) => {
2497
+ const clip$6 = (s, n) => {
2487
2498
  const t = typeof s === "string" ? s : s == null ? "" : String(s);
2488
2499
  return t.length > n ? `${t.slice(0, n - 1)}…` : t;
2489
2500
  };
@@ -2494,7 +2505,7 @@ function redactArgs$1(args) {
2494
2505
  const seen = new WeakSet();
2495
2506
  const walk = (v, depth) => {
2496
2507
  if (v === null || typeof v !== "object") {
2497
- return typeof v === "string" ? clip$5(v, 200) : v;
2508
+ return typeof v === "string" ? clip$6(v, 200) : v;
2498
2509
  }
2499
2510
  if (seen.has(v) || depth > 4) return "…";
2500
2511
  seen.add(v);
@@ -2511,7 +2522,7 @@ function redactArgs$1(args) {
2511
2522
  } catch (_e) {
2512
2523
  return null;
2513
2524
  }
2514
- return clip$5(json, ARGS_LIMIT);
2525
+ return clip$6(json, ARGS_LIMIT);
2515
2526
  }
2516
2527
 
2517
2528
  /**
@@ -2557,49 +2568,49 @@ function cleanInput(input) {
2557
2568
  const asset =
2558
2569
  input.asset && typeof input.asset === "object" ? input.asset : null;
2559
2570
  if (!asset || !KINDS$3.has(asset.kind)) return null;
2560
- const title = clip$5(input.title, 200);
2571
+ const title = clip$6(input.title, 200);
2561
2572
  if (!title) return null;
2562
2573
  const a = {
2563
2574
  kind: asset.kind,
2564
- name: clip$5(asset.name || "", 120),
2565
- ...(asset.component ? { component: clip$5(asset.component, 200) } : {}),
2575
+ name: clip$6(asset.name || "", 120),
2576
+ ...(asset.component ? { component: clip$6(asset.component, 200) } : {}),
2566
2577
  ...(asset.itemId != null ? { itemId: String(asset.itemId) } : {}),
2567
2578
  ...(asset.workspaceId != null
2568
2579
  ? { workspaceId: String(asset.workspaceId) }
2569
2580
  : {}),
2570
2581
  ...(asset.dashboardName
2571
- ? { dashboardName: clip$5(asset.dashboardName, 120) }
2582
+ ? { dashboardName: clip$6(asset.dashboardName, 120) }
2572
2583
  : {}),
2573
2584
  ...(asset.botId ? { botId: String(asset.botId) } : {}),
2574
- ...(asset.provider ? { provider: clip$5(asset.provider, 120) } : {}),
2585
+ ...(asset.provider ? { provider: clip$6(asset.provider, 120) } : {}),
2575
2586
  // A widget's place, so Fix with AI and Open reach that very copy.
2576
2587
  ...(asset.id != null ? { id: String(asset.id) } : {}),
2577
2588
  ...(asset.gridItemId != null
2578
2589
  ? { gridItemId: String(asset.gridItemId) }
2579
2590
  : {}),
2580
- ...(asset.cellNumber ? { cellNumber: clip$5(asset.cellNumber, 20) } : {}),
2591
+ ...(asset.cellNumber ? { cellNumber: clip$6(asset.cellNumber, 20) } : {}),
2581
2592
  ...(asset.pageId != null ? { pageId: String(asset.pageId) } : {}),
2582
- ...(asset.scope ? { scope: clip$5(asset.scope, 20) } : {}),
2583
- ...(asset.packageId ? { packageId: clip$5(asset.packageId, 200) } : {}),
2593
+ ...(asset.scope ? { scope: clip$6(asset.scope, 20) } : {}),
2594
+ ...(asset.packageId ? { packageId: clip$6(asset.packageId, 200) } : {}),
2584
2595
  };
2585
2596
  const call =
2586
2597
  input.call && typeof input.call === "object"
2587
2598
  ? {
2588
- provider: clip$5(input.call.provider || "", 120),
2589
- tool: clip$5(input.call.tool || "", 120),
2599
+ provider: clip$6(input.call.provider || "", 120),
2600
+ tool: clip$6(input.call.tool || "", 120),
2590
2601
  args: redactArgs$1(input.call.args),
2591
2602
  // Room for a provider's JSON answer, so "Show raw" has all of it.
2592
- error: clip$5(input.call.error || "", RAW_LIMIT),
2603
+ error: clip$6(input.call.error || "", RAW_LIMIT),
2593
2604
  }
2594
2605
  : null;
2595
2606
  return {
2596
2607
  asset: a,
2597
2608
  severity: SEVERITIES.has(input.severity) ? input.severity : "problem",
2598
2609
  title,
2599
- message: clip$5(input.message || (call && call.error) || "", TEXT_LIMIT),
2610
+ message: clip$6(input.message || (call && call.error) || "", TEXT_LIMIT),
2600
2611
  call,
2601
- hint: clip$5(input.hint || "", 400),
2602
- shown: clip$5(input.shown || "", 300),
2612
+ hint: clip$6(input.hint || "", 400),
2613
+ shown: clip$6(input.shown || "", 300),
2603
2614
  // What kind of failure, said by its source — never guessed from text:
2604
2615
  // "sign-in" | "start" | "provider" | "call" | "crash" | "run" | "warning"
2605
2616
  // | "model" (its model was retired: `model` says from what, to what).
@@ -2607,13 +2618,13 @@ function cleanInput(input) {
2607
2618
  // A provider behind it (a bot warning about a server): Reconnect it.
2608
2619
  related:
2609
2620
  input.related && input.related.provider
2610
- ? { provider: clip$5(input.related.provider, 120) }
2621
+ ? { provider: clip$6(input.related.provider, 120) }
2611
2622
  : null,
2612
2623
  model:
2613
2624
  input.model && input.model.from
2614
2625
  ? {
2615
- from: clip$5(input.model.from, 120),
2616
- to: clip$5(input.model.to || "", 120),
2626
+ from: clip$6(input.model.from, 120),
2627
+ to: clip$6(input.model.to || "", 120),
2617
2628
  }
2618
2629
  : null,
2619
2630
  };
@@ -2634,7 +2645,7 @@ function errorSignature(issue) {
2634
2645
  (issue && (issue.message || (issue.call && issue.call.error))) ||
2635
2646
  (issue && issue.title) ||
2636
2647
  "";
2637
- return clip$5(
2648
+ return clip$6(
2638
2649
  String(text)
2639
2650
  .toLowerCase()
2640
2651
  .replace(/\b(?=[0-9a-f-]*\d)[0-9a-f]{8,}(?:-[0-9a-f]+)*\b/g, "#")
@@ -3395,8 +3406,8 @@ function requireSecretBox () {
3395
3406
  * start); the renderer records what only it sees (a widget that crashed).
3396
3407
  */
3397
3408
 
3398
- const fs$t = require$$0$3;
3399
- const path$v = require$$1$1;
3409
+ const fs$u = require$$0$3;
3410
+ const path$w = require$$1$1;
3400
3411
  const {
3401
3412
  createIssueStore,
3402
3413
  assetKey,
@@ -3446,7 +3457,7 @@ function readList$1(p) {
3446
3457
  unreadable = false;
3447
3458
  let text;
3448
3459
  try {
3449
- text = fs$t.readFileSync(p, "utf8");
3460
+ text = fs$u.readFileSync(p, "utf8");
3450
3461
  } catch (_e) {
3451
3462
  return []; // No file yet.
3452
3463
  }
@@ -3474,11 +3485,11 @@ function saveNow() {
3474
3485
  try {
3475
3486
  const tmp = `${file}.tmp`;
3476
3487
  const json = JSON.stringify(store$7.all());
3477
- fs$t.writeFileSync(
3488
+ fs$u.writeFileSync(
3478
3489
  tmp,
3479
3490
  JSON.stringify({ v: 2, sealed: box$1 ? box$1.seal(json) : json }),
3480
3491
  );
3481
- fs$t.renameSync(tmp, file);
3492
+ fs$u.renameSync(tmp, file);
3482
3493
  } catch (_e) {
3483
3494
  // Best effort: issues are a convenience, never a reason to fail.
3484
3495
  }
@@ -3512,7 +3523,7 @@ function ensure$1() {
3512
3523
  } catch (_e) {
3513
3524
  dir = null;
3514
3525
  }
3515
- file = dir ? path$v.join(dir, FILE$1) : null;
3526
+ file = dir ? path$w.join(dir, FILE$1) : null;
3516
3527
  store$7 = createIssueStore({
3517
3528
  initial: file ? readList$1(file) : [],
3518
3529
  onChange: scheduleSave,
@@ -3526,7 +3537,7 @@ const issueController$2 = {
3526
3537
  if (typeof deps.getWindows === "function") getWindows$1 = deps.getWindows;
3527
3538
  box$1 = deps.secretBox || box$1 || defaultBox$1();
3528
3539
  if (deps.dataDir) {
3529
- file = path$v.join(deps.dataDir, FILE$1);
3540
+ file = path$w.join(deps.dataDir, FILE$1);
3530
3541
  store$7 = createIssueStore({
3531
3542
  initial: readList$1(file),
3532
3543
  onChange: scheduleSave,
@@ -4118,8 +4129,8 @@ var migrations = {
4118
4129
  */
4119
4130
 
4120
4131
  const { app: app$b } = require$$0$2;
4121
- const path$u = require$$1$1;
4122
- const fs$s = require$$0$3;
4132
+ const path$v = require$$1$1;
4133
+ const fs$t = require$$0$3;
4123
4134
  const { getFileContents: getFileContents$7, writeToFile: writeToFile$2 } = file$1;
4124
4135
  const { migrateSettings, CURRENT_SCHEMA_VERSION: CURRENT_SCHEMA_VERSION$2 } = migrations;
4125
4136
 
@@ -4128,15 +4139,15 @@ const appName$1 = "Dashboard";
4128
4139
 
4129
4140
  // Helper function to recursively copy directory
4130
4141
  function copyDirectory(source, destination) {
4131
- if (!fs$s.existsSync(destination)) {
4132
- fs$s.mkdirSync(destination, { recursive: true });
4142
+ if (!fs$t.existsSync(destination)) {
4143
+ fs$t.mkdirSync(destination, { recursive: true });
4133
4144
  }
4134
4145
 
4135
- const files = fs$s.readdirSync(source);
4146
+ const files = fs$t.readdirSync(source);
4136
4147
  for (const file of files) {
4137
- const srcPath = path$u.join(source, file);
4138
- const destPath = path$u.join(destination, file);
4139
- const stat = fs$s.lstatSync(srcPath);
4148
+ const srcPath = path$v.join(source, file);
4149
+ const destPath = path$v.join(destination, file);
4150
+ const stat = fs$t.lstatSync(srcPath);
4140
4151
 
4141
4152
  // Skip symlinks to prevent following links to sensitive files
4142
4153
  if (stat.isSymbolicLink()) {
@@ -4147,7 +4158,7 @@ function copyDirectory(source, destination) {
4147
4158
  if (stat.isDirectory()) {
4148
4159
  copyDirectory(srcPath, destPath);
4149
4160
  } else {
4150
- fs$s.copyFileSync(srcPath, destPath);
4161
+ fs$t.copyFileSync(srcPath, destPath);
4151
4162
  }
4152
4163
  }
4153
4164
  }
@@ -4163,7 +4174,7 @@ const settingsController$4 = {
4163
4174
  try {
4164
4175
  if (data) {
4165
4176
  // <appId>/settings.json
4166
- const filename = path$u.join(
4177
+ const filename = path$v.join(
4167
4178
  app$b.getPath("userData"),
4168
4179
  appName$1,
4169
4180
  configFilename$4,
@@ -4207,7 +4218,7 @@ const settingsController$4 = {
4207
4218
  getSettingsForApplication: (win) => {
4208
4219
  try {
4209
4220
  // <appId>/settings.json
4210
- const filename = path$u.join(
4221
+ const filename = path$v.join(
4211
4222
  app$b.getPath("userData"),
4212
4223
  appName$1,
4213
4224
  configFilename$4,
@@ -4255,7 +4266,7 @@ const settingsController$4 = {
4255
4266
  */
4256
4267
  getDataDirectory: (win) => {
4257
4268
  try {
4258
- const settingsPath = path$u.join(
4269
+ const settingsPath = path$v.join(
4259
4270
  app$b.getPath("userData"),
4260
4271
  appName$1,
4261
4272
  configFilename$4,
@@ -4263,7 +4274,7 @@ const settingsController$4 = {
4263
4274
  const settings = getFileContents$7(settingsPath, {});
4264
4275
  const userDataDir =
4265
4276
  settings.userDataDirectory ||
4266
- path$u.join(app$b.getPath("userData"), appName$1);
4277
+ path$v.join(app$b.getPath("userData"), appName$1);
4267
4278
 
4268
4279
  console.log("[settingsController] Data directory retrieved successfully");
4269
4280
  // Return the data for ipcMain.handle() - modern promise-based approach
@@ -4290,17 +4301,17 @@ const settingsController$4 = {
4290
4301
  setDataDirectory: (win, newPath) => {
4291
4302
  try {
4292
4303
  // Validate the path exists and is a directory
4293
- if (!fs$s.existsSync(newPath)) {
4294
- fs$s.mkdirSync(newPath, { recursive: true });
4304
+ if (!fs$t.existsSync(newPath)) {
4305
+ fs$t.mkdirSync(newPath, { recursive: true });
4295
4306
  }
4296
4307
 
4297
- const stats = fs$s.statSync(newPath);
4308
+ const stats = fs$t.statSync(newPath);
4298
4309
  if (!stats.isDirectory()) {
4299
4310
  throw new Error("Path is not a directory");
4300
4311
  }
4301
4312
 
4302
4313
  // Update settings
4303
- const settingsPath = path$u.join(
4314
+ const settingsPath = path$v.join(
4304
4315
  app$b.getPath("userData"),
4305
4316
  appName$1,
4306
4317
  configFilename$4,
@@ -4334,11 +4345,11 @@ const settingsController$4 = {
4334
4345
  migrateDataDirectory: (win, oldPath, newPath) => {
4335
4346
  try {
4336
4347
  // Resolve paths to prevent traversal
4337
- const resolvedOldPath = path$u.resolve(oldPath);
4338
- const resolvedNewPath = path$u.resolve(newPath);
4348
+ const resolvedOldPath = path$v.resolve(oldPath);
4349
+ const resolvedNewPath = path$v.resolve(newPath);
4339
4350
 
4340
4351
  // Validate oldPath is the current configured data directory
4341
- const settingsCheckPath = path$u.join(
4352
+ const settingsCheckPath = path$v.join(
4342
4353
  app$b.getPath("userData"),
4343
4354
  appName$1,
4344
4355
  configFilename$4,
@@ -4346,8 +4357,8 @@ const settingsController$4 = {
4346
4357
  const currentSettings = getFileContents$7(settingsCheckPath, {});
4347
4358
  const currentDataDir =
4348
4359
  currentSettings.userDataDirectory ||
4349
- path$u.join(app$b.getPath("userData"), appName$1);
4350
- if (resolvedOldPath !== path$u.resolve(currentDataDir)) {
4360
+ path$v.join(app$b.getPath("userData"), appName$1);
4361
+ if (resolvedOldPath !== path$v.resolve(currentDataDir)) {
4351
4362
  throw new Error("Source path must be the current data directory");
4352
4363
  }
4353
4364
 
@@ -4371,19 +4382,19 @@ const settingsController$4 = {
4371
4382
  }
4372
4383
 
4373
4384
  // Validate paths
4374
- if (!fs$s.existsSync(resolvedOldPath)) {
4385
+ if (!fs$t.existsSync(resolvedOldPath)) {
4375
4386
  throw new Error("Source directory does not exist");
4376
4387
  }
4377
4388
 
4378
- if (!fs$s.existsSync(resolvedNewPath)) {
4379
- fs$s.mkdirSync(resolvedNewPath, { recursive: true });
4389
+ if (!fs$t.existsSync(resolvedNewPath)) {
4390
+ fs$t.mkdirSync(resolvedNewPath, { recursive: true });
4380
4391
  }
4381
4392
 
4382
4393
  // Copy files
4383
4394
  copyDirectory(resolvedOldPath, resolvedNewPath);
4384
4395
 
4385
4396
  // Update settings to use new path
4386
- const settingsPath = path$u.join(
4397
+ const settingsPath = path$v.join(
4387
4398
  app$b.getPath("userData"),
4388
4399
  appName$1,
4389
4400
  configFilename$4,
@@ -4609,8 +4620,8 @@ var themeController_1 = themeController$5;
4609
4620
  * `/data/`.
4610
4621
  */
4611
4622
 
4612
- const path$t = require$$1$1;
4613
- const fs$r = require$$0$3;
4623
+ const path$u = require$$1$1;
4624
+ const fs$s = require$$0$3;
4614
4625
  const { app: app$a } = require$$0$2;
4615
4626
 
4616
4627
  const APP_NAME = "Dashboard";
@@ -4623,7 +4634,7 @@ function getAllowedRoots$2(category) {
4623
4634
  const userData = app$a.getPath("userData");
4624
4635
  switch (category) {
4625
4636
  case "data": {
4626
- const def = path$t.join(userData, APP_NAME, "data");
4637
+ const def = path$u.join(userData, APP_NAME, "data");
4627
4638
  // The user can configure a custom data directory in
4628
4639
  // Settings → General → Data Directory. If set, that
4629
4640
  // location is ALSO an allowed root. We don't replace the
@@ -4633,11 +4644,11 @@ function getAllowedRoots$2(category) {
4633
4644
  return override ? [def, override] : [def];
4634
4645
  }
4635
4646
  case "themes":
4636
- return [path$t.join(userData, APP_NAME, "themes")];
4647
+ return [path$u.join(userData, APP_NAME, "themes")];
4637
4648
  case "widgets":
4638
- return [path$t.join(userData, "widgets")];
4649
+ return [path$u.join(userData, "widgets")];
4639
4650
  case "plugins":
4640
- return [path$t.join(userData, "plugins")];
4651
+ return [path$u.join(userData, "plugins")];
4641
4652
  case "downloads":
4642
4653
  return [app$a.getPath("downloads")];
4643
4654
  default:
@@ -4654,13 +4665,13 @@ function getAllowedRoots$2(category) {
4654
4665
  */
4655
4666
  function readDataDirectoryFromSettings() {
4656
4667
  try {
4657
- const settingsPath = path$t.join(
4668
+ const settingsPath = path$u.join(
4658
4669
  app$a.getPath("userData"),
4659
4670
  APP_NAME,
4660
4671
  "settings.json",
4661
4672
  );
4662
- if (!fs$r.existsSync(settingsPath)) return undefined;
4663
- const raw = fs$r.readFileSync(settingsPath, "utf8");
4673
+ if (!fs$s.existsSync(settingsPath)) return undefined;
4674
+ const raw = fs$s.readFileSync(settingsPath, "utf8");
4664
4675
  const settings = JSON.parse(raw);
4665
4676
  const dir = settings && settings.dataDirectory;
4666
4677
  if (typeof dir === "string" && dir) return dir;
@@ -4686,18 +4697,18 @@ function safePath$3(requested, allowedRoots) {
4686
4697
  throw new Error("safePath: allowedRoots must be a non-empty array");
4687
4698
  }
4688
4699
 
4689
- const resolved = path$t.resolve(requested);
4700
+ const resolved = path$u.resolve(requested);
4690
4701
 
4691
4702
  // Real-path through symlinks. If the file doesn't exist yet (a
4692
4703
  // create-new operation), real-path the parent so a symlink in the
4693
4704
  // parent chain can't trick us.
4694
4705
  let real = resolved;
4695
4706
  try {
4696
- real = fs$r.realpathSync(resolved);
4707
+ real = fs$s.realpathSync(resolved);
4697
4708
  } catch (_e) {
4698
4709
  try {
4699
- const parent = fs$r.realpathSync(path$t.dirname(resolved));
4700
- real = path$t.join(parent, path$t.basename(resolved));
4710
+ const parent = fs$s.realpathSync(path$u.dirname(resolved));
4711
+ real = path$u.join(parent, path$u.basename(resolved));
4701
4712
  } catch (_e2) {
4702
4713
  // Parent doesn't exist either. Use the resolved-but-not-
4703
4714
  // real path; the caller's mkdirSync will happen inside the
@@ -4709,14 +4720,14 @@ function safePath$3(requested, allowedRoots) {
4709
4720
  for (const root of allowedRoots) {
4710
4721
  let realRoot = root;
4711
4722
  try {
4712
- if (fs$r.existsSync(root)) realRoot = fs$r.realpathSync(root);
4723
+ if (fs$s.existsSync(root)) realRoot = fs$s.realpathSync(root);
4713
4724
  } catch (_e) {
4714
4725
  // root doesn't exist or isn't reachable — keep as-is for
4715
4726
  // the comparison below
4716
4727
  }
4717
4728
  // Exact match OR strictly-inside (with separator to prevent
4718
4729
  // /data-evil/ matching /data/).
4719
- if (real === realRoot || real.startsWith(realRoot + path$t.sep)) {
4730
+ if (real === realRoot || real.startsWith(realRoot + path$u.sep)) {
4720
4731
  return real;
4721
4732
  }
4722
4733
  }
@@ -4738,7 +4749,7 @@ function safePath$3(requested, allowedRoots) {
4738
4749
  * against this machine's disk.
4739
4750
  */
4740
4751
  function serverPathOf(p) {
4741
- return path$t.posix
4752
+ return path$u.posix
4742
4753
  .normalize(String(p).replace(/\\/g, "/"))
4743
4754
  .replace(/^\/+/, "")
4744
4755
  .replace(/\/+$/, "")
@@ -4763,9 +4774,9 @@ function withinServerRoots(requested, roots) {
4763
4774
 
4764
4775
  /** A root that names a real folder or file on this computer. */
4765
4776
  function isLocalRoot(root) {
4766
- if (typeof root !== "string" || !path$t.isAbsolute(root)) return false;
4777
+ if (typeof root !== "string" || !path$u.isAbsolute(root)) return false;
4767
4778
  try {
4768
- return fs$r.existsSync(root);
4779
+ return fs$s.existsSync(root);
4769
4780
  } catch (_e) {
4770
4781
  return false;
4771
4782
  }
@@ -4916,8 +4927,8 @@ var fsGrantAttribution = { dataFileOwner, dropMisattributedFsPaths: dropMisattri
4916
4927
  * clearCache() → void // test-only
4917
4928
  */
4918
4929
 
4919
- const fs$q = require$$0$3;
4920
- const path$s = require$$1$1;
4930
+ const fs$r = require$$0$3;
4931
+ const path$t = require$$1$1;
4921
4932
  const { app: app$9 } = require$$0$2;
4922
4933
  const { dropMisattributedFsPaths } = fsGrantAttribution;
4923
4934
 
@@ -4930,14 +4941,14 @@ const FS_CLEANUP_MARK = "widgetMcpGrants.fs-attribution-cleaned";
4930
4941
  let _cache$1 = null;
4931
4942
 
4932
4943
  function grantsFilePath() {
4933
- return path$s.join(app$9.getPath("userData"), FILE_NAME);
4944
+ return path$t.join(app$9.getPath("userData"), FILE_NAME);
4934
4945
  }
4935
4946
 
4936
4947
  function loadFromDisk() {
4937
4948
  const p = grantsFilePath();
4938
- if (!fs$q.existsSync(p)) return {};
4949
+ if (!fs$r.existsSync(p)) return {};
4939
4950
  try {
4940
- const raw = fs$q.readFileSync(p, "utf8");
4951
+ const raw = fs$r.readFileSync(p, "utf8");
4941
4952
  const parsed = JSON.parse(raw);
4942
4953
  if (!parsed || typeof parsed !== "object") return {};
4943
4954
  return cleanMisattributedOnce(parsed);
@@ -4953,12 +4964,12 @@ function loadFromDisk() {
4953
4964
  * failed save leaves the mark unwritten, so the next load tries again.
4954
4965
  */
4955
4966
  function cleanMisattributedOnce(parsed) {
4956
- const mark = path$s.join(path$s.dirname(grantsFilePath()), FS_CLEANUP_MARK);
4957
- if (fs$q.existsSync(mark)) return parsed;
4967
+ const mark = path$t.join(path$t.dirname(grantsFilePath()), FS_CLEANUP_MARK);
4968
+ if (fs$r.existsSync(mark)) return parsed;
4958
4969
  const { grants, removed } = dropMisattributedFsPaths(parsed);
4959
4970
  try {
4960
4971
  if (removed > 0) writeToDisk(grants);
4961
- fs$q.writeFileSync(mark, new Date().toISOString(), "utf8");
4972
+ fs$r.writeFileSync(mark, new Date().toISOString(), "utf8");
4962
4973
  } catch (e) {
4963
4974
  console.warn(
4964
4975
  "[grantedPermissions] failed to save cleaned grants: " + e.message,
@@ -4977,9 +4988,9 @@ function writeToDisk(data) {
4977
4988
  const tmp = p + ".tmp";
4978
4989
  // Ensure parent dir exists (userData should already, but be defensive
4979
4990
  // for first-launch / freshly-cleared profile cases).
4980
- fs$q.mkdirSync(path$s.dirname(p), { recursive: true });
4981
- fs$q.writeFileSync(tmp, JSON.stringify(data, null, 2), "utf8");
4982
- fs$q.renameSync(tmp, p);
4991
+ fs$r.mkdirSync(path$t.dirname(p), { recursive: true });
4992
+ fs$r.writeFileSync(tmp, JSON.stringify(data, null, 2), "utf8");
4993
+ fs$r.renameSync(tmp, p);
4983
4994
  }
4984
4995
 
4985
4996
  // Recognized origins for a persisted grant.
@@ -5773,8 +5784,8 @@ function commonjsRequire(path) {
5773
5784
  * packaging script runs in plain Node, without dash-core's electron bundle).
5774
5785
  */
5775
5786
 
5776
- const fs$p = require$$0$3;
5777
- const path$r = require$$1$1;
5787
+ const fs$q = require$$0$3;
5788
+ const path$s = require$$1$1;
5778
5789
  const { builtinModules } = require$$2;
5779
5790
 
5780
5791
  // Provided by the host app via MODULE_MAP in widgetBundleLoader.js — never
@@ -5810,7 +5821,7 @@ const CODE = /\.(?:js|jsx|ts|tsx|mjs|cjs)$/;
5810
5821
  function sourceFiles(dir, rel = "") {
5811
5822
  let entries;
5812
5823
  try {
5813
- entries = fs$p.readdirSync(path$r.join(dir, rel), { withFileTypes: true });
5824
+ entries = fs$q.readdirSync(path$s.join(dir, rel), { withFileTypes: true });
5814
5825
  } catch (_e) {
5815
5826
  return [];
5816
5827
  }
@@ -5882,7 +5893,7 @@ const VALID_NAME = /^(?:@[a-z0-9~-][a-z0-9._~-]*\/)?[a-z0-9~-][a-z0-9._~-]*$/i;
5882
5893
  function findLibraryImports(dir) {
5883
5894
  const found = new Set();
5884
5895
  for (const rel of sourceFiles(dir)) {
5885
- const source = fs$p.readFileSync(path$r.join(dir, rel), "utf8");
5896
+ const source = fs$q.readFileSync(path$s.join(dir, rel), "utf8");
5886
5897
  const code = codeMask(source);
5887
5898
  for (const re of IMPORTS) {
5888
5899
  re.lastIndex = 0;
@@ -5905,9 +5916,9 @@ function findLibraryImports(dir) {
5905
5916
  /** The version of a library installed in one of `paths` (node_modules). */
5906
5917
  function installedVersion(name, paths) {
5907
5918
  for (const p of paths || []) {
5908
- const file = path$r.join(p, ...name.split("/"), "package.json");
5919
+ const file = path$s.join(p, ...name.split("/"), "package.json");
5909
5920
  try {
5910
- const v = JSON.parse(fs$p.readFileSync(file, "utf8")).version;
5921
+ const v = JSON.parse(fs$q.readFileSync(file, "utf8")).version;
5911
5922
  if (typeof v === "string" && v) return v;
5912
5923
  } catch (_e) {
5913
5924
  // not here
@@ -5925,7 +5936,7 @@ function libraryDependencies(dir, paths) {
5925
5936
  let listed = {};
5926
5937
  try {
5927
5938
  const pkg = JSON.parse(
5928
- fs$p.readFileSync(path$r.join(dir, "package.json"), "utf8"),
5939
+ fs$q.readFileSync(path$s.join(dir, "package.json"), "utf8"),
5929
5940
  );
5930
5941
  if (pkg && pkg.dependencies && typeof pkg.dependencies === "object") {
5931
5942
  listed = pkg.dependencies;
@@ -6461,8 +6472,8 @@ function requireWidgetLibraries () {
6461
6472
  * Runs in the Electron main process at widget install time.
6462
6473
  */
6463
6474
 
6464
- const fs$o = require$$0$3;
6465
- const path$q = require$$1$1;
6475
+ const fs$p = require$$0$3;
6476
+ const path$r = require$$1$1;
6466
6477
 
6467
6478
  // Provided by the host app via MODULE_MAP in widgetBundleLoader.js — never
6468
6479
  // bundled (utils/libraryImports.js).
@@ -6481,13 +6492,13 @@ const {
6481
6492
  */
6482
6493
  function hostLibraryPaths(dir = __dirname) {
6483
6494
  const out = [];
6484
- let at = path$q.resolve(dir);
6495
+ let at = path$r.resolve(dir);
6485
6496
  for (;;) {
6486
- if (path$q.basename(at) !== "node_modules") {
6487
- const candidate = path$q.join(at, "node_modules");
6488
- if (fs$o.existsSync(candidate)) out.push(candidate);
6497
+ if (path$r.basename(at) !== "node_modules") {
6498
+ const candidate = path$r.join(at, "node_modules");
6499
+ if (fs$p.existsSync(candidate)) out.push(candidate);
6489
6500
  }
6490
- const up = path$q.dirname(at);
6501
+ const up = path$r.dirname(at);
6491
6502
  if (up === at) break;
6492
6503
  at = up;
6493
6504
  }
@@ -6496,12 +6507,12 @@ function hostLibraryPaths(dir = __dirname) {
6496
6507
 
6497
6508
  /** Copy a folder with plain reads and writes (works out of an asar). */
6498
6509
  function copyDir(from, to) {
6499
- fs$o.mkdirSync(to, { recursive: true });
6500
- for (const name of fs$o.readdirSync(from)) {
6501
- const src = path$q.join(from, name);
6502
- const dest = path$q.join(to, name);
6503
- if (fs$o.statSync(src).isDirectory()) copyDir(src, dest);
6504
- else fs$o.writeFileSync(dest, fs$o.readFileSync(src));
6510
+ fs$p.mkdirSync(to, { recursive: true });
6511
+ for (const name of fs$p.readdirSync(from)) {
6512
+ const src = path$r.join(from, name);
6513
+ const dest = path$r.join(to, name);
6514
+ if (fs$p.statSync(src).isDirectory()) copyDir(src, dest);
6515
+ else fs$p.writeFileSync(dest, fs$p.readFileSync(src));
6505
6516
  }
6506
6517
  }
6507
6518
 
@@ -6512,11 +6523,11 @@ function copyDir(from, to) {
6512
6523
  */
6513
6524
  function mirrorLibrary(spec, fromPaths, toDir) {
6514
6525
  const name = packageNameOf(spec);
6515
- const dest = path$q.join(toDir, ...name.split("/"));
6516
- if (fs$o.existsSync(dest)) return true;
6526
+ const dest = path$r.join(toDir, ...name.split("/"));
6527
+ if (fs$p.existsSync(dest)) return true;
6517
6528
  for (const from of fromPaths) {
6518
- const src = path$q.join(from, ...name.split("/"));
6519
- if (fs$o.existsSync(src)) {
6529
+ const src = path$r.join(from, ...name.split("/"));
6530
+ if (fs$p.existsSync(src)) {
6520
6531
  copyDir(src, dest);
6521
6532
  return true;
6522
6533
  }
@@ -6554,25 +6565,25 @@ function appFolder() {
6554
6565
  */
6555
6566
  function libraryResolution(dir = __dirname) {
6556
6567
  const paths = libraryPaths(dir);
6557
- const inAsar = paths.filter((p) => p.includes(`.asar${path$q.sep}`));
6568
+ const inAsar = paths.filter((p) => p.includes(`.asar${path$r.sep}`));
6558
6569
  if (!inAsar.length) return { nodePaths: paths, plugins: [] };
6559
6570
  let cache;
6560
6571
  try {
6561
6572
  const { app } = require("electron");
6562
- cache = path$q.join(
6573
+ cache = path$r.join(
6563
6574
  app.getPath("userData"),
6564
6575
  "widget-build-libraries",
6565
6576
  app.getVersion(),
6566
6577
  "node_modules",
6567
6578
  );
6568
6579
  } catch (_e) {
6569
- cache = path$q.join(
6580
+ cache = path$r.join(
6570
6581
  require$$1$2.tmpdir(),
6571
6582
  "dash-widget-build-libraries",
6572
6583
  "node_modules",
6573
6584
  );
6574
6585
  }
6575
- fs$o.mkdirSync(cache, { recursive: true });
6586
+ fs$p.mkdirSync(cache, { recursive: true });
6576
6587
  return {
6577
6588
  nodePaths: [cache, ...paths.filter((p) => !inAsar.includes(p))],
6578
6589
  plugins: [
@@ -6594,13 +6605,13 @@ function libraryResolution(dir = __dirname) {
6594
6605
  /** A file in esbuild's error, short: "widgets/A.js", else its name. */
6595
6606
  function shortFile(file) {
6596
6607
  const f = String(file || "")
6597
- .split(path$q.sep)
6608
+ .split(path$r.sep)
6598
6609
  .join("/");
6599
6610
  return f.includes("/widgets/")
6600
6611
  ? `widgets/${f.split("/widgets/").pop()}`
6601
6612
  : f.startsWith("widgets/")
6602
6613
  ? f
6603
- : path$q.basename(f);
6614
+ : path$r.basename(f);
6604
6615
  }
6605
6616
 
6606
6617
  /**
@@ -6614,7 +6625,7 @@ function friendlyCompileError(error) {
6614
6625
  const loc = e.location || {};
6615
6626
  const missing = /^Could not resolve "(.+)"/.exec(e.text || "");
6616
6627
  if (missing && /^[./]/.test(missing[1])) {
6617
- return `${path$q.basename(String(loc.file || "a file"))} imports "${missing[1]}", which isn't in the package.`;
6628
+ return `${path$r.basename(String(loc.file || "a file"))} imports "${missing[1]}", which isn't in the package.`;
6618
6629
  }
6619
6630
  if (missing) {
6620
6631
  return `This widget needs the library "${packageNameOf(missing[1])}", which this app doesn't include.`;
@@ -6661,7 +6672,7 @@ function getEsbuildDiagnostics() {
6661
6672
 
6662
6673
  try {
6663
6674
  const pkgJsonPath = require.resolve("esbuild/package.json");
6664
- diagnostics.esbuildPackageDir = path$q.dirname(pkgJsonPath);
6675
+ diagnostics.esbuildPackageDir = path$r.dirname(pkgJsonPath);
6665
6676
  diagnostics.esbuildVersion = commonjsRequire(pkgJsonPath).version;
6666
6677
  } catch (err) {
6667
6678
  diagnostics.esbuildResolveError = err.message;
@@ -6671,15 +6682,15 @@ function getEsbuildDiagnostics() {
6671
6682
  const archPkgJson = require.resolve(
6672
6683
  `${diagnostics.archPackage}/package.json`,
6673
6684
  );
6674
- const archDir = path$q.dirname(archPkgJson);
6685
+ const archDir = path$r.dirname(archPkgJson);
6675
6686
  // esbuild's native binary on macOS/Linux is bin/esbuild;
6676
6687
  // on Windows it's esbuild.exe at the package root.
6677
6688
  const candidate =
6678
6689
  process.platform === "win32"
6679
- ? path$q.join(archDir, "esbuild.exe")
6680
- : path$q.join(archDir, "bin", "esbuild");
6690
+ ? path$r.join(archDir, "esbuild.exe")
6691
+ : path$r.join(archDir, "bin", "esbuild");
6681
6692
  diagnostics.nativeBinaryPath = candidate;
6682
- diagnostics.nativeBinaryExists = fs$o.existsSync(candidate);
6693
+ diagnostics.nativeBinaryExists = fs$p.existsSync(candidate);
6683
6694
  } catch (err) {
6684
6695
  diagnostics.archResolveError = err.message;
6685
6696
  }
@@ -6725,26 +6736,26 @@ async function healthCheck() {
6725
6736
  * @returns {string|null} Path to the widgets/ directory, or null
6726
6737
  */
6727
6738
  function findWidgetsDir$2(widgetPath) {
6728
- const direct = path$q.join(widgetPath, "widgets");
6729
- if (fs$o.existsSync(direct)) {
6739
+ const direct = path$r.join(widgetPath, "widgets");
6740
+ if (fs$p.existsSync(direct)) {
6730
6741
  return direct;
6731
6742
  }
6732
6743
 
6733
6744
  // Check configs/widgets/ (packageZip.js nests .dash.js files here)
6734
- const configsWidgets = path$q.join(widgetPath, "configs", "widgets");
6735
- if (fs$o.existsSync(configsWidgets)) {
6745
+ const configsWidgets = path$r.join(widgetPath, "configs", "widgets");
6746
+ if (fs$p.existsSync(configsWidgets)) {
6736
6747
  return configsWidgets;
6737
6748
  }
6738
6749
 
6739
6750
  // Check configs/ directory (used by packageZip.js for distributed widgets)
6740
- const configs = path$q.join(widgetPath, "configs");
6741
- if (fs$o.existsSync(configs)) {
6751
+ const configs = path$r.join(widgetPath, "configs");
6752
+ if (fs$p.existsSync(configs)) {
6742
6753
  return configs;
6743
6754
  }
6744
6755
 
6745
6756
  // Check one level deeper for nested ZIP extraction
6746
6757
  try {
6747
- const entries = fs$o.readdirSync(widgetPath, { withFileTypes: true });
6758
+ const entries = fs$p.readdirSync(widgetPath, { withFileTypes: true });
6748
6759
  const subdirs = entries.filter(
6749
6760
  (e) =>
6750
6761
  e.isDirectory() &&
@@ -6754,8 +6765,8 @@ function findWidgetsDir$2(widgetPath) {
6754
6765
  );
6755
6766
 
6756
6767
  for (const subdir of subdirs) {
6757
- const nested = path$q.join(widgetPath, subdir.name, "widgets");
6758
- if (fs$o.existsSync(nested)) {
6768
+ const nested = path$r.join(widgetPath, subdir.name, "widgets");
6769
+ if (fs$p.existsSync(nested)) {
6759
6770
  console.log(`[WidgetCompiler] Found nested widgets/ at ${nested}`);
6760
6771
  return nested;
6761
6772
  }
@@ -6799,7 +6810,7 @@ async function compileWidget$1(
6799
6810
  }
6800
6811
 
6801
6812
  // Discover .dash.js config files
6802
- const files = fs$o.readdirSync(widgetsDir);
6813
+ const files = fs$p.readdirSync(widgetsDir);
6803
6814
  const dashFiles = files.filter((f) => f.endsWith(".dash.js"));
6804
6815
 
6805
6816
  if (dashFiles.length === 0) {
@@ -6814,16 +6825,16 @@ async function compileWidget$1(
6814
6825
  // since widgetsDir may be nested (e.g., ./weather-widget/widgets/).
6815
6826
  // Built elsewhere (outDir), the entry imports the sources by full path.
6816
6827
  const relWidgetsDir = outDir
6817
- ? path$q.resolve(widgetsDir).split(path$q.sep).join("/")
6818
- : "./" + path$q.relative(widgetPath, widgetsDir).split(path$q.sep).join("/");
6828
+ ? path$r.resolve(widgetsDir).split(path$r.sep).join("/")
6829
+ : "./" + path$r.relative(widgetPath, widgetsDir).split(path$r.sep).join("/");
6819
6830
  const imports = [];
6820
6831
  const exportParts = [];
6821
6832
 
6822
6833
  for (const dashFile of dashFiles) {
6823
6834
  const componentName = dashFile.replace(".dash.js", "");
6824
6835
  const componentFile = `${componentName}.js`;
6825
- const componentFilePath = path$q.join(widgetsDir, componentFile);
6826
- const hasComponent = fs$o.existsSync(componentFilePath);
6836
+ const componentFilePath = path$r.join(widgetsDir, componentFile);
6837
+ const hasComponent = fs$p.existsSync(componentFilePath);
6827
6838
 
6828
6839
  // Import the config (always)
6829
6840
  imports.push(
@@ -6855,20 +6866,20 @@ async function compileWidget$1(
6855
6866
  const entryContent = [...imports, "", ...exportParts, ""].join("\n");
6856
6867
 
6857
6868
  // Write temporary entry file in the widget root (or beside the build)
6858
- const distDir = outDir || path$q.join(widgetPath, "dist");
6859
- const entryPath = path$q.join(outDir || widgetPath, "__compile_entry.js");
6860
- const outPath = path$q.join(distDir, "index.cjs.js");
6869
+ const distDir = outDir || path$r.join(widgetPath, "dist");
6870
+ const entryPath = path$r.join(outDir || widgetPath, "__compile_entry.js");
6871
+ const outPath = path$r.join(distDir, "index.cjs.js");
6861
6872
  // The package's own libraries (package.json dependencies), downloaded
6862
6873
  // into a temp folder for this build (consolidation Phase 1a-3).
6863
6874
  let own = null;
6864
6875
 
6865
6876
  try {
6866
6877
  // Ensure dist/ directory exists
6867
- if (!fs$o.existsSync(distDir)) {
6868
- fs$o.mkdirSync(distDir, { recursive: true });
6878
+ if (!fs$p.existsSync(distDir)) {
6879
+ fs$p.mkdirSync(distDir, { recursive: true });
6869
6880
  }
6870
6881
 
6871
- fs$o.writeFileSync(entryPath, entryContent, "utf8");
6882
+ fs$p.writeFileSync(entryPath, entryContent, "utf8");
6872
6883
 
6873
6884
  console.log(
6874
6885
  `[WidgetCompiler] Compiling ${dashFiles.length} component(s) from ${widgetPath}`,
@@ -6938,8 +6949,8 @@ async function compileWidget$1(
6938
6949
  if (own) own.cleanup();
6939
6950
  // Clean up temporary entry file
6940
6951
  try {
6941
- if (fs$o.existsSync(entryPath)) {
6942
- fs$o.unlinkSync(entryPath);
6952
+ if (fs$p.existsSync(entryPath)) {
6953
+ fs$p.unlinkSync(entryPath);
6943
6954
  }
6944
6955
  } catch (cleanupError) {
6945
6956
  // Non-fatal
@@ -13496,8 +13507,8 @@ var dashConfigParser = { parseDashConfig: parseDashConfig$4, DashConfigParseErro
13496
13507
  * Integrates with ComponentManager for automatic registration
13497
13508
  */
13498
13509
 
13499
- const fs$n = require$$0$3;
13500
- const path$p = require$$1$1;
13510
+ const fs$o = require$$0$3;
13511
+ const path$q = require$$1$1;
13501
13512
  const { findWidgetsDir: findWidgetsDir$1 } = widgetCompiler$1;
13502
13513
  const { parseDashConfig: parseDashConfig$3 } = dashConfigParser;
13503
13514
 
@@ -13538,14 +13549,14 @@ class DynamicWidgetLoader {
13538
13549
  );
13539
13550
 
13540
13551
  const widgetsDir =
13541
- findWidgetsDir$1(widgetPath) || path$p.join(widgetPath, "widgets");
13542
- const componentPath = path$p.join(widgetsDir, `${componentName}.js`);
13543
- const configPath = path$p.join(widgetsDir, `${componentName}.dash.js`);
13552
+ findWidgetsDir$1(widgetPath) || path$q.join(widgetPath, "widgets");
13553
+ const componentPath = path$q.join(widgetsDir, `${componentName}.js`);
13554
+ const configPath = path$q.join(widgetsDir, `${componentName}.dash.js`);
13544
13555
 
13545
- if (!fs$n.existsSync(componentPath)) {
13556
+ if (!fs$o.existsSync(componentPath)) {
13546
13557
  throw new Error(`Component file not found: ${componentPath}`);
13547
13558
  }
13548
- if (!fs$n.existsSync(configPath)) {
13559
+ if (!fs$o.existsSync(configPath)) {
13549
13560
  throw new Error(`Config file not found: ${configPath}`);
13550
13561
  }
13551
13562
 
@@ -13596,7 +13607,7 @@ class DynamicWidgetLoader {
13596
13607
  */
13597
13608
  async loadConfigFile(configPath) {
13598
13609
  try {
13599
- const source = fs$n.readFileSync(configPath, "utf8");
13610
+ const source = fs$o.readFileSync(configPath, "utf8");
13600
13611
 
13601
13612
  // Phase 5B (P1 #10): AST-allowlist parse. Rejects any node type
13602
13613
  // that could execute (CallExpression, MemberExpression,
@@ -13627,7 +13638,7 @@ class DynamicWidgetLoader {
13627
13638
  return [];
13628
13639
  }
13629
13640
 
13630
- const files = fs$n.readdirSync(widgetsDir);
13641
+ const files = fs$o.readdirSync(widgetsDir);
13631
13642
  const widgets = new Set();
13632
13643
 
13633
13644
  files.forEach((file) => {
@@ -14378,8 +14389,8 @@ var registryDownload = {
14378
14389
  * Test-only. Drops the in-process cache so tests can re-read.
14379
14390
  */
14380
14391
 
14381
- const fs$m = require$$0$3;
14382
- const path$o = require$$1$1;
14392
+ const fs$n = require$$0$3;
14393
+ const path$p = require$$1$1;
14383
14394
  const os$8 = require$$1$2;
14384
14395
  const { app: app$8 } = require$$0$2;
14385
14396
 
@@ -14396,7 +14407,7 @@ function expandHome(p) {
14396
14407
  if (typeof p !== "string" || !p) return p;
14397
14408
  if (p === "~") return os$8.homedir();
14398
14409
  if (p.startsWith("~/") || p.startsWith("~\\")) {
14399
- return path$o.join(os$8.homedir(), p.slice(2));
14410
+ return path$p.join(os$8.homedir(), p.slice(2));
14400
14411
  }
14401
14412
  return p;
14402
14413
  }
@@ -14506,10 +14517,10 @@ function dottedComponentIdToPackageId(widgetId) {
14506
14517
  function resolveWidgetPackagePath(widgetId) {
14507
14518
  const packageId = dottedComponentIdToPackageId(widgetId);
14508
14519
  if (typeof packageId !== "string" || !packageId) return null;
14509
- const widgetsRoot = path$o.join(app$8.getPath("userData"), "widgets");
14520
+ const widgetsRoot = path$p.join(app$8.getPath("userData"), "widgets");
14510
14521
  // Split scope from name for "@scope/name" form.
14511
14522
  const parts = packageId.startsWith("@") ? packageId.split("/") : [packageId];
14512
- return path$o.join(widgetsRoot, ...parts, "package.json");
14523
+ return path$p.join(widgetsRoot, ...parts, "package.json");
14513
14524
  }
14514
14525
 
14515
14526
  /**
@@ -14544,12 +14555,12 @@ function _componentNameFromWidgetId(widgetId) {
14544
14555
  function getWidgetMcpPermissions$2(widgetId) {
14545
14556
  if (_cache.has(widgetId)) return _cache.get(widgetId);
14546
14557
  const pkgPath = resolveWidgetPackagePath(widgetId);
14547
- if (!pkgPath || !fs$m.existsSync(pkgPath)) {
14558
+ if (!pkgPath || !fs$n.existsSync(pkgPath)) {
14548
14559
  _cache.set(widgetId, null);
14549
14560
  return null;
14550
14561
  }
14551
14562
  try {
14552
- const raw = fs$m.readFileSync(pkgPath, "utf8");
14563
+ const raw = fs$n.readFileSync(pkgPath, "utf8");
14553
14564
  const pkg = JSON.parse(raw);
14554
14565
  const componentName = _componentNameFromWidgetId(widgetId);
14555
14566
  const perms = parseManifestPermissions(pkg, componentName);
@@ -14600,8 +14611,8 @@ var widgetPermissions = {
14600
14611
  * (Slices 1-3) is the actual boundary.
14601
14612
  */
14602
14613
 
14603
- const fs$l = require$$0$3;
14604
- const path$n = require$$1$1;
14614
+ const fs$m = require$$0$3;
14615
+ const path$o = require$$1$1;
14605
14616
 
14606
14617
  const SOURCE_EXTENSIONS = new Set([
14607
14618
  ".js",
@@ -14654,24 +14665,24 @@ function readSourceFiles(dir) {
14654
14665
  function walk(current, relBase) {
14655
14666
  let entries;
14656
14667
  try {
14657
- entries = fs$l.readdirSync(current, { withFileTypes: true });
14668
+ entries = fs$m.readdirSync(current, { withFileTypes: true });
14658
14669
  } catch {
14659
14670
  return;
14660
14671
  }
14661
14672
  for (const entry of entries) {
14662
- const abs = path$n.join(current, entry.name);
14663
- const rel = relBase ? path$n.join(relBase, entry.name) : entry.name;
14673
+ const abs = path$o.join(current, entry.name);
14674
+ const rel = relBase ? path$o.join(relBase, entry.name) : entry.name;
14664
14675
  if (entry.isDirectory()) {
14665
14676
  if (skipDirs.has(entry.name)) continue;
14666
14677
  walk(abs, rel);
14667
14678
  } else if (entry.isFile()) {
14668
- const ext = path$n.extname(entry.name).toLowerCase();
14679
+ const ext = path$o.extname(entry.name).toLowerCase();
14669
14680
  if (!SOURCE_EXTENSIONS.has(ext)) continue;
14670
14681
  if (result.length >= SCAN_FILE_LIMIT) return;
14671
14682
  try {
14672
14683
  result.push({
14673
14684
  relPath: rel,
14674
- source: fs$l.readFileSync(abs, "utf8"),
14685
+ source: fs$m.readFileSync(abs, "utf8"),
14675
14686
  });
14676
14687
  } catch {
14677
14688
  // unreadable — skip
@@ -14691,7 +14702,7 @@ function scanForMcpUsage(input) {
14691
14702
  let fileList = [];
14692
14703
  if (input.files && typeof input.files === "object") {
14693
14704
  for (const [relPath, source] of Object.entries(input.files)) {
14694
- const ext = path$n.extname(relPath).toLowerCase();
14705
+ const ext = path$o.extname(relPath).toLowerCase();
14695
14706
  if (!SOURCE_EXTENSIONS.has(ext)) continue;
14696
14707
  if (typeof source !== "string") continue;
14697
14708
  fileList.push({ relPath, source });
@@ -14803,8 +14814,8 @@ var manifestScanner = {
14803
14814
  * containment.
14804
14815
  */
14805
14816
 
14806
- const fs$k = require$$0$3;
14807
- const path$m = require$$1$1;
14817
+ const fs$l = require$$0$3;
14818
+ const path$n = require$$1$1;
14808
14819
  const { safePath: safePath$2 } = safePath_1;
14809
14820
 
14810
14821
  const NAME_RE = /^@?[a-z0-9][a-z0-9.-]*(\/[a-z0-9][a-z0-9.-]*)?$/i;
@@ -14821,19 +14832,19 @@ function loadWidgetManifest(folderPath) {
14821
14832
  if (typeof folderPath !== "string" || !folderPath) {
14822
14833
  return { ok: false, error: "folderPath must be a non-empty string" };
14823
14834
  }
14824
- if (!fs$k.existsSync(folderPath)) {
14835
+ if (!fs$l.existsSync(folderPath)) {
14825
14836
  return { ok: false, error: `folder does not exist: ${folderPath}` };
14826
14837
  }
14827
14838
 
14828
- const dashJsonPath = path$m.join(folderPath, "dash.json");
14829
- const packageJsonPath = path$m.join(folderPath, "package.json");
14839
+ const dashJsonPath = path$n.join(folderPath, "dash.json");
14840
+ const packageJsonPath = path$n.join(folderPath, "package.json");
14830
14841
 
14831
14842
  let raw;
14832
14843
  let source;
14833
14844
 
14834
- if (fs$k.existsSync(dashJsonPath)) {
14845
+ if (fs$l.existsSync(dashJsonPath)) {
14835
14846
  try {
14836
- raw = JSON.parse(fs$k.readFileSync(dashJsonPath, "utf8"));
14847
+ raw = JSON.parse(fs$l.readFileSync(dashJsonPath, "utf8"));
14837
14848
  source = "dash.json";
14838
14849
  } catch (err) {
14839
14850
  return {
@@ -14841,12 +14852,12 @@ function loadWidgetManifest(folderPath) {
14841
14852
  error: `dash.json present but unreadable: ${err.message}`,
14842
14853
  };
14843
14854
  }
14844
- } else if (fs$k.existsSync(packageJsonPath)) {
14855
+ } else if (fs$l.existsSync(packageJsonPath)) {
14845
14856
  // Fall back to package.json — accept either a top-level shape
14846
14857
  // OR a nested `dash` block. Top-level wins for `name`/`version`
14847
14858
  // since that's where npm puts them.
14848
14859
  try {
14849
- const pkg = JSON.parse(fs$k.readFileSync(packageJsonPath, "utf8"));
14860
+ const pkg = JSON.parse(fs$l.readFileSync(packageJsonPath, "utf8"));
14850
14861
  const dashBlock = pkg.dash || {};
14851
14862
  raw = {
14852
14863
  name: pkg.name || dashBlock.name,
@@ -14897,7 +14908,7 @@ function loadWidgetManifest(folderPath) {
14897
14908
 
14898
14909
  // entry: optional with sensible default. Validate when present.
14899
14910
  let entry = typeof raw.entry === "string" ? raw.entry : "widgets";
14900
- if (path$m.isAbsolute(entry) || entry.split(/[/\\]/).includes("..")) {
14911
+ if (path$n.isAbsolute(entry) || entry.split(/[/\\]/).includes("..")) {
14901
14912
  return {
14902
14913
  ok: false,
14903
14914
  error: "manifest.entry must be relative and must not contain `..`",
@@ -14908,15 +14919,15 @@ function loadWidgetManifest(folderPath) {
14908
14919
  // folder root after realpath. If the entry doesn't yet exist on
14909
14920
  // disk (common during validate-only flows), fall back to a plain
14910
14921
  // resolve-and-prefix check.
14911
- const candidate = path$m.join(folderPath, entry);
14912
- if (fs$k.existsSync(candidate)) {
14922
+ const candidate = path$n.join(folderPath, entry);
14923
+ if (fs$l.existsSync(candidate)) {
14913
14924
  safePath$2(candidate, [folderPath]);
14914
14925
  } else {
14915
- const resolved = path$m.resolve(candidate);
14916
- const rootResolved = path$m.resolve(folderPath);
14926
+ const resolved = path$n.resolve(candidate);
14927
+ const rootResolved = path$n.resolve(folderPath);
14917
14928
  if (
14918
14929
  resolved !== rootResolved &&
14919
- !resolved.startsWith(rootResolved + path$m.sep)
14930
+ !resolved.startsWith(rootResolved + path$n.sep)
14920
14931
  ) {
14921
14932
  return {
14922
14933
  ok: false,
@@ -14983,7 +14994,7 @@ function walkSourceContainment(rootPath) {
14983
14994
  if (typeof rootPath !== "string" || !rootPath) {
14984
14995
  throw new Error("walkSourceContainment: rootPath required");
14985
14996
  }
14986
- if (!fs$k.existsSync(rootPath)) {
14997
+ if (!fs$l.existsSync(rootPath)) {
14987
14998
  throw new Error(`walkSourceContainment: rootPath missing: ${rootPath}`);
14988
14999
  }
14989
15000
 
@@ -14992,10 +15003,10 @@ function walkSourceContainment(rootPath) {
14992
15003
  const current = stack.pop();
14993
15004
  safePath$2(current, [rootPath]);
14994
15005
 
14995
- const stat = fs$k.lstatSync(current);
15006
+ const stat = fs$l.lstatSync(current);
14996
15007
  if (stat.isDirectory()) {
14997
- for (const entry of fs$k.readdirSync(current)) {
14998
- stack.push(path$m.join(current, entry));
15008
+ for (const entry of fs$l.readdirSync(current)) {
15009
+ stack.push(path$n.join(current, entry));
14999
15010
  }
15000
15011
  }
15001
15012
  // Symlinks: lstat gives us the symlink-itself; safePath above
@@ -22906,8 +22917,8 @@ function requireTransform () {
22906
22917
  }
22907
22918
 
22908
22919
  const { app: app$7 } = require$$0$2;
22909
- var fs$j = require$$0$3;
22910
- const path$l = require$$1$1;
22920
+ var fs$k = require$$0$3;
22921
+ const path$m = require$$1$1;
22911
22922
  const events$5 = events$8;
22912
22923
  const { getFileContents: getFileContents$5, writeToFile: writeToFile$1 } = file$1;
22913
22924
  const { safePath: safePath$1, getAllowedRoots: getAllowedRoots$1 } = safePath_1;
@@ -22924,13 +22935,13 @@ const { readEnforceFlag: readEnforceFlag$2, readJitFlag: readJitFlag$2 } = secur
22924
22935
  // domain-neutral name is a separate slice).
22925
22936
  function _loadFlags$1() {
22926
22937
  try {
22927
- const settingsPath = path$l.join(
22938
+ const settingsPath = path$m.join(
22928
22939
  app$7.getPath("userData"),
22929
22940
  appName,
22930
22941
  "settings.json",
22931
22942
  );
22932
- if (!fs$j.existsSync(settingsPath)) return null;
22933
- return JSON.parse(fs$j.readFileSync(settingsPath, "utf8"));
22943
+ if (!fs$k.existsSync(settingsPath)) return null;
22944
+ return JSON.parse(fs$k.readFileSync(settingsPath, "utf8"));
22934
22945
  } catch (_e) {
22935
22946
  return null;
22936
22947
  }
@@ -23011,7 +23022,7 @@ const dataController$1 = {
23011
23022
  // Validate the renderer-supplied filename is contained within
23012
23023
  // the data directory. path.join doesn't reject `..` segments;
23013
23024
  // safePath does.
23014
- const candidate = path$l.join(
23025
+ const candidate = path$m.join(
23015
23026
  app$7.getPath("userData"),
23016
23027
  appName,
23017
23028
  appId,
@@ -23188,7 +23199,7 @@ const dataController$1 = {
23188
23199
  // intent, plus realpath/symlink protection.
23189
23200
  const resolvedFilepath = safePath$1(toFilepath, getAllowedRoots$1("data"));
23190
23201
 
23191
- const writeStream = fs$j.createWriteStream(resolvedFilepath);
23202
+ const writeStream = fs$k.createWriteStream(resolvedFilepath);
23192
23203
 
23193
23204
  https$5
23194
23205
  .get(url, (resp) => {
@@ -23372,7 +23383,7 @@ const dataController$1 = {
23372
23383
  if (data) {
23373
23384
  // Validate filename is contained within the data directory.
23374
23385
  // path.join doesn't reject `..` segments; safePath does.
23375
- const candidate = path$l.join(
23386
+ const candidate = path$m.join(
23376
23387
  app$7.getPath("userData"),
23377
23388
  appName,
23378
23389
  "data",
@@ -23481,7 +23492,7 @@ const dataController$1 = {
23481
23492
  try {
23482
23493
  if (filename) {
23483
23494
  // filename to the pages file (live pages)
23484
- const fromFilename = path$l.join(
23495
+ const fromFilename = path$m.join(
23485
23496
  app$7.getPath("userData"),
23486
23497
  appName,
23487
23498
  "data",
@@ -61964,8 +61975,8 @@ const {
61964
61975
  const {
61965
61976
  StreamableHTTPClientTransport,
61966
61977
  } = streamableHttp$1;
61967
- const path$k = require$$1$1;
61968
- const fs$i = require$$0$3;
61978
+ const path$l = require$$1$1;
61979
+ const fs$j = require$$0$3;
61969
61980
  const os$7 = require$$1$2;
61970
61981
  const responseCache$2 = responseCache_1;
61971
61982
  const { gateToolCall, gateToolCallWithJit } = permissionGate;
@@ -62020,13 +62031,13 @@ function isSavedProvider(win, appId, name) {
62020
62031
  */
62021
62032
  function loadSettingsForFlags() {
62022
62033
  try {
62023
- const settingsPath = path$k.join(
62034
+ const settingsPath = path$l.join(
62024
62035
  app$6.getPath("userData"),
62025
62036
  "Dashboard",
62026
62037
  "settings.json",
62027
62038
  );
62028
- if (!fs$i.existsSync(settingsPath)) return null;
62029
- const raw = fs$i.readFileSync(settingsPath, "utf8");
62039
+ if (!fs$j.existsSync(settingsPath)) return null;
62040
+ const raw = fs$j.readFileSync(settingsPath, "utf8");
62030
62041
  return JSON.parse(raw);
62031
62042
  } catch (_e) {
62032
62043
  return null;
@@ -62193,7 +62204,7 @@ function getShellPath$1() {
62193
62204
  fallbackDirs.push(`${home}/.nodenv/shims`);
62194
62205
  try {
62195
62206
  const nvmDir = `${home}/.nvm/versions/node`;
62196
- const versions = fs$i.readdirSync(nvmDir).sort();
62207
+ const versions = fs$j.readdirSync(nvmDir).sort();
62197
62208
  if (versions.length > 0) {
62198
62209
  // Find the highest compatible version (v18/v20/v22)
62199
62210
  for (let i = versions.length - 1; i >= 0; i--) {
@@ -62336,15 +62347,15 @@ async function refreshGoogleOAuthToken(tokenRefresh) {
62336
62347
  const credPath = tokenRefresh.credentialsPath.replace(/^~/, home);
62337
62348
  const keysPath = tokenRefresh.oauthKeysPath.replace(/^~/, home);
62338
62349
 
62339
- if (!fs$i.existsSync(credPath) || !fs$i.existsSync(keysPath)) {
62350
+ if (!fs$j.existsSync(credPath) || !fs$j.existsSync(keysPath)) {
62340
62351
  console.log(
62341
62352
  "[mcpController] Token refresh skipped: credential files not found",
62342
62353
  );
62343
62354
  return;
62344
62355
  }
62345
62356
 
62346
- const credentials = JSON.parse(fs$i.readFileSync(credPath, "utf8"));
62347
- const keysFile = JSON.parse(fs$i.readFileSync(keysPath, "utf8"));
62357
+ const credentials = JSON.parse(fs$j.readFileSync(credPath, "utf8"));
62358
+ const keysFile = JSON.parse(fs$j.readFileSync(keysPath, "utf8"));
62348
62359
  const keyData = keysFile.installed || keysFile.web;
62349
62360
 
62350
62361
  if (
@@ -62413,7 +62424,7 @@ async function refreshGoogleOAuthToken(tokenRefresh) {
62413
62424
  credentials.refresh_token = body.refresh_token;
62414
62425
  }
62415
62426
 
62416
- fs$i.writeFileSync(credPath, JSON.stringify(credentials, null, 2));
62427
+ fs$j.writeFileSync(credPath, JSON.stringify(credentials, null, 2));
62417
62428
  console.log("[mcpController] Google OAuth token refreshed successfully");
62418
62429
  }
62419
62430
 
@@ -62800,7 +62811,7 @@ const mcpController$3 = {
62800
62811
  }
62801
62812
 
62802
62813
  // Interpolate {{MCP_DIR}} in args to resolve local MCP server scripts
62803
- const mcpDir = path$k.join(__dirname, "..", "mcp");
62814
+ const mcpDir = path$l.join(__dirname, "..", "mcp");
62804
62815
  for (let i = 0; i < args.length; i++) {
62805
62816
  if (
62806
62817
  typeof args[i] === "string" &&
@@ -63491,20 +63502,20 @@ const mcpController$3 = {
63491
63502
  */
63492
63503
  getCatalog: (win) => {
63493
63504
  try {
63494
- const catalogPath = path$k.join(
63505
+ const catalogPath = path$l.join(
63495
63506
  __dirname,
63496
63507
  "..",
63497
63508
  "mcp",
63498
63509
  "mcpServerCatalog.json",
63499
63510
  );
63500
63511
 
63501
- if (!fs$i.existsSync(catalogPath)) {
63512
+ if (!fs$j.existsSync(catalogPath)) {
63502
63513
  return {
63503
63514
  catalog: [],
63504
63515
  };
63505
63516
  }
63506
63517
 
63507
- const catalogData = fs$i.readFileSync(catalogPath, "utf8");
63518
+ const catalogData = fs$j.readFileSync(catalogPath, "utf8");
63508
63519
  const catalog = JSON.parse(catalogData);
63509
63520
 
63510
63521
  return {
@@ -63532,18 +63543,18 @@ const mcpController$3 = {
63532
63543
  */
63533
63544
  getKnownExternalCatalog: () => {
63534
63545
  try {
63535
- const catalogPath = path$k.join(
63546
+ const catalogPath = path$l.join(
63536
63547
  __dirname,
63537
63548
  "..",
63538
63549
  "mcp",
63539
63550
  "knownExternalMcpServers.json",
63540
63551
  );
63541
63552
 
63542
- if (!fs$i.existsSync(catalogPath)) {
63553
+ if (!fs$j.existsSync(catalogPath)) {
63543
63554
  return { success: true, servers: [] };
63544
63555
  }
63545
63556
 
63546
- const catalogData = fs$i.readFileSync(catalogPath, "utf8");
63557
+ const catalogData = fs$j.readFileSync(catalogPath, "utf8");
63547
63558
  const catalog = JSON.parse(catalogData);
63548
63559
 
63549
63560
  return {
@@ -63600,8 +63611,8 @@ const mcpController$3 = {
63600
63611
  const destPath = to.replace(/^~/, os$7.homedir());
63601
63612
  const destDir = require$$1$1.dirname(destPath);
63602
63613
  try {
63603
- fs$i.mkdirSync(destDir, { recursive: true });
63604
- fs$i.copyFileSync(sourcePath, destPath);
63614
+ fs$j.mkdirSync(destDir, { recursive: true });
63615
+ fs$j.copyFileSync(sourcePath, destPath);
63605
63616
  } catch (err) {
63606
63617
  return {
63607
63618
  error: true,
@@ -63637,7 +63648,7 @@ const mcpController$3 = {
63637
63648
  }
63638
63649
 
63639
63650
  // Interpolate {{MCP_DIR}} in authCommand args (same as startServer)
63640
- const mcpDir = path$k.join(__dirname, "..", "mcp");
63651
+ const mcpDir = path$l.join(__dirname, "..", "mcp");
63641
63652
  const resolvedArgs = (authCommand.args || []).map((arg) =>
63642
63653
  typeof arg === "string" && arg.includes("{{MCP_DIR}}")
63643
63654
  ? arg.replace(/\{\{MCP_DIR\}\}/g, mcpDir)
@@ -63810,8 +63821,8 @@ var isNewerVersion_1 = { isNewerVersion: isNewerVersion$2 };
63810
63821
  * - Support two-level browsing: packages (bundles) and widgets within packages
63811
63822
  */
63812
63823
 
63813
- const path$j = require$$1$1;
63814
- const fs$h = require$$0$3;
63824
+ const path$k = require$$1$1;
63825
+ const fs$i = require$$0$3;
63815
63826
  const os$6 = require$$1$2;
63816
63827
  const { toPackageId } = packageId;
63817
63828
  const { isNewerVersion: isNewerVersion$1 } = isNewerVersion_1;
@@ -63841,7 +63852,7 @@ function getCacheKey() {
63841
63852
  * Get the local test registry path for dev mode
63842
63853
  */
63843
63854
  function getTestRegistryPath() {
63844
- return path$j.join(__dirname, "..", "registry", "test-registry-index.json");
63855
+ return path$k.join(__dirname, "..", "registry", "test-registry-index.json");
63845
63856
  }
63846
63857
 
63847
63858
  /**
@@ -63881,12 +63892,12 @@ async function fetchRegistryIndex(forceRefresh = false) {
63881
63892
  if (isDev()) {
63882
63893
  // In dev mode, try local test file first
63883
63894
  const testPath = getTestRegistryPath();
63884
- if (fs$h.existsSync(testPath)) {
63895
+ if (fs$i.existsSync(testPath)) {
63885
63896
  console.log(
63886
63897
  "[RegistryController] Loading test registry from:",
63887
63898
  testPath,
63888
63899
  );
63889
- const raw = fs$h.readFileSync(testPath, "utf8");
63900
+ const raw = fs$i.readFileSync(testPath, "utf8");
63890
63901
  indexData = JSON.parse(raw);
63891
63902
  } else {
63892
63903
  // Fall back to API (supports DASH_REGISTRY_URL as full-URL override)
@@ -64465,7 +64476,7 @@ async function fetchPackageSource(packageName, componentName = null) {
64465
64476
 
64466
64477
  const zip = new AdmZip(buffer);
64467
64478
  const safeName = (pkg.name || "pkg").replace(/[^a-zA-Z0-9-_]/g, "_");
64468
- const tempDir = path$j.join(
64479
+ const tempDir = path$k.join(
64469
64480
  os$6.tmpdir(),
64470
64481
  `dash-registry-preview-${safeName}-${Date.now()}`,
64471
64482
  );
@@ -64474,13 +64485,13 @@ async function fetchPackageSource(packageName, componentName = null) {
64474
64485
  validateZipEntries(zip, tempDir);
64475
64486
  zip.extractAllTo(tempDir, true);
64476
64487
 
64477
- const widgetsDir = path$j.join(tempDir, "widgets");
64488
+ const widgetsDir = path$k.join(tempDir, "widgets");
64478
64489
  let componentCode = "";
64479
64490
  let configCode = "";
64480
64491
  let widgetName = null;
64481
64492
 
64482
- if (fs$h.existsSync(widgetsDir)) {
64483
- const files = fs$h.readdirSync(widgetsDir);
64493
+ if (fs$i.existsSync(widgetsDir)) {
64494
+ const files = fs$i.readdirSync(widgetsDir);
64484
64495
  const dashFiles = files.filter((f) => f.endsWith(".dash.js"));
64485
64496
  const componentFiles = files.filter(
64486
64497
  (f) => f.endsWith(".js") && !f.endsWith(".dash.js") && f !== "index.js",
@@ -64502,7 +64513,7 @@ async function fetchPackageSource(packageName, componentName = null) {
64502
64513
  if (!configFile) configFile = dashFiles[0];
64503
64514
 
64504
64515
  if (configFile) {
64505
- configCode = fs$h.readFileSync(path$j.join(widgetsDir, configFile), "utf8");
64516
+ configCode = fs$i.readFileSync(path$k.join(widgetsDir, configFile), "utf8");
64506
64517
  widgetName = configFile.replace(/\.dash\.js$/, "");
64507
64518
  }
64508
64519
 
@@ -64516,8 +64527,8 @@ async function fetchPackageSource(packageName, componentName = null) {
64516
64527
  if (!componentFile) componentFile = componentFiles[0];
64517
64528
 
64518
64529
  if (componentFile) {
64519
- componentCode = fs$h.readFileSync(
64520
- path$j.join(widgetsDir, componentFile),
64530
+ componentCode = fs$i.readFileSync(
64531
+ path$k.join(widgetsDir, componentFile),
64521
64532
  "utf8",
64522
64533
  );
64523
64534
  if (!widgetName) widgetName = componentFile.replace(/\.js$/, "");
@@ -64525,16 +64536,16 @@ async function fetchPackageSource(packageName, componentName = null) {
64525
64536
  }
64526
64537
 
64527
64538
  let bundleSource = null;
64528
- const bundlePath = path$j.join(tempDir, "dist", "index.cjs.js");
64529
- if (fs$h.existsSync(bundlePath)) {
64530
- bundleSource = fs$h.readFileSync(bundlePath, "utf8");
64539
+ const bundlePath = path$k.join(tempDir, "dist", "index.cjs.js");
64540
+ if (fs$i.existsSync(bundlePath)) {
64541
+ bundleSource = fs$i.readFileSync(bundlePath, "utf8");
64531
64542
  }
64532
64543
 
64533
64544
  let dashMeta = {};
64534
- const dashPath = path$j.join(tempDir, "dash.json");
64535
- if (fs$h.existsSync(dashPath)) {
64545
+ const dashPath = path$k.join(tempDir, "dash.json");
64546
+ if (fs$i.existsSync(dashPath)) {
64536
64547
  try {
64537
- dashMeta = JSON.parse(fs$h.readFileSync(dashPath, "utf8"));
64548
+ dashMeta = JSON.parse(fs$i.readFileSync(dashPath, "utf8"));
64538
64549
  } catch {
64539
64550
  // Ignore — metadata is optional for preview
64540
64551
  }
@@ -64553,7 +64564,7 @@ async function fetchPackageSource(packageName, componentName = null) {
64553
64564
  };
64554
64565
  } finally {
64555
64566
  try {
64556
- fs$h.rmSync(tempDir, { recursive: true, force: true });
64567
+ fs$i.rmSync(tempDir, { recursive: true, force: true });
64557
64568
  } catch (err) {
64558
64569
  console.warn(
64559
64570
  `[RegistryController] Failed to clean up preview temp dir ${tempDir}:`,
@@ -64653,7 +64664,7 @@ async function fetchPackageManifest(packageName) {
64653
64664
 
64654
64665
  const zip = new AdmZip(buffer);
64655
64666
  const safeName = (pkg.name || "pkg").replace(/[^a-zA-Z0-9-_]/g, "_");
64656
- const tempDir = path$j.join(
64667
+ const tempDir = path$k.join(
64657
64668
  os$6.tmpdir(),
64658
64669
  `dash-registry-manifest-${safeName}-${Date.now()}`,
64659
64670
  );
@@ -64699,8 +64710,8 @@ async function fetchPackageManifest(packageName) {
64699
64710
  // it. Keep the symmetric cleanup defensively in case future
64700
64711
  // edits switch back to extractAllTo.
64701
64712
  try {
64702
- if (fs$h.existsSync(tempDir)) {
64703
- fs$h.rmSync(tempDir, { recursive: true, force: true });
64713
+ if (fs$i.existsSync(tempDir)) {
64714
+ fs$i.rmSync(tempDir, { recursive: true, force: true });
64704
64715
  }
64705
64716
  } catch (_) {
64706
64717
  // non-fatal
@@ -64719,10 +64730,10 @@ var registryController$3 = {
64719
64730
  fetchPackageManifest,
64720
64731
  };
64721
64732
 
64722
- var fs$g = require$$0$3;
64733
+ var fs$h = require$$0$3;
64723
64734
  var JSONStream = require$$4$1;
64724
64735
  const algoliasearch$1 = require$$2$4;
64725
- const path$i = require$$3$3;
64736
+ const path$j = require$$3$3;
64726
64737
  const { ensureDirectoryExistence, checkDirectory } = file$1;
64727
64738
 
64728
64739
  let AlgoliaIndex$1 = class AlgoliaIndex {
@@ -64760,7 +64771,7 @@ let AlgoliaIndex$1 = class AlgoliaIndex {
64760
64771
  var batchNumber = 1;
64761
64772
 
64762
64773
  // create the readStream to parse the large file (json)
64763
- var readStream = fs$g.createReadStream(filepath).pipe(parser);
64774
+ var readStream = fs$h.createReadStream(filepath).pipe(parser);
64764
64775
 
64765
64776
  var batch = [];
64766
64777
 
@@ -64774,7 +64785,7 @@ let AlgoliaIndex$1 = class AlgoliaIndex {
64774
64785
  // lets write to the batch file
64775
64786
  if (countForBatch === batchSize) {
64776
64787
  // write to the batch file
64777
- var writeStream = fs$g.createWriteStream(
64788
+ var writeStream = fs$h.createWriteStream(
64778
64789
  batchFilepath + "/batch_" + batchNumber + ".json",
64779
64790
  );
64780
64791
  writeStream.write(JSON.stringify(batch));
@@ -64825,11 +64836,11 @@ let AlgoliaIndex$1 = class AlgoliaIndex {
64825
64836
  return new Promise((resolve, reject) => {
64826
64837
  try {
64827
64838
  checkDirectory(directoryPath);
64828
- fs$g.readdir(directoryPath, (err, files) => {
64839
+ fs$h.readdir(directoryPath, (err, files) => {
64829
64840
  if (err) reject(err);
64830
64841
  if (files) {
64831
64842
  files.forEach((file) => {
64832
- fs$g.unlinkSync(path$i.join(directoryPath, file));
64843
+ fs$h.unlinkSync(path$j.join(directoryPath, file));
64833
64844
  });
64834
64845
  resolve();
64835
64846
  }
@@ -64848,11 +64859,11 @@ let AlgoliaIndex$1 = class AlgoliaIndex {
64848
64859
  ) {
64849
64860
  try {
64850
64861
  // read the directory...
64851
- const files = await fs$g.readdirSync(batchFilepath);
64862
+ const files = await fs$h.readdirSync(batchFilepath);
64852
64863
  let results = [];
64853
64864
  for (const fileIndex in files) {
64854
64865
  // for each file lets read the file and then push to algolia
64855
- const pathToBatch = path$i.join(batchFilepath, files[fileIndex]);
64866
+ const pathToBatch = path$j.join(batchFilepath, files[fileIndex]);
64856
64867
  const fileContents = await this.readFile(pathToBatch);
64857
64868
  if (fileContents) {
64858
64869
  if ("data" in fileContents && "filepath" in fileContents) {
@@ -64877,7 +64888,7 @@ let AlgoliaIndex$1 = class AlgoliaIndex {
64877
64888
 
64878
64889
  async readFile(filepath) {
64879
64890
  return await new Promise((resolve, reject) => {
64880
- fs$g.readFile(filepath, "utf8", (err, data) => {
64891
+ fs$h.readFile(filepath, "utf8", (err, data) => {
64881
64892
  if (err) {
64882
64893
  reject(err);
64883
64894
  }
@@ -65027,7 +65038,7 @@ var algolia = AlgoliaIndex$1;
65027
65038
  const algoliasearch = require$$2$4;
65028
65039
  const events$3 = events$8;
65029
65040
  const AlgoliaIndex = algolia;
65030
- var fs$f = require$$0$3;
65041
+ var fs$g = require$$0$3;
65031
65042
  const { safePath, getAllowedRoots } = safePath_1;
65032
65043
 
65033
65044
  const algoliaController$1 = {
@@ -65136,7 +65147,7 @@ const algoliaController$1 = {
65136
65147
  // init the Algolia Index helper
65137
65148
  const a = new AlgoliaIndex(appId, apiKey, indexName);
65138
65149
  // create the write stream to store the hits
65139
- const writeStream = fs$f.createWriteStream(toFilename);
65150
+ const writeStream = fs$g.createWriteStream(toFilename);
65140
65151
  writeStream.write("[");
65141
65152
 
65142
65153
  let sep = "";
@@ -65391,7 +65402,7 @@ function upsertMenuItem$1(items, menuItem) {
65391
65402
 
65392
65403
  var upsertMenuItem_1 = { upsertMenuItem: upsertMenuItem$1 };
65393
65404
 
65394
- const path$h = require$$1$1;
65405
+ const path$i = require$$1$1;
65395
65406
  const { writeFileSync } = require$$0$3;
65396
65407
  const { getFileContents: getFileContents$3 } = file$1;
65397
65408
  const { getAppFilePath: getAppFilePath$3, getAppDataDir } = appPaths;
@@ -65456,8 +65467,8 @@ const menuItemsController$1 = {
65456
65467
  try {
65457
65468
  const dir = getAppDataDir(appId);
65458
65469
  const result = deleteMenuItemFromFiles(
65459
- path$h.join(dir, configFilename$1),
65460
- path$h.join(dir, "workspaces.json"),
65470
+ path$i.join(dir, configFilename$1),
65471
+ path$i.join(dir, "workspaces.json"),
65461
65472
  menuItemId,
65462
65473
  );
65463
65474
  removeEverywhere(appId, "folders", menuItemId);
@@ -67565,8 +67576,8 @@ streamableHttp.StreamableHTTPServerTransport = StreamableHTTPServerTransport$1;
67565
67576
  * https.createServer({ key, cert }, handler);
67566
67577
  */
67567
67578
 
67568
- const fs$e = require$$0$3;
67569
- const path$g = require$$1$1;
67579
+ const fs$f = require$$0$3;
67580
+ const path$h = require$$1$1;
67570
67581
  const forge = require$$2$5;
67571
67582
 
67572
67583
  /**
@@ -67575,14 +67586,14 @@ const forge = require$$2$5;
67575
67586
  * @returns {{ cert: string, key: string }} PEM-encoded certificate and private key
67576
67587
  */
67577
67588
  function getOrCreateCert$1(certsDir) {
67578
- const certPath = path$g.join(certsDir, "cert.pem");
67579
- const keyPath = path$g.join(certsDir, "key.pem");
67589
+ const certPath = path$h.join(certsDir, "cert.pem");
67590
+ const keyPath = path$h.join(certsDir, "key.pem");
67580
67591
 
67581
67592
  // Return existing cert if valid
67582
- if (fs$e.existsSync(certPath) && fs$e.existsSync(keyPath)) {
67593
+ if (fs$f.existsSync(certPath) && fs$f.existsSync(keyPath)) {
67583
67594
  try {
67584
- const cert = fs$e.readFileSync(certPath, "utf8");
67585
- const key = fs$e.readFileSync(keyPath, "utf8");
67595
+ const cert = fs$f.readFileSync(certPath, "utf8");
67596
+ const key = fs$f.readFileSync(keyPath, "utf8");
67586
67597
  // Verify cert is not expired
67587
67598
  const parsed = forge.pki.certificateFromPem(cert);
67588
67599
  if (parsed.validity.notAfter > new Date()) {
@@ -67648,9 +67659,9 @@ function getOrCreateCert$1(certsDir) {
67648
67659
  const keyPem = forge.pki.privateKeyToPem(keys.privateKey);
67649
67660
 
67650
67661
  // Write to disk
67651
- fs$e.mkdirSync(certsDir, { recursive: true });
67652
- fs$e.writeFileSync(certPath, certPem, { mode: 0o644 });
67653
- fs$e.writeFileSync(keyPath, keyPem, { mode: 0o600 });
67662
+ fs$f.mkdirSync(certsDir, { recursive: true });
67663
+ fs$f.writeFileSync(certPath, certPem, { mode: 0o644 });
67664
+ fs$f.writeFileSync(keyPath, keyPem, { mode: 0o600 });
67654
67665
 
67655
67666
  console.log(`[tlsCert] Certificate saved to ${certsDir}`);
67656
67667
 
@@ -71357,7 +71368,7 @@ var themeGenerator = /*#__PURE__*/Object.freeze({
71357
71368
  getThemePresets: getThemePresets
71358
71369
  });
71359
71370
 
71360
- var require$$48 = /*@__PURE__*/getAugmentedNamespace(themeGenerator);
71371
+ var require$$50 = /*@__PURE__*/getAugmentedNamespace(themeGenerator);
71361
71372
 
71362
71373
  /**
71363
71374
  * paletteToThemeMapper.js
@@ -71368,7 +71379,7 @@ var require$$48 = /*@__PURE__*/getAugmentedNamespace(themeGenerator);
71368
71379
  */
71369
71380
 
71370
71381
  const { TAILWIND_COLORS: TAILWIND_COLORS$1 } = require$$13;
71371
- const { generateThemeName } = require$$48;
71382
+ const { generateThemeName } = require$$50;
71372
71383
 
71373
71384
  const VALID_HEX_RE = /^#[0-9a-fA-F]{6}$/;
71374
71385
 
@@ -75993,7 +76004,7 @@ const FIELD_KINDS = [
75993
76004
  ];
75994
76005
  const FLOW_ID = /^flow_[a-z0-9]{6,40}$/;
75995
76006
  const STEP_ID = /^step_[a-z0-9]{1,40}$/;
75996
- const MAX_STEPS = 20;
76007
+ const MAX_STEPS$1 = 20;
75997
76008
  const MAX_FIELDS = 30;
75998
76009
  const DEFAULT_MAX_ROUNDS$1 = 3;
75999
76010
  const MAX_ROUNDS_CAP$1 = 10;
@@ -76126,7 +76137,7 @@ function normalizeFlow$1(input = {}) {
76126
76137
  const steps = [];
76127
76138
  const ids = new Set();
76128
76139
  const list = Array.isArray(input.steps)
76129
- ? input.steps.slice(0, MAX_STEPS)
76140
+ ? input.steps.slice(0, MAX_STEPS$1)
76130
76141
  : [];
76131
76142
  list.forEach((s, i) => {
76132
76143
  const step = cleanStep(s, i);
@@ -76412,7 +76423,7 @@ const HANDS_ON = ["answer", "summary", "files"];
76412
76423
  const STEP_KINDS = ["check", "reviewer", "you"];
76413
76424
  const MAX_CHECK_STEPS = 10;
76414
76425
  const WORK_STEP$2 = "step_work";
76415
- const MAX_TITLE$2 = 120;
76426
+ const MAX_TITLE$3 = 120;
76416
76427
 
76417
76428
  const str$2 = (v, max = 400) =>
76418
76429
  typeof v === "string" ? v.trim().slice(0, max) : "";
@@ -76614,7 +76625,7 @@ function jobTitle$1(bot, { prompt = "", trigger = "" } = {}) {
76614
76625
  ? "its scheduled run"
76615
76626
  : "its run");
76616
76627
  const title = `${(bot && bot.name) || "A bot"}: ${what}`;
76617
- return title.length > MAX_TITLE$2 ? `${title.slice(0, MAX_TITLE$2 - 1)}…` : title;
76628
+ return title.length > MAX_TITLE$3 ? `${title.slice(0, MAX_TITLE$3 - 1)}…` : title;
76618
76629
  }
76619
76630
 
76620
76631
  /** Where a job came from, for the ledger's `source`. */
@@ -77082,6 +77093,8 @@ function causeFromEvent$1(event) {
77082
77093
  if (event && event.goalId) {
77083
77094
  cause.goal = { goalId: event.goalId, taskId: event.taskId || null };
77084
77095
  }
77096
+ // The job it's part of (DASH-28): a hand-on joins it.
77097
+ if (event && event.jobId) cause.jobId = event.jobId;
77085
77098
  return cause;
77086
77099
  }
77087
77100
 
@@ -77129,6 +77142,8 @@ function buildBotEventMessage$1(bot, event, payload, cause = rootCause$3()) {
77129
77142
  msg.content.goalId = goal.goalId;
77130
77143
  msg.content.taskId = goal.taskId || null;
77131
77144
  }
77145
+ // The job the run is part of, so the bots it starts join it (DASH-28).
77146
+ if (cause.jobId) msg.jobId = cause.jobId;
77132
77147
  return msg;
77133
77148
  }
77134
77149
 
@@ -81079,8 +81094,8 @@ var publisherKeyController$1 = {
81079
81094
  * Handles publishing packages and generating registry URLs.
81080
81095
  */
81081
81096
 
81082
- const fs$d = require$$0$3;
81083
- const path$f = require$$1$1;
81097
+ const fs$e = require$$0$3;
81098
+ const path$g = require$$1$1;
81084
81099
  const { getStoredToken } = registryAuthController$1;
81085
81100
  const { signZipBuffer: signZipBuffer$1 } = publisherKeyController$1;
81086
81101
 
@@ -81111,7 +81126,7 @@ async function publishToRegistry$1(zipPath, manifest) {
81111
81126
 
81112
81127
  try {
81113
81128
  // Read the ZIP file
81114
- const zipBuffer = fs$d.readFileSync(zipPath);
81129
+ const zipBuffer = fs$e.readFileSync(zipPath);
81115
81130
 
81116
81131
  // Sign the ZIP with the local publisher key. First-call generates
81117
81132
  // the keypair locally, registers the public half with the registry,
@@ -81142,7 +81157,7 @@ async function publishToRegistry$1(zipPath, manifest) {
81142
81157
  formData.append(
81143
81158
  "file",
81144
81159
  new Blob([zipBuffer], { type: "application/zip" }),
81145
- path$f.basename(zipPath),
81160
+ path$g.basename(zipPath),
81146
81161
  );
81147
81162
  formData.append("manifest", JSON.stringify(manifest));
81148
81163
  formData.append("signature", signing.signature);
@@ -81576,7 +81591,7 @@ var themeStanding = /*#__PURE__*/Object.freeze({
81576
81591
  themePublished: themePublished$1
81577
81592
  });
81578
81593
 
81579
- var require$$49 = /*@__PURE__*/getAugmentedNamespace(themeStanding);
81594
+ var require$$51 = /*@__PURE__*/getAugmentedNamespace(themeStanding);
81580
81595
 
81581
81596
  /**
81582
81597
  * themeRegistryController.js
@@ -81586,8 +81601,8 @@ var require$$49 = /*@__PURE__*/getAugmentedNamespace(themeStanding);
81586
81601
  * and registry interaction.
81587
81602
  */
81588
81603
 
81589
- const fs$c = require$$0$3;
81590
- const path$e = require$$1$1;
81604
+ const fs$d = require$$0$3;
81605
+ const path$f = require$$1$1;
81591
81606
  const { app: app$4, dialog: dialog$2 } = require$$0$2;
81592
81607
  const AdmZip$2 = require$$3$1;
81593
81608
 
@@ -81870,11 +81885,11 @@ async function prepareThemeForPublish$1(win, appId, themeKey, options = {}) {
81870
81885
  const defaultFilename = `theme-${sanitizedName}-v${manifest.version}.zip`;
81871
81886
  let filePath;
81872
81887
  if (headlessPlan) {
81873
- const tmpDir = fs$c.mkdtempSync(
81874
- path$e.join(app$4.getPath("temp"), "dash-publish-"),
81888
+ const tmpDir = fs$d.mkdtempSync(
81889
+ path$f.join(app$4.getPath("temp"), "dash-publish-"),
81875
81890
  );
81876
81891
  headlessTmpDir = tmpDir;
81877
- filePath = path$e.join(tmpDir, defaultFilename);
81892
+ filePath = path$f.join(tmpDir, defaultFilename);
81878
81893
  } else {
81879
81894
  const saveResult = await dialog$2.showSaveDialog(win, {
81880
81895
  title: "Save Theme Package",
@@ -81979,7 +81994,7 @@ async function prepareThemeForPublish$1(win, appId, themeKey, options = {}) {
81979
81994
 
81980
81995
  if (headlessPlan) {
81981
81996
  try {
81982
- fs$c.rmSync(path$e.dirname(filePath), { recursive: true, force: true });
81997
+ fs$d.rmSync(path$f.dirname(filePath), { recursive: true, force: true });
81983
81998
  } catch (_e) {
81984
81999
  // a leftover temp file is harmless
81985
82000
  }
@@ -82011,7 +82026,7 @@ async function prepareThemeForPublish$1(win, appId, themeKey, options = {}) {
82011
82026
  // A headless publish that failed partway leaves no temp folder.
82012
82027
  if (headlessTmpDir) {
82013
82028
  try {
82014
- fs$c.rmSync(headlessTmpDir, { recursive: true, force: true });
82029
+ fs$d.rmSync(headlessTmpDir, { recursive: true, force: true });
82015
82030
  } catch (_e) {
82016
82031
  // harmless
82017
82032
  }
@@ -82277,7 +82292,7 @@ async function installThemeFromRegistry$1(win, appId, packageName, options = {})
82277
82292
  // Validate entry path (security: prevent path traversal)
82278
82293
  if (
82279
82294
  themeEntry.entryName.includes("..") ||
82280
- path$e.isAbsolute(themeEntry.entryName)
82295
+ path$f.isAbsolute(themeEntry.entryName)
82281
82296
  ) {
82282
82297
  return {
82283
82298
  success: false,
@@ -82391,7 +82406,7 @@ async function getThemePublishPreview$1(appId, themeKey) {
82391
82406
  // the registry couldn't be asked.
82392
82407
  let published = null;
82393
82408
  try {
82394
- const { themePublished } = require$$49;
82409
+ const { themePublished } = require$$51;
82395
82410
  let username = null;
82396
82411
  try {
82397
82412
  username =
@@ -82582,7 +82597,7 @@ var themeRegistryController$1 = {
82582
82597
  * the host and the store together.
82583
82598
  */
82584
82599
 
82585
- const path$d = require$$1$1;
82600
+ const path$e = require$$1$1;
82586
82601
  const { app: app$3, safeStorage } = require$$0$2;
82587
82602
  const Store$1 = require$$2$1;
82588
82603
  const { createSecretBox } = requireSecretBox();
@@ -82600,11 +82615,11 @@ function createElectronHost$1() {
82600
82615
  const budgetStore = new Store$1({ name: "dash-bot-budgets" });
82601
82616
  const memoryStore = new Store$1({ name: "dash-bot-memory" });
82602
82617
  const recentStore = new Store$1({ name: "dash-create-recent" });
82603
- const botsRoot = path$d.join(app$3.getPath("userData"), "bots");
82618
+ const botsRoot = path$e.join(app$3.getPath("userData"), "bots");
82604
82619
 
82605
82620
  return {
82606
82621
  // The saved audit log (US-003 AC5) — append-only JSON lines.
82607
- paths: { botsRoot, auditLog: path$d.join(botsRoot, "audit.log") },
82622
+ paths: { botsRoot, auditLog: path$e.join(botsRoot, "audit.log") },
82608
82623
  clock: { now: () => new Date().toISOString() },
82609
82624
  // Seals sensitive bot data at rest (run answers) with the OS keychain.
82610
82625
  // Falls back to plain text where the keychain isn't available.
@@ -82661,8 +82676,8 @@ var BotStore$2 = {exports: {}};
82661
82676
  * on create() and removed on delete().
82662
82677
  */
82663
82678
 
82664
- const fs$b = require$$0$3;
82665
- const path$c = require$$1$1;
82679
+ const fs$c = require$$0$3;
82680
+ const path$d = require$$1$1;
82666
82681
  const {
82667
82682
  newBotId,
82668
82683
  isValidBotId,
@@ -82753,7 +82768,7 @@ let BotStore$1 = class BotStore {
82753
82768
  if (!isValidBotId(id)) {
82754
82769
  throw new Error(`BotStore: invalid bot id "${id}"`);
82755
82770
  }
82756
- return path$c.join(this._botsRoot, id, "files");
82771
+ return path$d.join(this._botsRoot, id, "files");
82757
82772
  }
82758
82773
 
82759
82774
  /** @returns {object[]} all bot definitions */
@@ -82810,7 +82825,7 @@ let BotStore$1 = class BotStore {
82810
82825
  data.bots[id] = bot;
82811
82826
  this._save(data);
82812
82827
 
82813
- fs$b.mkdirSync(this.workingDir(id), { recursive: true });
82828
+ fs$c.mkdirSync(this.workingDir(id), { recursive: true });
82814
82829
  this._changed("created", id);
82815
82830
  return bot;
82816
82831
  }
@@ -82858,7 +82873,7 @@ let BotStore$1 = class BotStore {
82858
82873
  this._save(data);
82859
82874
 
82860
82875
  if (isValidBotId(id)) {
82861
- fs$b.rmSync(path$c.join(this._botsRoot, id), {
82876
+ fs$c.rmSync(path$d.join(this._botsRoot, id), {
82862
82877
  recursive: true,
82863
82878
  force: true,
82864
82879
  });
@@ -87332,7 +87347,7 @@ var PauseController_1 = PauseController$1;
87332
87347
  * Portable (NFR-006): the file path, fs and clock are injected; no Electron.
87333
87348
  */
87334
87349
 
87335
- const path$b = require$$1$1;
87350
+ const path$c = require$$1$1;
87336
87351
 
87337
87352
  const DEFAULT_MAX_BYTES = 2.5 * 1024 * 1024;
87338
87353
 
@@ -87470,7 +87485,7 @@ function createAuditLog$1({
87470
87485
  };
87471
87486
  let line = `${JSON.stringify(saved)}\n`;
87472
87487
  try {
87473
- fs.mkdirSync(path$b.dirname(file), { recursive: true });
87488
+ fs.mkdirSync(path$c.dirname(file), { recursive: true });
87474
87489
  // A torn last line (Dash quit mid-write) mustn't swallow this entry.
87475
87490
  if (!checkedEnd) {
87476
87491
  checkedEnd = true;
@@ -88717,6 +88732,574 @@ function createCheckJobs$1(deps) {
88717
88732
 
88718
88733
  var checkJobs = { createCheckJobs: createCheckJobs$1 };
88719
88734
 
88735
+ /**
88736
+ * jobStore.js — where jobs are kept (DASH-28, DASH-31): one file per job,
88737
+ *
88738
+ * <root>/<jobId>.json
88739
+ *
88740
+ * sealed at rest like goals and bot runs (secretBox; plain without a
88741
+ * keychain), written to a temp file and renamed into place. Jobs are the
88742
+ * user's history on their own computer, so nothing here deletes one by
88743
+ * itself: only deleteJob, when the user asks.
88744
+ */
88745
+
88746
+ const fs$b = require$$0$3;
88747
+ const path$b = require$$1$1;
88748
+
88749
+ const JOB_ID = /^job_[a-z0-9]+$/;
88750
+
88751
+ /**
88752
+ * @param {{ root: string, box?: { seal: Function, open: Function } }} p
88753
+ */
88754
+ function createJobStore$1({ root, box = null }) {
88755
+ const jobs = new Map();
88756
+ // Sealed by a keychain this session can't open: never shown, never
88757
+ // overwritten.
88758
+ const unreadable = new Set();
88759
+
88760
+ const fileOf = (id) => path$b.join(root, `${id}.json`);
88761
+
88762
+ function readRecord(file) {
88763
+ const raw = JSON.parse(fs$b.readFileSync(file, "utf8"));
88764
+ if (raw && typeof raw.sealed === "string") {
88765
+ const opened = box ? box.open(raw.sealed) : raw.sealed;
88766
+ if (opened == null) throw new Error("sealed by another keychain");
88767
+ return JSON.parse(opened);
88768
+ }
88769
+ return raw;
88770
+ }
88771
+
88772
+ function load() {
88773
+ jobs.clear();
88774
+ unreadable.clear();
88775
+ let names = [];
88776
+ try {
88777
+ names = fs$b.readdirSync(root);
88778
+ } catch (_e) {
88779
+ return; // No jobs yet.
88780
+ }
88781
+ for (const name of names) {
88782
+ const id = name.replace(/\.json$/, "");
88783
+ if (!name.endsWith(".json") || !JOB_ID.test(id)) continue;
88784
+ try {
88785
+ const job = readRecord(fileOf(id));
88786
+ if (job && job.id === id) jobs.set(id, job);
88787
+ } catch (_e) {
88788
+ unreadable.add(id);
88789
+ }
88790
+ }
88791
+ }
88792
+
88793
+ function save(job) {
88794
+ if (!job || !JOB_ID.test(String(job.id || ""))) return false;
88795
+ if (unreadable.has(job.id)) return false;
88796
+ fs$b.mkdirSync(root, { recursive: true });
88797
+ const file = fileOf(job.id);
88798
+ const json = JSON.stringify(job);
88799
+ const tmp = `${file}.tmp`;
88800
+ fs$b.writeFileSync(
88801
+ tmp,
88802
+ JSON.stringify({ v: 1, sealed: box ? box.seal(json) : json }),
88803
+ );
88804
+ fs$b.renameSync(tmp, file);
88805
+ jobs.set(job.id, job);
88806
+ return true;
88807
+ }
88808
+
88809
+ function remove(id) {
88810
+ if (!JOB_ID.test(String(id || ""))) return false;
88811
+ const had = jobs.delete(id) || unreadable.delete(id);
88812
+ try {
88813
+ fs$b.rmSync(fileOf(id), { force: true });
88814
+ } catch (_e) {
88815
+ // Gone already.
88816
+ }
88817
+ return had;
88818
+ }
88819
+
88820
+ load();
88821
+ return {
88822
+ JOB_ID,
88823
+ load,
88824
+ save,
88825
+ remove,
88826
+ get: (id) => jobs.get(id) || null,
88827
+ /** Every job, newest change first. */
88828
+ list: () =>
88829
+ [...jobs.values()].sort((a, b) =>
88830
+ String(b.updatedAt || "").localeCompare(String(a.updatedAt || "")),
88831
+ ),
88832
+ };
88833
+ }
88834
+
88835
+ var jobStore = { createJobStore: createJobStore$1, JOB_ID };
88836
+
88837
+ /**
88838
+ * jobTracker.js — a job is one chain of work that goes through a team lead
88839
+ * (DASH-28, DASH-31): the lead's run, the bots it asks, their checks, and
88840
+ * every hand-on they set off, until none is still going.
88841
+ *
88842
+ * job: { id, workspaceId, leadId, leadName, title, startedBy,
88843
+ * conversationId, status, steps, createdAt, updatedAt, endedAt }
88844
+ * step: { id, botId, botName, status, why, runAt, startedAt, endedAt,
88845
+ * summary, goalId, conversationId }
88846
+ *
88847
+ * Step statuses: queued (a hand-on about to start), running, checking (its
88848
+ * checks are trying the work), needs-you (waiting on the user: a paused
88849
+ * bot, checks that need a look), done, failed, stopped, skipped.
88850
+ *
88851
+ * A job is running while any step is queued, running or checking — and for
88852
+ * a moment after the last one ends, because hand-ons start a tick after the
88853
+ * bot that sets them off (botController defers bot→bot dispatch). Then it
88854
+ * is done, failed or stopped, from its steps. Needs-you wins over running,
88855
+ * so a job stuck on the user says so.
88856
+ *
88857
+ * Pure apart from the injected store, clock and timers.
88858
+ */
88859
+
88860
+ const SETTLE_MS = 2000;
88861
+ const MAX_STEPS = 100;
88862
+ const MAX_TITLE$2 = 200;
88863
+ const MAX_SUMMARY = 600;
88864
+
88865
+ const ACTIVE = new Set(["queued", "running", "checking"]);
88866
+ const WAITING = new Set(["queued", "needs-you"]);
88867
+ const FINAL = new Set(["done", "failed", "stopped"]);
88868
+
88869
+ const clip$5 = (s, n) => {
88870
+ const t = String(s == null ? "" : s)
88871
+ .replace(/\s+/g, " ")
88872
+ .trim();
88873
+ return t.length > n ? `${t.slice(0, n - 1)}…` : t;
88874
+ };
88875
+
88876
+ /** A job's status from its steps (settling: a step just ended). */
88877
+ function jobStatus(steps, settling = false) {
88878
+ const list = steps || [];
88879
+ // Just made: its lead's run is about to start.
88880
+ if (!list.length) return "running";
88881
+ if (list.some((s) => s.status === "needs-you")) return "needs-you";
88882
+ if (settling || list.some((s) => ACTIVE.has(s.status))) return "running";
88883
+ if (list.some((s) => s.status === "failed")) return "failed";
88884
+ if (list.some((s) => s.status === "stopped")) return "stopped";
88885
+ // Nothing ran at all (its lead was busy): stopped, not done.
88886
+ if (list.every((s) => s.status === "skipped")) return "stopped";
88887
+ return "done";
88888
+ }
88889
+
88890
+ /** A finished run's status, as a step's. */
88891
+ function stepStatusOf(record) {
88892
+ const s = record && record.status;
88893
+ if (s === "completed") return "done";
88894
+ if (s === "failed" || s === "error") return "failed";
88895
+ if (s === "skipped") return "skipped";
88896
+ return "stopped";
88897
+ }
88898
+
88899
+ /** What a run's record says, short. */
88900
+ function summaryOf(record) {
88901
+ if (!record) return "";
88902
+ if (record.status === "failed" || record.status === "error") {
88903
+ return clip$5(record.error || "It failed.", MAX_SUMMARY);
88904
+ }
88905
+ if (record.status === "skipped") {
88906
+ return clip$5(
88907
+ record.reason || record.skipped || "It didn't run.",
88908
+ MAX_SUMMARY,
88909
+ );
88910
+ }
88911
+ return clip$5(record.output || "", MAX_SUMMARY);
88912
+ }
88913
+
88914
+ /**
88915
+ * @param {{
88916
+ * store: ReturnType<import("./jobStore").createJobStore>,
88917
+ * now?: () => number,
88918
+ * random?: () => number,
88919
+ * onChange?: (job: object) => void,
88920
+ * setTimer?: Function, clearTimer?: Function, settleMs?: number,
88921
+ * }} deps
88922
+ */
88923
+ function createJobTracker$1({
88924
+ store,
88925
+ now = Date.now,
88926
+ random = Math.random,
88927
+ onChange = () => {},
88928
+ setTimer = setTimeout,
88929
+ clearTimer = clearTimeout,
88930
+ settleMs = SETTLE_MS,
88931
+ }) {
88932
+ const iso = () => new Date(now()).toISOString();
88933
+ const newId = (prefix) =>
88934
+ `${prefix}_${now().toString(36)}${Math.floor(random() * 36 ** 6)
88935
+ .toString(36)
88936
+ .padStart(6, "0")}`;
88937
+ const settling = new Map(); // jobId → timer
88938
+ const waiters = new Map(); // jobId → [resolve]
88939
+ // goalId → jobId: a step's checks, found without reading every job ever
88940
+ // kept (jobs are never pruned on their own).
88941
+ let byGoal = null;
88942
+ const goalIndex = () => {
88943
+ if (!byGoal) {
88944
+ byGoal = new Map();
88945
+ for (const j of store.list()) {
88946
+ for (const st of j.steps || []) {
88947
+ if (st.goalId) byGoal.set(st.goalId, j.id);
88948
+ }
88949
+ }
88950
+ }
88951
+ return byGoal;
88952
+ };
88953
+
88954
+ function commit(job) {
88955
+ job.status = jobStatus(job.steps, settling.has(job.id));
88956
+ job.updatedAt = iso();
88957
+ if (FINAL.has(job.status)) job.endedAt = job.endedAt || job.updatedAt;
88958
+ else job.endedAt = null;
88959
+ try {
88960
+ store.save(job);
88961
+ } catch (_e) {
88962
+ // Kept in memory; written on its next change.
88963
+ }
88964
+ try {
88965
+ onChange(job);
88966
+ } catch (_e) {
88967
+ // A listener never stops the job.
88968
+ }
88969
+ if (FINAL.has(job.status)) {
88970
+ const list = waiters.get(job.id) || [];
88971
+ waiters.delete(job.id);
88972
+ for (const resolve of list) resolve(job);
88973
+ }
88974
+ return job;
88975
+ }
88976
+
88977
+ function settle(job) {
88978
+ const t = settling.get(job.id);
88979
+ if (t) clearTimer(t);
88980
+ settling.set(
88981
+ job.id,
88982
+ setTimer(() => {
88983
+ settling.delete(job.id);
88984
+ const current = store.get(job.id);
88985
+ if (current) commit(current);
88986
+ }, settleMs),
88987
+ );
88988
+ }
88989
+
88990
+ function unsettle(jobId) {
88991
+ const t = settling.get(jobId);
88992
+ if (t) clearTimer(t);
88993
+ settling.delete(jobId);
88994
+ }
88995
+
88996
+ const jobOf = (jobId) => (jobId ? store.get(jobId) : null);
88997
+
88998
+ /** Start a job for a lead's run. */
88999
+ function startJob({
89000
+ workspaceId = null,
89001
+ leadId = null,
89002
+ leadName = "",
89003
+ title = "",
89004
+ startedBy = { kind: "you" },
89005
+ conversationId = null,
89006
+ } = {}) {
89007
+ const at = iso();
89008
+ const job = {
89009
+ id: newId("job"),
89010
+ workspaceId: workspaceId == null ? null : String(workspaceId),
89011
+ leadId: leadId || null,
89012
+ leadName: leadName || "",
89013
+ title: clip$5(title, MAX_TITLE$2) || "A job",
89014
+ startedBy: { kind: "you", ...startedBy },
89015
+ conversationId: conversationId || null,
89016
+ status: "running",
89017
+ steps: [],
89018
+ createdAt: at,
89019
+ updatedAt: at,
89020
+ endedAt: null,
89021
+ };
89022
+ return commit(job);
89023
+ }
89024
+
89025
+ function addStep(job, step) {
89026
+ if (job.steps.length >= MAX_STEPS) return null;
89027
+ const s = {
89028
+ id: newId("step"),
89029
+ botId: step.botId,
89030
+ botName: step.botName || step.botId,
89031
+ status: step.status,
89032
+ why: step.why || null,
89033
+ runAt: step.runAt || null,
89034
+ startedAt: step.status === "running" ? iso() : null,
89035
+ endedAt: null,
89036
+ summary: step.summary ? clip$5(step.summary, MAX_SUMMARY) : "",
89037
+ goalId: step.goalId || null,
89038
+ conversationId: step.conversationId || null,
89039
+ };
89040
+ job.steps.push(s);
89041
+ return s;
89042
+ }
89043
+
89044
+ /**
89045
+ * A bot's run in the job starts. A hand-on that was waiting for it (queued,
89046
+ * or for the user to turn the bot on) becomes this run.
89047
+ */
89048
+ function startStep(jobId, { botId, botName, runAt, why, conversationId }) {
89049
+ const job = jobOf(jobId);
89050
+ if (!job) return null;
89051
+ unsettle(job.id);
89052
+ let step = job.steps.find(
89053
+ (s) => s.botId === botId && WAITING.has(s.status),
89054
+ );
89055
+ if (step) {
89056
+ step.status = "running";
89057
+ step.runAt = runAt || null;
89058
+ step.startedAt = iso();
89059
+ step.summary = "";
89060
+ if (conversationId) step.conversationId = conversationId;
89061
+ } else {
89062
+ step = addStep(job, {
89063
+ botId,
89064
+ botName,
89065
+ status: "running",
89066
+ why,
89067
+ runAt,
89068
+ conversationId,
89069
+ });
89070
+ }
89071
+ commit(job);
89072
+ return step;
89073
+ }
89074
+
89075
+ /** A hand-on that can't start yet: waiting on the user (a paused bot). */
89076
+ function waitStep(jobId, { botId, botName, why, summary }) {
89077
+ const job = jobOf(jobId);
89078
+ if (!job) return null;
89079
+ unsettle(job.id);
89080
+ const step =
89081
+ job.steps.find((s) => s.botId === botId && WAITING.has(s.status)) ||
89082
+ addStep(job, { botId, botName, status: "needs-you", why });
89083
+ if (!step) return null;
89084
+ step.status = "needs-you";
89085
+ step.summary = clip$5(summary || "", MAX_SUMMARY);
89086
+ commit(job);
89087
+ return step;
89088
+ }
89089
+
89090
+ /** A hand-on that won't run (its bot drops events while paused). */
89091
+ function skipStep(jobId, { botId, botName, why, summary }) {
89092
+ const job = jobOf(jobId);
89093
+ if (!job) return null;
89094
+ const step = addStep(job, {
89095
+ botId,
89096
+ botName,
89097
+ status: "skipped",
89098
+ why,
89099
+ summary,
89100
+ });
89101
+ if (step) step.endedAt = iso();
89102
+ settle(job);
89103
+ commit(job);
89104
+ return step;
89105
+ }
89106
+
89107
+ const stepOfRun = (job, botId, runAt) =>
89108
+ job.steps.find((s) => s.botId === botId && s.runAt && s.runAt === runAt) ||
89109
+ // The run's start time is only known once it has begun; the newest
89110
+ // running step of that bot is this run.
89111
+ [...job.steps]
89112
+ .reverse()
89113
+ .find((s) => s.botId === botId && s.status === "running");
89114
+
89115
+ /**
89116
+ * A bot's run in the job ended. `checking` + goalId: its checks are trying
89117
+ * the work (bot-checks), so the step goes on until they pass.
89118
+ */
89119
+ function endStep(jobId, { botId, runAt, record, checking = null }) {
89120
+ const job = jobOf(jobId);
89121
+ if (!job) return null;
89122
+ const step = stepOfRun(job, botId, runAt);
89123
+ if (!step) return null;
89124
+ if (record && record.startedAt) step.runAt = record.startedAt;
89125
+ if (checking && checking.goalId) {
89126
+ step.status = "checking";
89127
+ step.goalId = checking.goalId;
89128
+ goalIndex().set(checking.goalId, job.id);
89129
+ step.summary = summaryOf(record);
89130
+ } else {
89131
+ step.status = stepStatusOf(record);
89132
+ step.summary = summaryOf(record);
89133
+ step.endedAt = iso();
89134
+ }
89135
+ settle(job);
89136
+ commit(job);
89137
+ return step;
89138
+ }
89139
+
89140
+ /** The checks on a step's work moved on (checkJobs' state for its goal). */
89141
+ function checksMoved(goalId, state, summary = null) {
89142
+ if (!goalId) return null;
89143
+ const job = jobOf(goalIndex().get(goalId));
89144
+ const step = job && job.steps.find((s) => s.goalId === goalId);
89145
+ if (!step) return null;
89146
+ const next =
89147
+ state === "passed"
89148
+ ? "done"
89149
+ : state === "needs-you" || state === "waiting"
89150
+ ? "needs-you"
89151
+ : state === "stopped" || state === "gone"
89152
+ ? "stopped"
89153
+ : "checking";
89154
+ if (step.status === next) return step;
89155
+ step.status = next;
89156
+ if (summary) step.summary = clip$5(summary, MAX_SUMMARY);
89157
+ if (FINAL.has(next)) step.endedAt = iso();
89158
+ if (!ACTIVE.has(next)) settle(job);
89159
+ else unsettle(job.id);
89160
+ commit(job);
89161
+ return step;
89162
+ }
89163
+
89164
+ /** The job a goal's work belongs to (a check retry joins it). */
89165
+ function jobForGoal(goalId) {
89166
+ if (!goalId) return null;
89167
+ return goalIndex().get(goalId) || null;
89168
+ }
89169
+
89170
+ /** Still going (or waiting on the user): a hand-on may join it. */
89171
+ function isOpen(jobId) {
89172
+ const job = jobOf(jobId);
89173
+ return !!job && !FINAL.has(job.status);
89174
+ }
89175
+
89176
+ /**
89177
+ * Hand-ons still waiting for a bot that won't take them: its queued
89178
+ * events ran (a newer one replaced theirs) or it was deleted. They're
89179
+ * skipped, said why, so their jobs can end.
89180
+ */
89181
+ function releaseWaiting(botId, summary) {
89182
+ for (const job of store.list()) {
89183
+ if (FINAL.has(job.status)) continue;
89184
+ const waiting = job.steps.filter(
89185
+ (st) => st.botId === botId && WAITING.has(st.status),
89186
+ );
89187
+ if (!waiting.length) continue;
89188
+ for (const st of waiting) {
89189
+ st.status = "skipped";
89190
+ st.summary = clip$5(summary, MAX_SUMMARY);
89191
+ st.endedAt = iso();
89192
+ }
89193
+ settle(job);
89194
+ commit(job);
89195
+ }
89196
+ }
89197
+
89198
+ /** Stop job: its waiting hand-ons won't start. */
89199
+ function stopWaiting(jobId) {
89200
+ const job = jobOf(jobId);
89201
+ if (!job) return null;
89202
+ for (const st of job.steps) {
89203
+ if (WAITING.has(st.status)) {
89204
+ st.status = "stopped";
89205
+ st.summary = "Stopped before it started.";
89206
+ st.endedAt = iso();
89207
+ }
89208
+ }
89209
+ settle(job);
89210
+ return commit(job);
89211
+ }
89212
+
89213
+ /** Resolves with the job once it has finished (done, failed or stopped). */
89214
+ function waitForEnd(jobId) {
89215
+ const job = jobOf(jobId);
89216
+ if (!job) return Promise.resolve(null);
89217
+ if (FINAL.has(job.status) && !settling.has(job.id)) {
89218
+ return Promise.resolve(job);
89219
+ }
89220
+ return new Promise((resolve) => {
89221
+ const list = waiters.get(job.id) || [];
89222
+ list.push(resolve);
89223
+ waiters.set(job.id, list);
89224
+ });
89225
+ }
89226
+
89227
+ /**
89228
+ * After a restart: what was still going when Dash closed is stopped, said
89229
+ * plainly. Runs don't survive a restart.
89230
+ */
89231
+ function interruptLeftovers() {
89232
+ for (const job of store.list()) {
89233
+ if (FINAL.has(job.status)) continue;
89234
+ // Made for a task whose lead never started before Dash closed.
89235
+ if (!job.steps.length) {
89236
+ const st = addStep(job, {
89237
+ botId: job.leadId,
89238
+ botName: job.leadName,
89239
+ status: "stopped",
89240
+ why: job.startedBy,
89241
+ summary: "Dash closed before it started.",
89242
+ });
89243
+ st.endedAt = iso();
89244
+ commit(job);
89245
+ continue;
89246
+ }
89247
+ let changed = false;
89248
+ for (const s of job.steps) {
89249
+ if (ACTIVE.has(s.status) || s.status === "needs-you") {
89250
+ s.status = "stopped";
89251
+ s.summary = "Dash closed while this was going.";
89252
+ s.endedAt = s.endedAt || iso();
89253
+ changed = true;
89254
+ }
89255
+ }
89256
+ if (changed || job.status !== jobStatus(job.steps)) commit(job);
89257
+ }
89258
+ }
89259
+
89260
+ function remove(jobId) {
89261
+ unsettle(jobId);
89262
+ // Anyone waiting for it (a task) hears it was stopped, never nothing.
89263
+ const job = jobOf(jobId);
89264
+ const list = waiters.get(jobId) || [];
89265
+ waiters.delete(jobId);
89266
+ for (const resolve of list) {
89267
+ resolve(job ? { ...job, status: "stopped" } : null);
89268
+ }
89269
+ if (byGoal) {
89270
+ for (const [g, j] of byGoal) if (j === jobId) byGoal.delete(g);
89271
+ }
89272
+ return store.remove(jobId);
89273
+ }
89274
+
89275
+ function list({ workspaceId } = {}) {
89276
+ const all = store.list();
89277
+ return workspaceId == null
89278
+ ? all
89279
+ : all.filter((j) => String(j.workspaceId) === String(workspaceId));
89280
+ }
89281
+
89282
+ return {
89283
+ startJob,
89284
+ startStep,
89285
+ waitStep,
89286
+ skipStep,
89287
+ endStep,
89288
+ checksMoved,
89289
+ jobForGoal,
89290
+ isOpen,
89291
+ releaseWaiting,
89292
+ stopWaiting,
89293
+ waitForEnd,
89294
+ interruptLeftovers,
89295
+ remove,
89296
+ list,
89297
+ get: (id) => store.get(id),
89298
+ };
89299
+ }
89300
+
89301
+ var jobTracker = { createJobTracker: createJobTracker$1, jobStatus, SETTLE_MS };
89302
+
88720
89303
  /**
88721
89304
  * pausedQueue.js — events that arrive for a paused (or over-budget) bot,
88722
89305
  * kept until it's resumed (bot-factory US-011 AC8, whilePaused "queue").
@@ -90157,8 +90740,13 @@ function createMcpTasks$1({
90157
90740
  return { wrong: true, triesLeft: MAX_WRONG - wrong };
90158
90741
  },
90159
90742
 
90160
- running(id) {
90161
- return update(id, { status: "running", confirmedAt: iso(now()) });
90743
+ /** `jobId`: the job that follows the whole chain (DASH-28). */
90744
+ running(id, { jobId = null } = {}) {
90745
+ return update(id, {
90746
+ status: "running",
90747
+ confirmedAt: iso(now()),
90748
+ ...(jobId ? { jobId } : {}),
90749
+ });
90162
90750
  },
90163
90751
 
90164
90752
  /**
@@ -105677,6 +106265,8 @@ const { EventDispatcher } = EventDispatcher_1;
105677
106265
  const { normalizeMcpResult } = mcpResult;
105678
106266
  const BotEventPublisher = BotEventPublisher_1;
105679
106267
  const { createCheckJobs } = checkJobs;
106268
+ const { createJobStore } = jobStore;
106269
+ const { createJobTracker } = jobTracker;
105680
106270
  const { PausedQueue, drainBot } = pausedQueue;
105681
106271
  const {
105682
106272
  stopBotRun,
@@ -105841,7 +106431,7 @@ const {
105841
106431
  buildNoteOf,
105842
106432
  } = planBuild;
105843
106433
  // Pure JS, main-process safe (see its header): a plan's new theme.
105844
- const { generateCustomTheme } = require$$48;
106434
+ const { generateCustomTheme } = require$$50;
105845
106435
  // Whose a saved theme is (theme change round) — pure, shared with the app.
105846
106436
  const {
105847
106437
  hasEditorChanges,
@@ -105850,7 +106440,7 @@ const {
105850
106440
  themeColors,
105851
106441
  themeOrigin,
105852
106442
  themePublished,
105853
- } = require$$49;
106443
+ } = require$$51;
105854
106444
  const { planTarget, validatePlan } = teamPlan;
105855
106445
  const { resolveEditTarget, ownsWidget } = editTarget;
105856
106446
  const { checkBot } = checkBot_1;
@@ -105937,6 +106527,59 @@ const TEST_ID_RE = /^test-[a-z0-9]{6,40}$/;
105937
106527
  // The most a sample sent with a save may be (an answer is cut at 32 KB).
105938
106528
  const MAX_SAMPLE_BYTES = 512 * 1024;
105939
106529
 
106530
+ // ---- Jobs (DASH-28, DASH-31): who or what started a step ------------------
106531
+
106532
+ /** "bot:local/designer[b1].completed" → "Completed". */
106533
+ function eventWord(eventType) {
106534
+ const last =
106535
+ String(eventType || "")
106536
+ .split(".")
106537
+ .pop() || "";
106538
+ return last ? last.charAt(0).toUpperCase() + last.slice(1) : "";
106539
+ }
106540
+
106541
+ /** Who started a lead's job: a task over MCP, or the user in Dash. */
106542
+ function jobStartedBy(opts = {}) {
106543
+ const m = /^mcp-task(?::(.*))?$/.exec(String(opts.via || ""));
106544
+ if (m) return { kind: "task", label: m[1] || "MCP" };
106545
+ if (/^mcp/.test(String(opts.via || ""))) return { kind: "mcp", label: "MCP" };
106546
+ return { kind: "you" };
106547
+ }
106548
+
106549
+ /** A hand-on: which bot's event started it. */
106550
+ function handOnWhy(store, event, bot) {
106551
+ const from = event && event.originBotId ? store.get(event.originBotId) : null;
106552
+ const sub = ((bot && bot.subscriptions) || []).find(
106553
+ (s) => s && s.eventType === (event && event.eventType),
106554
+ );
106555
+ return {
106556
+ kind: "handon",
106557
+ by: (from && from.name) || null,
106558
+ label: (sub && sub.label) || eventWord(event && event.eventType),
106559
+ };
106560
+ }
106561
+
106562
+ /** Why a run is a step in its job. */
106563
+ function jobWhy(store, bot, opts = {}) {
106564
+ if (isLead(bot)) return { ...jobStartedBy(opts) };
106565
+ const lead = /^lead:(.+)$/.exec(String(opts.via || ""));
106566
+ if (lead) {
106567
+ const l = store.get(lead[1]);
106568
+ return { kind: "asked", by: (l && l.name) || null };
106569
+ }
106570
+ if (opts.trigger === "event" && opts.source) {
106571
+ const from = opts.source.originBotId
106572
+ ? store.get(opts.source.originBotId)
106573
+ : null;
106574
+ return {
106575
+ kind: "handon",
106576
+ by: (from && from.name) || null,
106577
+ label: opts.source.label || eventWord(opts.source.eventType),
106578
+ };
106579
+ }
106580
+ return { kind: opts.trigger || "run" };
106581
+ }
106582
+
105940
106583
  /** A test's sample, as test() made it, small enough to keep. */
105941
106584
  function isSample(sample) {
105942
106585
  if (!sample || typeof sample !== "object" || Array.isArray(sample)) {
@@ -105990,6 +106633,7 @@ const {
105990
106633
  BOT_OPEN_REQUEST: BOT_OPEN_REQUEST$1,
105991
106634
  BOT_PLAN_BUILD_PROGRESS: BOT_PLAN_BUILD_PROGRESS$1,
105992
106635
  BOT_MCP_TASKS_CHANGED: BOT_MCP_TASKS_CHANGED$1,
106636
+ BOT_JOBS_CHANGED: BOT_JOBS_CHANGED$1,
105993
106637
  CREATE_RECENT_CHANGED: CREATE_RECENT_CHANGED$1,
105994
106638
  } = botEvents$2;
105995
106639
  const { LLM_MODEL_LIST_CHANGED: LLM_MODEL_LIST_CHANGED$1 } = llmEvents$1;
@@ -106240,15 +106884,43 @@ const botController$1 = {
106240
106884
  goals: () => goalController$1.store(),
106241
106885
  getBot: (id) => this._store.get(id),
106242
106886
  publisher: this._events,
106243
- patchRun: (id, startedAt, patch) =>
106244
- this._store.patchRun(id, startedAt, patch),
106887
+ patchRun: (id, startedAt, patch) => {
106888
+ const r = this._store.patchRun(id, startedAt, patch);
106889
+ // The job's step follows its checks (DASH-31).
106890
+ if (patch && patch.checks && patch.checks.goalId && this._jobs) {
106891
+ this._jobs.checksMoved(patch.checks.goalId, patch.checks.state);
106892
+ }
106893
+ return r;
106894
+ },
106245
106895
  getRuns: (id) => this._store.getRuns(id),
106246
- notify: (botId, info) =>
106896
+ notify: (botId, info) => {
106247
106897
  this._broadcast(BOT_STREAM$1, {
106248
106898
  botId,
106249
106899
  event: { type: "checked", ...info },
106900
+ });
106901
+ // Checks waiting on the user show on the job (DASH-31).
106902
+ if (info && info.goalId && this._jobs) {
106903
+ this._jobs.checksMoved(info.goalId, info.state);
106904
+ }
106905
+ },
106906
+ });
106907
+
106908
+ // Jobs (DASH-28, DASH-31): each chain of work through a team lead —
106909
+ // the lead's run, the bots it asks, their checks and hand-ons — kept on
106910
+ // this computer until the user deletes them.
106911
+ this._jobs = createJobTracker({
106912
+ store: createJobStore({
106913
+ root: path$4.join(path$4.dirname(this._botsRoot), "jobs"),
106914
+ box: host.secretBox || null,
106915
+ }),
106916
+ onChange: (job) =>
106917
+ this._broadcast(BOT_JOBS_CHANGED$1, {
106918
+ jobId: job.id,
106919
+ workspaceId: job.workspaceId,
106920
+ status: job.status,
106250
106921
  }),
106251
106922
  });
106923
+ this._jobs.interruptLeftovers();
106252
106924
 
106253
106925
  this._runner = new BotRunner({
106254
106926
  engines,
@@ -106566,7 +107238,19 @@ const botController$1 = {
106566
107238
  this._holdEvent(bot, event);
106567
107239
  continue;
106568
107240
  }
106569
- if (!this._dispatcher.shouldDispatch(bot.id)) continue;
107241
+ if (!this._dispatcher.shouldDispatch(bot.id)) {
107242
+ // In a job, the hand-on that didn't start is said (DASH-31).
107243
+ const jobId = this._handOnJob(event, bot);
107244
+ if (jobId) {
107245
+ this._jobs.skipStep(jobId, {
107246
+ botId: bot.id,
107247
+ botName: bot.name,
107248
+ why: handOnWhy(this._store, event, bot),
107249
+ summary: `${bot.name} ran moments ago, so this hand-on was skipped.`,
107250
+ });
107251
+ }
107252
+ continue;
107253
+ }
106570
107254
  this._dispatcher.note(bot.id);
106571
107255
  this._runEvent(bot, event);
106572
107256
  }
@@ -106602,6 +107286,30 @@ const botController$1 = {
106602
107286
  */
106603
107287
  _holdEvent(bot, event) {
106604
107288
  const source = sourceFromEvent(bot, event);
107289
+ // In a job (DASH-31): the hand-on waits for the user, or is skipped.
107290
+ const jobId = this._handOnJob(event, bot);
107291
+ if (jobId) {
107292
+ const why = handOnWhy(this._store, event, bot);
107293
+ const paused = this._pause.isPaused(bot.id);
107294
+ const held = paused ? "is paused" : "is over its budget";
107295
+ if (bot.whilePaused === "drop") {
107296
+ this._jobs.skipStep(event.jobId, {
107297
+ botId: bot.id,
107298
+ botName: bot.name,
107299
+ why,
107300
+ summary: `${bot.name} ${held} and skips events meanwhile, so it didn't run.`,
107301
+ });
107302
+ } else {
107303
+ this._jobs.waitStep(event.jobId, {
107304
+ botId: bot.id,
107305
+ botName: bot.name,
107306
+ why,
107307
+ summary: paused
107308
+ ? `${bot.name} is paused, so it hasn't started. Turn it on and it starts.`
107309
+ : `${bot.name} is over its budget, so it hasn't started.`,
107310
+ });
107311
+ }
107312
+ }
106605
107313
  if (bot.whilePaused === "drop") {
106606
107314
  const now = new Date().toISOString();
106607
107315
  this._store.appendRun(bot.id, {
@@ -106645,7 +107353,14 @@ const botController$1 = {
106645
107353
  isHeld: (id) => this._isHeld(id),
106646
107354
  runOne: (item) => this._runQueued(botId, item),
106647
107355
  })
106648
- .then(() => this._notifyListChanged())
107356
+ .then(() => {
107357
+ const name = (this._store.get(botId) || {}).name || "The bot";
107358
+ this._jobs.releaseWaiting(
107359
+ botId,
107360
+ `${name} ran a newer event instead of this one.`,
107361
+ );
107362
+ this._notifyListChanged();
107363
+ })
106649
107364
  .catch(() => {});
106650
107365
  this._notifyListChanged();
106651
107366
  }
@@ -107036,6 +107751,13 @@ const botController$1 = {
107036
107751
  if (isLead(bot) && bot.workspaceId) {
107037
107752
  this._store.setTeamSettings(bot.workspaceId, { leadEnabled: false });
107038
107753
  }
107754
+ // Hand-ons in jobs that were waiting for it won't run (DASH-31).
107755
+ if (this._jobs) {
107756
+ this._jobs.releaseWaiting(
107757
+ botId,
107758
+ "Its bot was deleted, so it didn't run.",
107759
+ );
107760
+ }
107039
107761
  // Its private memory (bots with no dashboard) goes with it; team and
107040
107762
  // global memory are shared and stay.
107041
107763
  this._memory.forgetBot(botId);
@@ -107779,6 +108501,107 @@ const botController$1 = {
107779
108501
  return notes;
107780
108502
  },
107781
108503
 
108504
+ // ---- Jobs (DASH-28, DASH-31) --------------------------------------------
108505
+
108506
+ /** Jobs, newest change first — one dashboard's with workspaceId. */
108507
+ listJobs({ workspaceId = null } = {}) {
108508
+ return this._jobs ? this._jobs.list({ workspaceId }) : [];
108509
+ },
108510
+
108511
+ getJob(jobId) {
108512
+ return this._jobs ? this._jobs.get(String(jobId || "")) : null;
108513
+ },
108514
+
108515
+ /** A task given via MCP: its job, made before the lead starts on it. */
108516
+ startTaskJob(task) {
108517
+ if (!this._jobs || !task) return null;
108518
+ const lead = this._store.get(task.leadId) || {};
108519
+ return this._jobs.startJob({
108520
+ workspaceId: lead.workspaceId,
108521
+ leadId: task.leadId,
108522
+ leadName: lead.name || task.teamName || "",
108523
+ title: task.task,
108524
+ startedBy: {
108525
+ kind: "task",
108526
+ label: task.from || "MCP",
108527
+ taskId: task.id,
108528
+ },
108529
+ }).id;
108530
+ },
108531
+
108532
+ /** The lead never started on the job (busy, paused…): it stops, said why. */
108533
+ abandonJob(jobId, summary) {
108534
+ const job = this.getJob(jobId);
108535
+ if (!job) return null;
108536
+ // Its lead's run already has a step (it ran, or was skipped).
108537
+ if (job.steps.some((s) => s.botId === job.leadId)) return null;
108538
+ return this._jobs.skipStep(job.id, {
108539
+ botId: job.leadId,
108540
+ botName: job.leadName,
108541
+ why: job.startedBy,
108542
+ summary,
108543
+ });
108544
+ },
108545
+
108546
+ /**
108547
+ * The job a hand-on joins: its event's, while that job is still open and
108548
+ * on the bot's own dashboard — never one that has ended, or another
108549
+ * dashboard's (DASH-31).
108550
+ */
108551
+ _handOnJob(event, bot) {
108552
+ const jobId = event && event.jobId;
108553
+ if (!jobId || !this._jobs || !this._jobs.isOpen(jobId)) return null;
108554
+ const job = this._jobs.get(jobId);
108555
+ const ws = bot && bot.workspaceId != null ? String(bot.workspaceId) : null;
108556
+ return job && job.workspaceId === ws ? jobId : null;
108557
+ },
108558
+
108559
+ /** Resolves with the job once its whole chain has finished. */
108560
+ waitForJob(jobId) {
108561
+ return this._jobs ? this._jobs.waitForEnd(jobId) : Promise.resolve(null);
108562
+ },
108563
+
108564
+ /** Stop every bot still running in the job. */
108565
+ stopJob(jobId) {
108566
+ const job = this.getJob(jobId);
108567
+ if (!job) return { ok: false };
108568
+ for (const s of job.steps) {
108569
+ if (s.status === "running") this.stop(s.botId);
108570
+ // Its checks: their job closes, so no more retries.
108571
+ if (s.status === "checking" && s.goalId) {
108572
+ try {
108573
+ goalController$1.close(s.goalId);
108574
+ } catch (_e) {
108575
+ // The step still stops below.
108576
+ }
108577
+ this._jobs.checksMoved(s.goalId, "stopped");
108578
+ }
108579
+ }
108580
+ this._jobs.stopWaiting(job.id);
108581
+ return { ok: true };
108582
+ },
108583
+
108584
+ /** Delete a job — only ever because the user asked. Not while it runs. */
108585
+ deleteJob(jobId) {
108586
+ const job = this.getJob(jobId);
108587
+ if (!job) return { ok: false };
108588
+ const going = job.steps.some((s) =>
108589
+ ["queued", "running", "checking"].includes(s.status),
108590
+ );
108591
+ if (job.status === "running" || going) {
108592
+ return { ok: false, error: "Stop the job before deleting it." };
108593
+ }
108594
+ const ok = this._jobs.remove(job.id);
108595
+ if (ok) {
108596
+ this._broadcast(BOT_JOBS_CHANGED$1, {
108597
+ jobId: job.id,
108598
+ workspaceId: job.workspaceId,
108599
+ status: "deleted",
108600
+ });
108601
+ }
108602
+ return { ok };
108603
+ },
108604
+
107782
108605
  /** "Unlock now" after 5 wrong passphrases. */
107783
108606
  unlockMcpTasks() {
107784
108607
  this._mcpTasks.unlock();
@@ -107843,6 +108666,8 @@ const botController$1 = {
107843
108666
  // What to show as asked (an MCP task without the app's notes), and who.
107844
108667
  shown = null,
107845
108668
  from = null,
108669
+ // A task's job, made before the lead starts (DASH-28).
108670
+ jobId = null,
107846
108671
  } = {},
107847
108672
  ) {
107848
108673
  const bot = this._store.get(botId);
@@ -107869,6 +108694,9 @@ const botController$1 = {
107869
108694
  // asks record it on their runs.
107870
108695
  conversationId: conversationId || (kept && kept.id) || null,
107871
108696
  ...(kept ? { onEvent: kept.onEvent } : {}),
108697
+ ...(jobId ? { jobId } : {}),
108698
+ // The job is named for what was asked, not the app's notes.
108699
+ ...(shown ? { jobTitle: shown } : {}),
107872
108700
  });
107873
108701
  // Asked in the app, it's the user's run: a paused lead still answers.
107874
108702
  // Asked over MCP ("mcp", "mcp-task…"), pause holds.
@@ -109416,6 +110244,58 @@ const botController$1 = {
109416
110244
  : rootCause());
109417
110245
  const goal = cause.goal || { goalId: null, taskId: null };
109418
110246
  cause.goal = goal;
110247
+ // The job (DASH-28, DASH-31): a team lead's own run starts one; every
110248
+ // run in its chain joins it — a bot it asks, a hand-on, a check's
110249
+ // retry. Its id rides the cause, so the run's events carry it on.
110250
+ const bot = this._store.get(botId) || {};
110251
+ const willStart = !this._runner.listActive().includes(botId);
110252
+ let jobId =
110253
+ opts.jobId ||
110254
+ (cause.jobId ? this._handOnJob(cause, bot) : null) ||
110255
+ (goal.goalId ? this._jobs.jobForGoal(goal.goalId) : null) ||
110256
+ null;
110257
+ if (
110258
+ !jobId &&
110259
+ willStart &&
110260
+ isLead(bot) &&
110261
+ !isDashTeam(bot) &&
110262
+ !opts.noTools &&
110263
+ opts.trigger !== "schedule" &&
110264
+ opts.trigger !== "catch-up"
110265
+ ) {
110266
+ jobId = this._jobs.startJob({
110267
+ workspaceId: bot.workspaceId,
110268
+ leadId: bot.id,
110269
+ leadName: bot.name,
110270
+ title: String(opts.jobTitle || opts.prompt || "").split("\n")[0],
110271
+ startedBy: jobStartedBy(opts),
110272
+ conversationId: opts.conversationId || null,
110273
+ }).id;
110274
+ }
110275
+ if (jobId) cause.jobId = jobId;
110276
+ // A check's retry or review is part of its step's checks, not a step.
110277
+ let jobStep = null;
110278
+ if (jobId && willStart && opts.trigger !== "flow") {
110279
+ jobStep = this._jobs.startStep(jobId, {
110280
+ botId,
110281
+ botName: bot.name,
110282
+ why: jobWhy(this._store, bot, opts),
110283
+ conversationId: opts.conversationId || null,
110284
+ });
110285
+ } else if (jobId && !willStart && opts.trigger === "event") {
110286
+ this._jobs.skipStep(jobId, {
110287
+ botId,
110288
+ botName: bot.name,
110289
+ why: jobWhy(this._store, bot, opts),
110290
+ summary: `${bot.name} was busy with another run, so this hand-on didn't start.`,
110291
+ });
110292
+ }
110293
+ let jobStepEnded = false;
110294
+ const endJobStep = (record, checking = null) => {
110295
+ if (!jobStep || jobStepEnded) return;
110296
+ jobStepEnded = true;
110297
+ this._jobs.endStep(jobId, { botId, record, checking });
110298
+ };
109419
110299
  // A bot with checks holds the results it sends until they pass
109420
110300
  // (bot-checks PRD).
109421
110301
  if (!alreadyRunning) {
@@ -109431,6 +110311,7 @@ const botController$1 = {
109431
110311
  viaEntry = {
109432
110312
  via: opts.via || null,
109433
110313
  conversationId: opts.conversationId || null,
110314
+ jobId,
109434
110315
  };
109435
110316
  this._runVia.set(botId, viaEntry);
109436
110317
  // The run's goal, so a goal deleted mid-run is forgotten by it.
@@ -109485,6 +110366,14 @@ const botController$1 = {
109485
110366
  // already updated here. Broadcast on start and again on completion so the
109486
110367
  // tray/powerSaveBlocker can react (US-018).
109487
110368
  this._broadcastRunActive();
110369
+ // The run in progress, so a lead asking a bot that a hand-on in the same
110370
+ // job already started waits for that run (DASH-28).
110371
+ let activeEntry = null;
110372
+ if (willStart) {
110373
+ if (!this._runsInProgress) this._runsInProgress = new Map();
110374
+ activeEntry = { jobId, promise: Promise.resolve(p) };
110375
+ this._runsInProgress.set(botId, activeEntry);
110376
+ }
109488
110377
  Promise.resolve(p)
109489
110378
  .then((record) => {
109490
110379
  // A bot with checks: its work is held as a job until they pass
@@ -109501,13 +110390,26 @@ const botController$1 = {
109501
110390
  if (!alreadyRunning && !held) {
109502
110391
  this._events.endRun(this._store.get(botId), record);
109503
110392
  }
110393
+ endJobStep(
110394
+ record,
110395
+ held && record && record.checks && record.checks.goalId
110396
+ ? { goalId: record.checks.goalId }
110397
+ : null,
110398
+ );
109504
110399
  // A failed run notifies (US-018 AC5).
109505
110400
  this._sendNotice(failureNotice(this._store.get(botId), record));
109506
110401
  // What went wrong goes in Issues; a clean run resolves the bot's.
109507
110402
  this._recordRunIssues(this._store.get(botId), record);
109508
110403
  })
109509
- .catch(() => {})
110404
+ .catch((e) => {
110405
+ endJobStep({ status: "failed", error: (e && e.message) || null });
110406
+ })
109510
110407
  .finally(() => {
110408
+ // A run that ended without a record still ends its step.
110409
+ endJobStep({ status: "stopped" });
110410
+ if (activeEntry && this._runsInProgress.get(botId) === activeEntry) {
110411
+ this._runsInProgress.delete(botId);
110412
+ }
109511
110413
  if (viaEntry && this._runVia.get(botId) === viaEntry) {
109512
110414
  this._runVia.delete(botId);
109513
110415
  }
@@ -112010,6 +112912,9 @@ const botController$1 = {
112010
112912
  if (!this._leadAsked) this._leadAsked = new Map();
112011
112913
  const info = leadRunInfo(this._runVia ? this._runVia.get(lead.id) : null);
112012
112914
  const leadGoal = this._runGoals ? this._runGoals.get(lead.id) : null;
112915
+ // The lead's job: the bot it asks joins it (DASH-28).
112916
+ const leadEntry = this._runVia ? this._runVia.get(lead.id) : null;
112917
+ const jobId = (leadEntry && leadEntry.jobId) || null;
112013
112918
  const result = await askTeamBot({
112014
112919
  lead,
112015
112920
  member,
@@ -112021,10 +112926,17 @@ const botController$1 = {
112021
112926
  goal: leadGoal && leadGoal.goalId ? leadGoal : null,
112022
112927
  takeHandoff: () => this._handoffs.take(lead.id, runKey),
112023
112928
  // For the user's own request, the bot's run is theirs too.
112024
- run: (opts) =>
112025
- this._inUserRun(lead.id)
112026
- ? this._asUserRun(member.id, () => this._run(member.id, opts))
112027
- : this._run(member.id, opts),
112929
+ run: (opts) => {
112930
+ // Already running in this job (a hand-on started it): the lead
112931
+ // waits for that run's answer instead of hearing "busy" (DASH-28).
112932
+ const going =
112933
+ this._runsInProgress && this._runsInProgress.get(member.id);
112934
+ if (jobId && going && going.jobId === jobId) return going.promise;
112935
+ const withJob = jobId ? { ...opts, jobId } : opts;
112936
+ return this._inUserRun(lead.id)
112937
+ ? this._asUserRun(member.id, () => this._run(member.id, withJob))
112938
+ : this._run(member.id, withJob);
112939
+ },
112028
112940
  // Stopping the lead stops the bots it's waiting on (stop()).
112029
112941
  track: (p) => {
112030
112942
  const asked = this._leadAsked.get(lead.id) || new Set();
@@ -130565,6 +131477,10 @@ const {
130565
131477
  BOTS_ASK_LEAD,
130566
131478
  BOTS_LIST_LEADS,
130567
131479
  BOTS_LIST_MCP_TASKS,
131480
+ BOTS_LIST_JOBS,
131481
+ BOTS_GET_JOB,
131482
+ BOTS_STOP_JOB,
131483
+ BOTS_DELETE_JOB,
130568
131484
  BOTS_LIST_MCP_ROUTES,
130569
131485
  BOTS_LIST_MCP_TASK_TEAMS,
130570
131486
  BOTS_SET_TAKES_MCP_TASKS,
@@ -130597,6 +131513,7 @@ const {
130597
131513
  BOT_OPEN_REQUEST,
130598
131514
  BOT_PLAN_BUILD_PROGRESS,
130599
131515
  BOT_MCP_TASKS_CHANGED,
131516
+ BOT_JOBS_CHANGED,
130600
131517
  } = botEvents$2;
130601
131518
 
130602
131519
  let _nextListenerId$1 = 0;
@@ -130867,6 +131784,16 @@ const botApi$1 = {
130867
131784
  /** A team's tasks via MCP, newest first (all teams without one). */
130868
131785
  listMcpTasks: (workspaceId = null, limit = 20) =>
130869
131786
  ipcRenderer$3.invoke(BOTS_LIST_MCP_TASKS, { workspaceId, limit }),
131787
+ // ---- Jobs: each chain of work through a team lead (DASH-28, DASH-31) ----
131788
+ /** Jobs, newest change first; one dashboard's with workspaceId. */
131789
+ listJobs: (workspaceId = null) =>
131790
+ ipcRenderer$3.invoke(BOTS_LIST_JOBS, { workspaceId }),
131791
+ /** One job with its steps, or null. */
131792
+ getJob: (jobId) => ipcRenderer$3.invoke(BOTS_GET_JOB, { jobId }),
131793
+ /** Stop every bot still running in the job. */
131794
+ stopJob: (jobId) => ipcRenderer$3.invoke(BOTS_STOP_JOB, { jobId }),
131795
+ /** Delete a finished job (only the user deletes jobs). */
131796
+ deleteJob: (jobId) => ipcRenderer$3.invoke(BOTS_DELETE_JOB, { jobId }),
130870
131797
  /** The Dash Lead's routing log, newest first. */
130871
131798
  listMcpRoutes: (limit = 20) =>
130872
131799
  ipcRenderer$3.invoke(BOTS_LIST_MCP_ROUTES, { limit }),
@@ -130909,6 +131836,8 @@ const botApi$1 = {
130909
131836
  /** Tasks via MCP, the routing log, the passphrase or the lock changed. */
130910
131837
  onMcpTasksChanged: (callback) =>
130911
131838
  _addListener(BOT_MCP_TASKS_CHANGED, callback),
131839
+ /** A job started, moved on or ended: { jobId, workspaceId, status }. */
131840
+ onJobsChanged: (callback) => _addListener(BOT_JOBS_CHANGED, callback),
130912
131841
  /** Recent changed (a save, a build's progress, a removal). */
130913
131842
  onCreateRecent: (callback) => _addListener(CREATE_RECENT_CHANGED, callback),
130914
131843
 
@@ -131244,7 +132173,7 @@ const TEAM_TOOLS = [
131244
132173
  {
131245
132174
  name: "get_task_status",
131246
132175
  description:
131247
- "How a task from give_task is going: waiting for the passphrase, running, done (with the team's summary), failed (with why), or expired.",
132176
+ "How a task from give_task is going: waiting for the passphrase, running, done (with the team's summary), failed (with why), or expired. A task is running until every bot it set going has finished — the lead, the bots it asked and the ones they handed on to; steps lists each, with its status.",
131248
132177
  inputSchema: {
131249
132178
  type: "object",
131250
132179
  properties: {
@@ -131295,6 +132224,64 @@ const taskView = (t) => ({
131295
132224
  ...(t.endedAt ? { endedAt: t.endedAt } : {}),
131296
132225
  });
131297
132226
 
132227
+ /** Why a step in a job started, in a few words. */
132228
+ function stepWhy(why) {
132229
+ const w = why || {};
132230
+ if (w.kind === "task") return `Task${w.label ? ` from ${w.label}` : ""}`;
132231
+ if (w.kind === "you") return "Asked in Dash";
132232
+ if (w.kind === "asked") return `Asked by ${w.by || "the team lead"}`;
132233
+ if (w.kind === "handon") {
132234
+ return `Started by ${w.by || "a bot"}${w.label ? ` › ${w.label}` : ""}`;
132235
+ }
132236
+ return w.kind || "";
132237
+ }
132238
+
132239
+ /** A job's steps as the agent sees them (DASH-28): bot, status, why. */
132240
+ const stepsView = (job) =>
132241
+ ((job && job.steps) || []).map((st) => ({
132242
+ bot: st.botName,
132243
+ status: st.status,
132244
+ startedBy: stepWhy(st.why),
132245
+ ...(st.summary
132246
+ ? {
132247
+ summary:
132248
+ st.summary.length > LIST_CHARS
132249
+ ? `${st.summary.slice(0, LIST_CHARS)}…`
132250
+ : st.summary,
132251
+ }
132252
+ : {}),
132253
+ ...(st.startedAt ? { startedAt: st.startedAt } : {}),
132254
+ ...(st.endedAt ? { endedAt: st.endedAt } : {}),
132255
+ }));
132256
+
132257
+ /** Running: which bots are still going, or waiting on the user. */
132258
+ function stillGoing(job) {
132259
+ const steps = (job && job.steps) || [];
132260
+ const going = steps
132261
+ .filter((st) => ["queued", "running", "checking"].includes(st.status))
132262
+ .map((st) => st.botName);
132263
+ const waiting = steps
132264
+ .filter((st) => st.status === "needs-you")
132265
+ .map((st) => st.summary || `${st.botName} is waiting on the user.`);
132266
+ return [going.length ? `Still going: ${going.join(", ")}.` : "", ...waiting]
132267
+ .filter(Boolean)
132268
+ .join(" ");
132269
+ }
132270
+
132271
+ /** After the lead's answer: what the bots it set off said (hand-ons). */
132272
+ function afterLead(job) {
132273
+ return ((job && job.steps) || [])
132274
+ .filter(
132275
+ (st) =>
132276
+ st.why &&
132277
+ st.why.kind === "handon" &&
132278
+ st.status === "done" &&
132279
+ st.summary,
132280
+ )
132281
+ .map((st) => `${st.botName}: ${st.summary}`)
132282
+ .join(" ");
132283
+ }
132284
+
131298
132285
  const STATUS_MESSAGE = {
131299
132286
  waiting: (t) =>
131300
132287
  `Waiting for the user's task passphrase (expires at ${timeOf(t.expiresAt)}). Ask them for it and call confirm_task.`,
@@ -131368,7 +132355,10 @@ function makeTeamToolHandlers({
131368
132355
  // (allowed — the user confirmed it), and the task follows the run.
131369
132356
  const startTask = (task) => {
131370
132357
  const tasks = bots.tasks();
131371
- tasks.running(task.id);
132358
+ // Its job follows the whole chain — the lead, the bots it asks and
132359
+ // their hand-ons — so the task is done only when all of it is (DASH-28).
132360
+ const jobId = bots.startTaskJob ? bots.startTaskJob(task) : null;
132361
+ tasks.running(task.id, { jobId });
131372
132362
  const via = `mcp-task${task.from ? `:${task.from}` : ""}`;
131373
132363
  // Notes left by an earlier run don't belong to this task.
131374
132364
  const takeNotes = () =>
@@ -131381,10 +132371,17 @@ function makeTeamToolHandlers({
131381
132371
  // Kept as a conversation: the task as it was given, and by whom.
131382
132372
  shown: task.task,
131383
132373
  from: task.from || "mcp",
132374
+ ...(jobId ? { jobId } : {}),
131384
132375
  }),
131385
132376
  )
131386
132377
  .then((result) => {
131387
132378
  if (result && result.skipped) {
132379
+ if (jobId && bots.abandonJob) {
132380
+ bots.abandonJob(
132381
+ jobId,
132382
+ `The team lead didn't start${result.reason ? `: ${result.reason}` : ""}.`,
132383
+ );
132384
+ }
131388
132385
  return tasks.failed(
131389
132386
  task.id,
131390
132387
  result.reason && result.reason !== "a run is already in progress"
@@ -131395,6 +132392,13 @@ function makeTeamToolHandlers({
131395
132392
  // Only a finished run is done: one stopped in Dash, or cut off when
131396
132393
  // Dash closed, has at most part of an answer. Each keeps its run.
131397
132394
  const ran = { runAt: (result && result.startedAt) || null };
132395
+ const ok = result && result.status === "completed" && !result.error;
132396
+ if (!ok && jobId && bots.abandonJob) {
132397
+ bots.abandonJob(
132398
+ jobId,
132399
+ (result && result.error) || "The team lead didn't finish.",
132400
+ );
132401
+ }
131398
132402
  if (result && result.status === "stopped") {
131399
132403
  return tasks.failed(task.id, "It was stopped in Dash.", ran);
131400
132404
  }
@@ -131413,15 +132417,39 @@ function makeTeamToolHandlers({
131413
132417
  );
131414
132418
  }
131415
132419
  const notes = takeNotes();
131416
- return tasks.done(task.id, {
132420
+ const lead = {
131417
132421
  summary: withoutHandoff(result.output) || "",
131418
132422
  runAt: result.startedAt || null,
131419
132423
  needsYou: notes.length ? notes.join(" ") : null,
132424
+ };
132425
+ if (!jobId || !bots.waitForJob) return tasks.done(task.id, lead);
132426
+ // The lead has answered; the task ends when its job does.
132427
+ return Promise.resolve(bots.waitForJob(jobId)).then((job) => {
132428
+ if (!job || job.status === "done") {
132429
+ const more = afterLead(job);
132430
+ return tasks.done(task.id, {
132431
+ ...lead,
132432
+ summary: more ? `${lead.summary} ${more}`.trim() : lead.summary,
132433
+ });
132434
+ }
132435
+ const bad = job.steps.find(
132436
+ (st) => st.status === "failed" || st.status === "stopped",
132437
+ );
132438
+ return tasks.failed(
132439
+ task.id,
132440
+ bad
132441
+ ? `${bad.botName} ${bad.status === "failed" ? "failed" : "was stopped"}${bad.summary ? `: ${bad.summary}` : "."}`
132442
+ : `The job ${job.status}.`,
132443
+ { runAt: lead.runAt },
132444
+ );
131420
132445
  });
131421
132446
  })
131422
- .catch((err) =>
131423
- tasks.failed(task.id, (err && err.message) || String(err)),
131424
- );
132447
+ .catch((err) => {
132448
+ if (jobId && bots.abandonJob) {
132449
+ bots.abandonJob(jobId, (err && err.message) || String(err));
132450
+ }
132451
+ return tasks.failed(task.id, (err && err.message) || String(err));
132452
+ });
131425
132453
  };
131426
132454
 
131427
132455
  /** Passphrase checks out → start; otherwise say what to do next. */
@@ -131667,9 +132695,12 @@ function makeTeamToolHandlers({
131667
132695
  if (!task) {
131668
132696
  return json({ message: "No task with that taskId." }, true);
131669
132697
  }
132698
+ const job = task.jobId && bots.getJob ? bots.getJob(task.jobId) : null;
132699
+ const going = task.status === "running" && job ? stillGoing(job) : "";
131670
132700
  return json({
131671
132701
  ...taskView(task),
131672
- message: STATUS_MESSAGE[task.status](task),
132702
+ ...(job ? { jobId: job.id, steps: stepsView(job) } : {}),
132703
+ message: `${STATUS_MESSAGE[task.status](task)}${going ? ` ${going}` : ""}`,
131673
132704
  });
131674
132705
  },
131675
132706
 
@@ -131830,6 +132861,11 @@ function registerTeamTools$1() {
131830
132861
  routeTask: (task, teams, opts) =>
131831
132862
  botController.routeMcpTask(task, teams, opts),
131832
132863
  takeTaskNotes: (leadId) => botController.takeTaskNotes(leadId),
132864
+ // Jobs (DASH-28): the task follows its whole chain.
132865
+ startTaskJob: (task) => botController.startTaskJob(task),
132866
+ waitForJob: (jobId) => botController.waitForJob(jobId),
132867
+ getJob: (jobId) => botController.getJob(jobId),
132868
+ abandonJob: (jobId, why) => botController.abandonJob(jobId, why),
131833
132869
  },
131834
132870
  });
131835
132871