@trops/dash-core 0.1.624 → 0.1.626
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/electron/index.js +146 -2
- package/dist/electron/index.js.map +1 -1
- package/dist/index.esm.js +409 -46
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +409 -46
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/electron/index.js
CHANGED
|
@@ -976,11 +976,18 @@ const BOTS_GET_BUDGETS$1 = "bots-get-budgets";
|
|
|
976
976
|
const BOTS_SET_BUDGET$1 = "bots-set-budget";
|
|
977
977
|
const BOTS_GET_SPEND$1 = "bots-get-spend";
|
|
978
978
|
const BOTS_RESUME_BUDGET$1 = "bots-resume-budget";
|
|
979
|
+
const BOTS_LIST_RUNNING$1 = "bots-list-running";
|
|
980
|
+
const BOTS_PAUSE_ALL$1 = "bots-pause-all";
|
|
981
|
+
const BOTS_RESUME_ALL$1 = "bots-resume-all";
|
|
982
|
+
const BOTS_PAUSE_BOT$1 = "bots-pause-bot";
|
|
983
|
+
const BOTS_RESUME_BOT$1 = "bots-resume-bot";
|
|
984
|
+
const BOTS_GET_PAUSE_STATE$1 = "bots-get-pause-state";
|
|
979
985
|
|
|
980
986
|
// --- Main → Renderer (send) ---
|
|
981
987
|
const BOT_STREAM$2 = "bot-stream"; // { botId, event: BotEvent }
|
|
982
988
|
const BOT_APPROVAL_PENDING$2 = "bot-approval-pending"; // { id, request }
|
|
983
989
|
const BOT_BUDGET_ALERT$2 = "bot-budget-alert"; // { botId, cost, estimated, status }
|
|
990
|
+
const BOT_RUN_ACTIVE$2 = "bot-run-active"; // { count, running: string[] }
|
|
984
991
|
|
|
985
992
|
var botEvents$1 = {
|
|
986
993
|
BOTS_LIST: BOTS_LIST$1,
|
|
@@ -995,9 +1002,16 @@ var botEvents$1 = {
|
|
|
995
1002
|
BOTS_SET_BUDGET: BOTS_SET_BUDGET$1,
|
|
996
1003
|
BOTS_GET_SPEND: BOTS_GET_SPEND$1,
|
|
997
1004
|
BOTS_RESUME_BUDGET: BOTS_RESUME_BUDGET$1,
|
|
1005
|
+
BOTS_LIST_RUNNING: BOTS_LIST_RUNNING$1,
|
|
1006
|
+
BOTS_PAUSE_ALL: BOTS_PAUSE_ALL$1,
|
|
1007
|
+
BOTS_RESUME_ALL: BOTS_RESUME_ALL$1,
|
|
1008
|
+
BOTS_PAUSE_BOT: BOTS_PAUSE_BOT$1,
|
|
1009
|
+
BOTS_RESUME_BOT: BOTS_RESUME_BOT$1,
|
|
1010
|
+
BOTS_GET_PAUSE_STATE: BOTS_GET_PAUSE_STATE$1,
|
|
998
1011
|
BOT_STREAM: BOT_STREAM$2,
|
|
999
1012
|
BOT_APPROVAL_PENDING: BOT_APPROVAL_PENDING$2,
|
|
1000
1013
|
BOT_BUDGET_ALERT: BOT_BUDGET_ALERT$2,
|
|
1014
|
+
BOT_RUN_ACTIVE: BOT_RUN_ACTIVE$2,
|
|
1001
1015
|
};
|
|
1002
1016
|
|
|
1003
1017
|
/**
|
|
@@ -75420,6 +75434,63 @@ BudgetController$2.exports.WARN_AT = WARN_AT;
|
|
|
75420
75434
|
|
|
75421
75435
|
var BudgetControllerExports = BudgetController$2.exports;
|
|
75422
75436
|
|
|
75437
|
+
/**
|
|
75438
|
+
* PauseController.js
|
|
75439
|
+
*
|
|
75440
|
+
* Holds bot pause state and answers "is this bot paused?" for the permission
|
|
75441
|
+
* gate (PRD US-014). Pause is enforced at the gate: while paused, every tool
|
|
75442
|
+
* call is denied, so any engine halts at its next tool boundary. Two levels
|
|
75443
|
+
* ship here — a global "pause all" kill switch and per-bot pause; the workspace/
|
|
75444
|
+
* project levels layer on later using the same shape.
|
|
75445
|
+
*
|
|
75446
|
+
* Portable (NFR-006): pure state, injected audit sink, no Electron.
|
|
75447
|
+
*/
|
|
75448
|
+
|
|
75449
|
+
let PauseController$1 = class PauseController {
|
|
75450
|
+
constructor({ audit } = {}) {
|
|
75451
|
+
this._global = false;
|
|
75452
|
+
this._bots = new Set();
|
|
75453
|
+
this._audit = audit || (() => {});
|
|
75454
|
+
}
|
|
75455
|
+
|
|
75456
|
+
/** Global kill switch — pauses every bot (US-014 AC7). */
|
|
75457
|
+
pauseAll() {
|
|
75458
|
+
this._global = true;
|
|
75459
|
+
this._audit({ type: "pause-all" });
|
|
75460
|
+
}
|
|
75461
|
+
|
|
75462
|
+
resumeAll() {
|
|
75463
|
+
this._global = false;
|
|
75464
|
+
this._audit({ type: "resume-all" });
|
|
75465
|
+
}
|
|
75466
|
+
|
|
75467
|
+
isGloballyPaused() {
|
|
75468
|
+
return this._global;
|
|
75469
|
+
}
|
|
75470
|
+
|
|
75471
|
+
pauseBot(botId) {
|
|
75472
|
+
this._bots.add(botId);
|
|
75473
|
+
this._audit({ type: "pause-bot", botId });
|
|
75474
|
+
}
|
|
75475
|
+
|
|
75476
|
+
resumeBot(botId) {
|
|
75477
|
+
this._bots.delete(botId);
|
|
75478
|
+
this._audit({ type: "resume-bot", botId });
|
|
75479
|
+
}
|
|
75480
|
+
|
|
75481
|
+
/** True when the global switch is on OR this bot is individually paused. */
|
|
75482
|
+
isPaused(botId) {
|
|
75483
|
+
return this._global || this._bots.has(botId);
|
|
75484
|
+
}
|
|
75485
|
+
|
|
75486
|
+
/** @returns {{ global: boolean, bots: string[] }} */
|
|
75487
|
+
list() {
|
|
75488
|
+
return { global: this._global, bots: [...this._bots] };
|
|
75489
|
+
}
|
|
75490
|
+
};
|
|
75491
|
+
|
|
75492
|
+
var PauseController_1 = PauseController$1;
|
|
75493
|
+
|
|
75423
75494
|
/**
|
|
75424
75495
|
* mcpResult.js
|
|
75425
75496
|
*
|
|
@@ -75485,6 +75556,7 @@ const engines = engines$1;
|
|
|
75485
75556
|
const BotRunner = BotRunner_1;
|
|
75486
75557
|
const BotScheduler = BotScheduler_1;
|
|
75487
75558
|
const BudgetController = BudgetControllerExports;
|
|
75559
|
+
const PauseController = PauseController_1;
|
|
75488
75560
|
const { normalizeMcpResult } = mcpResult;
|
|
75489
75561
|
const {
|
|
75490
75562
|
getProvider: getProvider$1,
|
|
@@ -75497,6 +75569,7 @@ const {
|
|
|
75497
75569
|
BOT_STREAM: BOT_STREAM$1,
|
|
75498
75570
|
BOT_APPROVAL_PENDING: BOT_APPROVAL_PENDING$1,
|
|
75499
75571
|
BOT_BUDGET_ALERT: BOT_BUDGET_ALERT$1,
|
|
75572
|
+
BOT_RUN_ACTIVE: BOT_RUN_ACTIVE$1,
|
|
75500
75573
|
} = botEvents$1;
|
|
75501
75574
|
|
|
75502
75575
|
/** Pricing lookup for BudgetController: curated-model pricing by provider. */
|
|
@@ -75551,6 +75624,9 @@ const botController$1 = {
|
|
|
75551
75624
|
},
|
|
75552
75625
|
};
|
|
75553
75626
|
|
|
75627
|
+
// Pause state (global kill switch + per-bot), enforced at the gate.
|
|
75628
|
+
this._pause = new PauseController();
|
|
75629
|
+
|
|
75554
75630
|
// Budgets: accrue per-run cost, auto-pause bots over their monthly cap.
|
|
75555
75631
|
this._budgets = new BudgetController({
|
|
75556
75632
|
persistence: host.budgetPersistence,
|
|
@@ -75565,8 +75641,10 @@ const botController$1 = {
|
|
|
75565
75641
|
resolveTools: (bot) => this._resolveTools(bot),
|
|
75566
75642
|
callTool: (serverName, toolName, args, o) =>
|
|
75567
75643
|
this._callTool(serverName, toolName, args, o),
|
|
75568
|
-
//
|
|
75644
|
+
// Paused at the permission gate when: globally/individually paused, or
|
|
75645
|
+
// over any applicable budget.
|
|
75569
75646
|
isPaused: (botId) =>
|
|
75647
|
+
this._pause.isPaused(botId) ||
|
|
75570
75648
|
this._budgets.isOverBudget(
|
|
75571
75649
|
botId,
|
|
75572
75650
|
(this._store.get(botId) || {}).workspaceId,
|
|
@@ -75670,14 +75748,63 @@ const botController$1 = {
|
|
|
75670
75748
|
return this._budgets.resumeOverBudget(botId);
|
|
75671
75749
|
},
|
|
75672
75750
|
|
|
75751
|
+
// ---- background / pause (US-014, US-018) ---------------------------------
|
|
75752
|
+
|
|
75753
|
+
/** @returns {Array<{id: string, name: string}>} bots with an in-flight run */
|
|
75754
|
+
listRunning() {
|
|
75755
|
+
return this._runner.listActive().map((id) => ({
|
|
75756
|
+
id,
|
|
75757
|
+
name: (this._store.get(id) || {}).name || id,
|
|
75758
|
+
}));
|
|
75759
|
+
},
|
|
75760
|
+
|
|
75761
|
+
pauseAll() {
|
|
75762
|
+
this._pause.pauseAll();
|
|
75763
|
+
return this._pause.list();
|
|
75764
|
+
},
|
|
75765
|
+
|
|
75766
|
+
resumeAll() {
|
|
75767
|
+
this._pause.resumeAll();
|
|
75768
|
+
return this._pause.list();
|
|
75769
|
+
},
|
|
75770
|
+
|
|
75771
|
+
pauseBot(botId) {
|
|
75772
|
+
this._pause.pauseBot(botId);
|
|
75773
|
+
return this._pause.list();
|
|
75774
|
+
},
|
|
75775
|
+
|
|
75776
|
+
resumeBot(botId) {
|
|
75777
|
+
this._pause.resumeBot(botId);
|
|
75778
|
+
return this._pause.list();
|
|
75779
|
+
},
|
|
75780
|
+
|
|
75781
|
+
isGloballyPaused() {
|
|
75782
|
+
return this._pause.isGloballyPaused();
|
|
75783
|
+
},
|
|
75784
|
+
|
|
75785
|
+
getPauseState() {
|
|
75786
|
+
return this._pause.list();
|
|
75787
|
+
},
|
|
75788
|
+
|
|
75673
75789
|
// ---- internals ----------------------------------------------------------
|
|
75674
75790
|
|
|
75675
75791
|
_run(botId, opts) {
|
|
75676
|
-
|
|
75792
|
+
const p = this._runner.run(botId, {
|
|
75677
75793
|
prompt: opts.prompt,
|
|
75678
75794
|
trigger: opts.trigger,
|
|
75679
75795
|
emit: (event) => this._broadcast(BOT_STREAM$1, { botId, event }),
|
|
75680
75796
|
});
|
|
75797
|
+
// The runner marks the bot active synchronously, so the active count is
|
|
75798
|
+
// already updated here. Broadcast on start and again on completion so the
|
|
75799
|
+
// tray/powerSaveBlocker can react (US-018).
|
|
75800
|
+
this._broadcastRunActive();
|
|
75801
|
+
Promise.resolve(p).finally(() => this._broadcastRunActive());
|
|
75802
|
+
return p;
|
|
75803
|
+
},
|
|
75804
|
+
|
|
75805
|
+
_broadcastRunActive() {
|
|
75806
|
+
const running = this._runner.listActive();
|
|
75807
|
+
this._broadcast(BOT_RUN_ACTIVE$1, { count: running.length, running });
|
|
75681
75808
|
},
|
|
75682
75809
|
|
|
75683
75810
|
_broadcast(channel, payload) {
|
|
@@ -79667,9 +79794,16 @@ const {
|
|
|
79667
79794
|
BOTS_SET_BUDGET,
|
|
79668
79795
|
BOTS_GET_SPEND,
|
|
79669
79796
|
BOTS_RESUME_BUDGET,
|
|
79797
|
+
BOTS_LIST_RUNNING,
|
|
79798
|
+
BOTS_PAUSE_ALL,
|
|
79799
|
+
BOTS_RESUME_ALL,
|
|
79800
|
+
BOTS_PAUSE_BOT,
|
|
79801
|
+
BOTS_RESUME_BOT,
|
|
79802
|
+
BOTS_GET_PAUSE_STATE,
|
|
79670
79803
|
BOT_STREAM,
|
|
79671
79804
|
BOT_APPROVAL_PENDING,
|
|
79672
79805
|
BOT_BUDGET_ALERT,
|
|
79806
|
+
BOT_RUN_ACTIVE,
|
|
79673
79807
|
} = botEvents$1;
|
|
79674
79808
|
|
|
79675
79809
|
let _nextListenerId = 0;
|
|
@@ -79706,12 +79840,22 @@ const botApi$1 = {
|
|
|
79706
79840
|
getSpend: (month) => ipcRenderer$3.invoke(BOTS_GET_SPEND, { month }),
|
|
79707
79841
|
resumeBudget: (botId) => ipcRenderer$3.invoke(BOTS_RESUME_BUDGET, { botId }),
|
|
79708
79842
|
|
|
79843
|
+
// --- Background / pause (US-014, US-018) ---
|
|
79844
|
+
listRunning: () => ipcRenderer$3.invoke(BOTS_LIST_RUNNING),
|
|
79845
|
+
pauseAll: () => ipcRenderer$3.invoke(BOTS_PAUSE_ALL),
|
|
79846
|
+
resumeAll: () => ipcRenderer$3.invoke(BOTS_RESUME_ALL),
|
|
79847
|
+
pauseBot: (botId) => ipcRenderer$3.invoke(BOTS_PAUSE_BOT, { botId }),
|
|
79848
|
+
resumeBot: (botId) => ipcRenderer$3.invoke(BOTS_RESUME_BOT, { botId }),
|
|
79849
|
+
getPauseState: () => ipcRenderer$3.invoke(BOTS_GET_PAUSE_STATE),
|
|
79850
|
+
|
|
79709
79851
|
/** Subscribe to streamed run events: { botId, event }. */
|
|
79710
79852
|
onStream: (callback) => _addListener(BOT_STREAM, callback),
|
|
79711
79853
|
/** Subscribe to new pending approvals: { id, request }. */
|
|
79712
79854
|
onApprovalPending: (callback) => _addListener(BOT_APPROVAL_PENDING, callback),
|
|
79713
79855
|
/** Subscribe to budget warn/exceeded alerts. */
|
|
79714
79856
|
onBudgetAlert: (callback) => _addListener(BOT_BUDGET_ALERT, callback),
|
|
79857
|
+
/** Subscribe to active-run count changes: { count, running }. */
|
|
79858
|
+
onRunActive: (callback) => _addListener(BOT_RUN_ACTIVE, callback),
|
|
79715
79859
|
|
|
79716
79860
|
removeListener: (id) => {
|
|
79717
79861
|
const entry = _listenerMap.get(id);
|