@trops/dash-core 0.1.890 → 0.1.891
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 +757 -14
- package/dist/electron/index.js.map +1 -1
- package/package.json +1 -1
package/dist/electron/index.js
CHANGED
|
@@ -4016,14 +4016,14 @@ var approvalErrorReason_1 = { approvalErrorReason: approvalErrorReason$3, format
|
|
|
4016
4016
|
* a deliberate malicious step that's visible at install-time review.
|
|
4017
4017
|
*/
|
|
4018
4018
|
|
|
4019
|
-
const crypto$
|
|
4019
|
+
const crypto$4 = require$$0$4;
|
|
4020
4020
|
|
|
4021
4021
|
const _byToken = new Map(); // token → widgetId
|
|
4022
4022
|
|
|
4023
4023
|
function _generateToken() {
|
|
4024
4024
|
// 24 random bytes = 48 hex chars = 192 bits of entropy. More than
|
|
4025
4025
|
// enough; collision probability is negligible.
|
|
4026
|
-
return crypto$
|
|
4026
|
+
return crypto$4.randomBytes(24).toString("hex");
|
|
4027
4027
|
}
|
|
4028
4028
|
|
|
4029
4029
|
/**
|
|
@@ -68012,7 +68012,7 @@ var themeGenerator = /*#__PURE__*/Object.freeze({
|
|
|
68012
68012
|
getThemePresets: getThemePresets
|
|
68013
68013
|
});
|
|
68014
68014
|
|
|
68015
|
-
var require$$
|
|
68015
|
+
var require$$41 = /*@__PURE__*/getAugmentedNamespace(themeGenerator);
|
|
68016
68016
|
|
|
68017
68017
|
/**
|
|
68018
68018
|
* paletteToThemeMapper.js
|
|
@@ -68023,7 +68023,7 @@ var require$$40 = /*@__PURE__*/getAugmentedNamespace(themeGenerator);
|
|
|
68023
68023
|
*/
|
|
68024
68024
|
|
|
68025
68025
|
const { TAILWIND_COLORS: TAILWIND_COLORS$1 } = require$$13;
|
|
68026
|
-
const { generateThemeName } = require$$
|
|
68026
|
+
const { generateThemeName } = require$$41;
|
|
68027
68027
|
|
|
68028
68028
|
const VALID_HEX_RE = /^#[0-9a-fA-F]{6}$/;
|
|
68029
68029
|
|
|
@@ -76408,7 +76408,7 @@ var remix = { remixOrigin: remixOrigin$4, checkRemix: checkRemix$4, checkRemixAl
|
|
|
76408
76408
|
* that change by themselves.
|
|
76409
76409
|
*/
|
|
76410
76410
|
|
|
76411
|
-
const crypto$
|
|
76411
|
+
const crypto$3 = require$$0$4;
|
|
76412
76412
|
|
|
76413
76413
|
const DASHBOARD_LOCAL = new Set([
|
|
76414
76414
|
"id",
|
|
@@ -76452,7 +76452,7 @@ function stableStringify(value) {
|
|
|
76452
76452
|
}
|
|
76453
76453
|
|
|
76454
76454
|
function hash(value) {
|
|
76455
|
-
return crypto$
|
|
76455
|
+
return crypto$3
|
|
76456
76456
|
.createHash("sha256")
|
|
76457
76457
|
.update(stableStringify(value))
|
|
76458
76458
|
.digest("hex")
|
|
@@ -77360,7 +77360,7 @@ var themeStanding = /*#__PURE__*/Object.freeze({
|
|
|
77360
77360
|
themePublished: themePublished$1
|
|
77361
77361
|
});
|
|
77362
77362
|
|
|
77363
|
-
var require$$
|
|
77363
|
+
var require$$42 = /*@__PURE__*/getAugmentedNamespace(themeStanding);
|
|
77364
77364
|
|
|
77365
77365
|
/**
|
|
77366
77366
|
* themeRegistryController.js
|
|
@@ -78175,7 +78175,7 @@ async function getThemePublishPreview$1(appId, themeKey) {
|
|
|
78175
78175
|
// the registry couldn't be asked.
|
|
78176
78176
|
let published = null;
|
|
78177
78177
|
try {
|
|
78178
|
-
const { themePublished } = require$$
|
|
78178
|
+
const { themePublished } = require$$42;
|
|
78179
78179
|
let username = null;
|
|
78180
78180
|
try {
|
|
78181
78181
|
username =
|
|
@@ -78877,6 +78877,62 @@ let BotStore$1 = class BotStore {
|
|
|
78877
78877
|
return data.teams[key];
|
|
78878
78878
|
}
|
|
78879
78879
|
|
|
78880
|
+
// ---- Tasks via MCP (bot-teams TEAM-016) ---------------------------------
|
|
78881
|
+
|
|
78882
|
+
/** Tasks given via MCP — the user's words, so sealed at rest like results. */
|
|
78883
|
+
getMcpTasks() {
|
|
78884
|
+
const { mcpTasks } = this._load();
|
|
78885
|
+
if (typeof mcpTasks !== "string") return null;
|
|
78886
|
+
const json = this._box ? this._box.open(mcpTasks) : mcpTasks;
|
|
78887
|
+
if (typeof json !== "string") return null;
|
|
78888
|
+
try {
|
|
78889
|
+
return JSON.parse(json);
|
|
78890
|
+
} catch (_e) {
|
|
78891
|
+
return null;
|
|
78892
|
+
}
|
|
78893
|
+
}
|
|
78894
|
+
|
|
78895
|
+
setMcpTasks(tasks) {
|
|
78896
|
+
const data = this._load();
|
|
78897
|
+
const json = JSON.stringify(tasks || []);
|
|
78898
|
+
data.mcpTasks = this._box ? this._box.seal(json) : json;
|
|
78899
|
+
this._save(data);
|
|
78900
|
+
}
|
|
78901
|
+
|
|
78902
|
+
/** The task passphrase (sealed, like provider keys), or null. */
|
|
78903
|
+
getTaskPassphrase() {
|
|
78904
|
+
const { taskPassphrase } = this._load();
|
|
78905
|
+
if (typeof taskPassphrase !== "string" || !taskPassphrase) return null;
|
|
78906
|
+
const text = this._box ? this._box.open(taskPassphrase) : taskPassphrase;
|
|
78907
|
+
return typeof text === "string" && text ? text : null;
|
|
78908
|
+
}
|
|
78909
|
+
|
|
78910
|
+
/** Set it, or clear it with null. */
|
|
78911
|
+
setTaskPassphrase(text) {
|
|
78912
|
+
const data = this._load();
|
|
78913
|
+
if (typeof text === "string" && text) {
|
|
78914
|
+
data.taskPassphrase = this._box ? this._box.seal(text) : text;
|
|
78915
|
+
} else {
|
|
78916
|
+
delete data.taskPassphrase;
|
|
78917
|
+
}
|
|
78918
|
+
this._save(data);
|
|
78919
|
+
}
|
|
78920
|
+
|
|
78921
|
+
/** Wrong passphrases in a row and the lock: { wrong, until }. */
|
|
78922
|
+
getTaskLock() {
|
|
78923
|
+
const { taskLock } = this._load();
|
|
78924
|
+
return taskLock || null;
|
|
78925
|
+
}
|
|
78926
|
+
|
|
78927
|
+
setTaskLock(lock) {
|
|
78928
|
+
const data = this._load();
|
|
78929
|
+
data.taskLock = {
|
|
78930
|
+
wrong: Number(lock && lock.wrong) || 0,
|
|
78931
|
+
until: (lock && lock.until) || null,
|
|
78932
|
+
};
|
|
78933
|
+
this._save(data);
|
|
78934
|
+
}
|
|
78935
|
+
|
|
78880
78936
|
/**
|
|
78881
78937
|
* Global bot settings. Defaults: autoLeads on; background mode (US-018) —
|
|
78882
78938
|
* keep running with the window closed, start at login, don't keep awake.
|
|
@@ -84037,6 +84093,262 @@ async function zipAndPublish$1(files, manifest) {
|
|
|
84037
84093
|
|
|
84038
84094
|
var botPublish = { registryIdentity: registryIdentity$1, zipAndPublish: zipAndPublish$1 };
|
|
84039
84095
|
|
|
84096
|
+
/**
|
|
84097
|
+
* mcpTasks.js — tasks given to a team via Dash's MCP server (bot-teams
|
|
84098
|
+
* TEAM-016): an agent such as the user's own bridge gives a team a task, and
|
|
84099
|
+
* the team starts only once the user's task passphrase checks out.
|
|
84100
|
+
*
|
|
84101
|
+
* waiting → given, waiting for the passphrase (expires after 10 minutes)
|
|
84102
|
+
* running → confirmed; the team's lead is doing it
|
|
84103
|
+
* done / failed / expired
|
|
84104
|
+
*
|
|
84105
|
+
* The passphrase is any word or phrase the user sets in Settings › MCP
|
|
84106
|
+
* Server. It's compared loosely, because it's usually spoken and voice-to-text
|
|
84107
|
+
* never writes it the same way twice: case, punctuation and extra spaces don't
|
|
84108
|
+
* count. 5 wrong tries lock tasks for 15 minutes. The passphrase never goes in
|
|
84109
|
+
* a reply, a task or a log.
|
|
84110
|
+
*
|
|
84111
|
+
* Pure: the store (load/save of tasks, the passphrase and the lock) and the
|
|
84112
|
+
* clock are injected; botController keeps them in dash-bots.json, sealed.
|
|
84113
|
+
*/
|
|
84114
|
+
|
|
84115
|
+
const crypto$2 = require$$0$4;
|
|
84116
|
+
|
|
84117
|
+
const TASK_EXPIRES_MS = 10 * 60 * 1000;
|
|
84118
|
+
const MAX_WRONG = 5;
|
|
84119
|
+
const LOCK_MS = 15 * 60 * 1000;
|
|
84120
|
+
const MAX_TASKS = 50;
|
|
84121
|
+
const MIN_LETTERS = 4;
|
|
84122
|
+
const SHORT_LETTERS = 8;
|
|
84123
|
+
const MAX_TASK_CHARS = 4000;
|
|
84124
|
+
|
|
84125
|
+
/** "Purple, Otter." → "purple otter" */
|
|
84126
|
+
function normalizePassphrase(text) {
|
|
84127
|
+
return String(text == null ? "" : text)
|
|
84128
|
+
.normalize("NFKC")
|
|
84129
|
+
.toLowerCase()
|
|
84130
|
+
.replace(/[^\p{L}\p{N}]+/gu, " ")
|
|
84131
|
+
.trim();
|
|
84132
|
+
}
|
|
84133
|
+
|
|
84134
|
+
/**
|
|
84135
|
+
* Can this be the passphrase? { ok, error?, short? } — short is advice
|
|
84136
|
+
* ("Short and easy to guess"), not a refusal.
|
|
84137
|
+
*/
|
|
84138
|
+
function checkPassphrase$1(text) {
|
|
84139
|
+
const letters = normalizePassphrase(text).replace(/ /g, "");
|
|
84140
|
+
if (letters.length < MIN_LETTERS) {
|
|
84141
|
+
return {
|
|
84142
|
+
ok: false,
|
|
84143
|
+
error: `Use at least ${MIN_LETTERS} letters.`,
|
|
84144
|
+
};
|
|
84145
|
+
}
|
|
84146
|
+
return { ok: true, short: letters.length < SHORT_LETTERS };
|
|
84147
|
+
}
|
|
84148
|
+
|
|
84149
|
+
const same = (a, b) => {
|
|
84150
|
+
// Hash both so the compare takes the same time whatever the lengths.
|
|
84151
|
+
const ha = crypto$2.createHash("sha256").update(a).digest();
|
|
84152
|
+
const hb = crypto$2.createHash("sha256").update(b).digest();
|
|
84153
|
+
return crypto$2.timingSafeEqual(ha, hb);
|
|
84154
|
+
};
|
|
84155
|
+
|
|
84156
|
+
/** An agent's name for itself, kept short and plain ("ha-bridge"). */
|
|
84157
|
+
function cleanFrom(from) {
|
|
84158
|
+
const s = String(from == null ? "" : from)
|
|
84159
|
+
.replace(/[^\p{L}\p{N} ._-]+/gu, "")
|
|
84160
|
+
.trim()
|
|
84161
|
+
.slice(0, 40);
|
|
84162
|
+
return s || null;
|
|
84163
|
+
}
|
|
84164
|
+
|
|
84165
|
+
/**
|
|
84166
|
+
* @param {object} deps
|
|
84167
|
+
* @param {{ loadTasks: () => object[]|null, saveTasks: (t: object[]) => void,
|
|
84168
|
+
* getPassphrase: () => string|null,
|
|
84169
|
+
* getLock: () => object|null, saveLock: (l: object) => void }} deps.store
|
|
84170
|
+
* @param {() => number} [deps.now]
|
|
84171
|
+
* @param {() => string} [deps.newId]
|
|
84172
|
+
*/
|
|
84173
|
+
function createMcpTasks$1({
|
|
84174
|
+
store,
|
|
84175
|
+
now = () => Date.now(),
|
|
84176
|
+
newId = () => `task_${crypto$2.randomBytes(6).toString("hex")}`,
|
|
84177
|
+
}) {
|
|
84178
|
+
const iso = (t) => new Date(t).toISOString();
|
|
84179
|
+
|
|
84180
|
+
const load = () => {
|
|
84181
|
+
const list = store.loadTasks();
|
|
84182
|
+
return Array.isArray(list) ? list : [];
|
|
84183
|
+
};
|
|
84184
|
+
// Over the limit, the oldest finished tasks go first — never one that's
|
|
84185
|
+
// still waiting or running.
|
|
84186
|
+
const save = (list) => {
|
|
84187
|
+
let out = list;
|
|
84188
|
+
while (out.length > MAX_TASKS) {
|
|
84189
|
+
const i = out.findIndex(
|
|
84190
|
+
(t) => t.status !== "waiting" && t.status !== "running",
|
|
84191
|
+
);
|
|
84192
|
+
if (i < 0) break;
|
|
84193
|
+
out = [...out.slice(0, i), ...out.slice(i + 1)];
|
|
84194
|
+
}
|
|
84195
|
+
store.saveTasks(out);
|
|
84196
|
+
};
|
|
84197
|
+
|
|
84198
|
+
// A waiting task past its time is expired, on every read.
|
|
84199
|
+
const withExpiry = (list) => {
|
|
84200
|
+
const t = now();
|
|
84201
|
+
let changed = false;
|
|
84202
|
+
const out = list.map((task) => {
|
|
84203
|
+
if (task.status === "waiting" && Date.parse(task.expiresAt) <= t) {
|
|
84204
|
+
changed = true;
|
|
84205
|
+
return { ...task, status: "expired", endedAt: task.expiresAt };
|
|
84206
|
+
}
|
|
84207
|
+
return task;
|
|
84208
|
+
});
|
|
84209
|
+
if (changed) save(out);
|
|
84210
|
+
return out;
|
|
84211
|
+
};
|
|
84212
|
+
|
|
84213
|
+
const update = (id, patch) => {
|
|
84214
|
+
const list = withExpiry(load());
|
|
84215
|
+
const i = list.findIndex((t) => t.id === id);
|
|
84216
|
+
if (i < 0) return null;
|
|
84217
|
+
list[i] = { ...list[i], ...patch };
|
|
84218
|
+
save(list);
|
|
84219
|
+
return list[i];
|
|
84220
|
+
};
|
|
84221
|
+
|
|
84222
|
+
const lockState = () => {
|
|
84223
|
+
const l = store.getLock() || {};
|
|
84224
|
+
return {
|
|
84225
|
+
wrong: Number(l.wrong) || 0,
|
|
84226
|
+
until: l.until || null,
|
|
84227
|
+
};
|
|
84228
|
+
};
|
|
84229
|
+
|
|
84230
|
+
return {
|
|
84231
|
+
/** A new task, waiting for the passphrase. */
|
|
84232
|
+
create({ task, team, from = null, routedBy = null }) {
|
|
84233
|
+
const t = now();
|
|
84234
|
+
const record = {
|
|
84235
|
+
id: newId(),
|
|
84236
|
+
task: String(task || "").slice(0, MAX_TASK_CHARS),
|
|
84237
|
+
teamId: String(team.id),
|
|
84238
|
+
teamName: team.name || "Untitled",
|
|
84239
|
+
leadId: team.leadId || null,
|
|
84240
|
+
from: cleanFrom(from),
|
|
84241
|
+
routedBy: routedBy || null,
|
|
84242
|
+
status: "waiting",
|
|
84243
|
+
createdAt: iso(t),
|
|
84244
|
+
expiresAt: iso(t + TASK_EXPIRES_MS),
|
|
84245
|
+
};
|
|
84246
|
+
save([...withExpiry(load()), record]);
|
|
84247
|
+
return record;
|
|
84248
|
+
},
|
|
84249
|
+
|
|
84250
|
+
get(id) {
|
|
84251
|
+
return withExpiry(load()).find((t) => t.id === String(id)) || null;
|
|
84252
|
+
},
|
|
84253
|
+
|
|
84254
|
+
/** Newest first. */
|
|
84255
|
+
list({ teamId = null, limit = 20 } = {}) {
|
|
84256
|
+
return withExpiry(load())
|
|
84257
|
+
.filter((t) => teamId === null || t.teamId === String(teamId))
|
|
84258
|
+
.reverse()
|
|
84259
|
+
.slice(0, limit);
|
|
84260
|
+
},
|
|
84261
|
+
|
|
84262
|
+
/** Locked until (ISO), or null. */
|
|
84263
|
+
lockedUntil() {
|
|
84264
|
+
const { until } = lockState();
|
|
84265
|
+
return until && Date.parse(until) > now() ? until : null;
|
|
84266
|
+
},
|
|
84267
|
+
|
|
84268
|
+
/** Unlock early (Settings › MCP Server: "Unlock now"). */
|
|
84269
|
+
unlock() {
|
|
84270
|
+
store.saveLock({ wrong: 0, until: null });
|
|
84271
|
+
},
|
|
84272
|
+
|
|
84273
|
+
/**
|
|
84274
|
+
* Check a passphrase.
|
|
84275
|
+
* @returns {{ ok: true } | { notSet: true } | { locked: string }
|
|
84276
|
+
* | { wrong: true, triesLeft: number, locked?: string }}
|
|
84277
|
+
*/
|
|
84278
|
+
verify(passphrase) {
|
|
84279
|
+
const locked = this.lockedUntil();
|
|
84280
|
+
if (locked) return { locked };
|
|
84281
|
+
const set = store.getPassphrase();
|
|
84282
|
+
if (!set) return { notSet: true };
|
|
84283
|
+
const given = normalizePassphrase(passphrase);
|
|
84284
|
+
if (given && same(given, normalizePassphrase(set))) {
|
|
84285
|
+
store.saveLock({ wrong: 0, until: null });
|
|
84286
|
+
return { ok: true };
|
|
84287
|
+
}
|
|
84288
|
+
const { until } = lockState();
|
|
84289
|
+
// A lock that ran out starts the count again.
|
|
84290
|
+
const wrong =
|
|
84291
|
+
(until && Date.parse(until) <= now() ? 0 : lockState().wrong) + 1;
|
|
84292
|
+
if (wrong >= MAX_WRONG) {
|
|
84293
|
+
const lockUntil = iso(now() + LOCK_MS);
|
|
84294
|
+
store.saveLock({ wrong, until: lockUntil });
|
|
84295
|
+
return { wrong: true, triesLeft: 0, locked: lockUntil };
|
|
84296
|
+
}
|
|
84297
|
+
store.saveLock({ wrong, until: null });
|
|
84298
|
+
return { wrong: true, triesLeft: MAX_WRONG - wrong };
|
|
84299
|
+
},
|
|
84300
|
+
|
|
84301
|
+
running(id) {
|
|
84302
|
+
return update(id, { status: "running", confirmedAt: iso(now()) });
|
|
84303
|
+
},
|
|
84304
|
+
|
|
84305
|
+
done(id, { summary = "", runAt = null } = {}) {
|
|
84306
|
+
return update(id, {
|
|
84307
|
+
status: "done",
|
|
84308
|
+
summary: String(summary || "").slice(0, MAX_TASK_CHARS),
|
|
84309
|
+
endedAt: iso(now()),
|
|
84310
|
+
...(runAt ? { runAt } : {}),
|
|
84311
|
+
});
|
|
84312
|
+
},
|
|
84313
|
+
|
|
84314
|
+
failed(id, error) {
|
|
84315
|
+
return update(id, {
|
|
84316
|
+
status: "failed",
|
|
84317
|
+
error: String(error || "Something went wrong."),
|
|
84318
|
+
endedAt: iso(now()),
|
|
84319
|
+
});
|
|
84320
|
+
},
|
|
84321
|
+
|
|
84322
|
+
/** Dash restarted: a task that was running didn't finish. */
|
|
84323
|
+
recover() {
|
|
84324
|
+
const list = load();
|
|
84325
|
+
let changed = false;
|
|
84326
|
+
const out = list.map((t) => {
|
|
84327
|
+
if (t.status !== "running") return t;
|
|
84328
|
+
changed = true;
|
|
84329
|
+
return {
|
|
84330
|
+
...t,
|
|
84331
|
+
status: "failed",
|
|
84332
|
+
error: "Dash closed before the team finished.",
|
|
84333
|
+
endedAt: iso(now()),
|
|
84334
|
+
};
|
|
84335
|
+
});
|
|
84336
|
+
if (changed) save(out);
|
|
84337
|
+
},
|
|
84338
|
+
};
|
|
84339
|
+
}
|
|
84340
|
+
|
|
84341
|
+
var mcpTasks = {
|
|
84342
|
+
createMcpTasks: createMcpTasks$1,
|
|
84343
|
+
normalizePassphrase,
|
|
84344
|
+
checkPassphrase: checkPassphrase$1,
|
|
84345
|
+
cleanFrom,
|
|
84346
|
+
TASK_EXPIRES_MS,
|
|
84347
|
+
MAX_WRONG,
|
|
84348
|
+
LOCK_MS,
|
|
84349
|
+
MIN_LETTERS,
|
|
84350
|
+
};
|
|
84351
|
+
|
|
84040
84352
|
/**
|
|
84041
84353
|
* botUpdate.js
|
|
84042
84354
|
*
|
|
@@ -85211,15 +85523,18 @@ var teamLeads = {
|
|
|
85211
85523
|
* Safety: the lead only passes requests on, and its words can be steered by
|
|
85212
85524
|
* team data (email text, other bots' answers), so a bot run this way always
|
|
85213
85525
|
* asks the user before anything that changes things (approvalPolicy "ask";
|
|
85214
|
-
* tools the user chose to always allow stay allowed). A lead asked
|
|
85215
|
-
* outside Dash (
|
|
85526
|
+
* tools the user chose to always allow stay allowed). A lead asked a
|
|
85527
|
+
* question from outside Dash (via "mcp") can't run its bots at all; a task
|
|
85528
|
+
* given via MCP and confirmed with the user's passphrase can (TEAM-016).
|
|
85216
85529
|
*/
|
|
85217
85530
|
|
|
85218
85531
|
// How long a lead waits for a bot it asked before reporting it as still
|
|
85219
85532
|
// going — usually it's waiting on the user's approval.
|
|
85220
85533
|
const LEAD_ASK_WAIT_MS = 3 * 60 * 1000;
|
|
85221
85534
|
|
|
85222
|
-
// Where a lead's own run can come from that may not run its bots.
|
|
85535
|
+
// Where a lead's own run can come from that may not run its bots. A task
|
|
85536
|
+
// given via MCP ("mcp-task[:<from>]") may: the user confirmed it with their
|
|
85537
|
+
// task passphrase (TEAM-016).
|
|
85223
85538
|
const OUTSIDE_CALLERS = new Set(["mcp"]);
|
|
85224
85539
|
|
|
85225
85540
|
/**
|
|
@@ -92060,6 +92375,7 @@ const BOT_WIDGETS = {
|
|
|
92060
92375
|
activity: "dash.bots.BotActivity",
|
|
92061
92376
|
};
|
|
92062
92377
|
const { registryIdentity, zipAndPublish } = botPublish;
|
|
92378
|
+
const { createMcpTasks, checkPassphrase } = mcpTasks;
|
|
92063
92379
|
const {
|
|
92064
92380
|
makeRegistryRef: makeRegistryRef$1,
|
|
92065
92381
|
readRegistryRef: readRegistryRef$1,
|
|
@@ -92150,7 +92466,7 @@ const {
|
|
|
92150
92466
|
settingKeys,
|
|
92151
92467
|
} = planBuild;
|
|
92152
92468
|
// Pure JS, main-process safe (see its header): a plan's new theme.
|
|
92153
|
-
const { generateCustomTheme } = require$$
|
|
92469
|
+
const { generateCustomTheme } = require$$41;
|
|
92154
92470
|
// Whose a saved theme is (theme change round) — pure, shared with the app.
|
|
92155
92471
|
const {
|
|
92156
92472
|
hasEditorChanges,
|
|
@@ -92159,7 +92475,7 @@ const {
|
|
|
92159
92475
|
themeColors,
|
|
92160
92476
|
themeOrigin,
|
|
92161
92477
|
themePublished,
|
|
92162
|
-
} = require$$
|
|
92478
|
+
} = require$$42;
|
|
92163
92479
|
const { planTarget, validatePlan } = teamPlan;
|
|
92164
92480
|
const { resolveEditTarget, ownsWidget } = editTarget;
|
|
92165
92481
|
const { checkBot } = checkBot_1;
|
|
@@ -92354,6 +92670,19 @@ const botController$1 = {
|
|
|
92354
92670
|
},
|
|
92355
92671
|
};
|
|
92356
92672
|
|
|
92673
|
+
// Tasks given to teams via MCP (TEAM-016). One that was running when
|
|
92674
|
+
// Dash closed didn't finish.
|
|
92675
|
+
this._mcpTasks = createMcpTasks({
|
|
92676
|
+
store: {
|
|
92677
|
+
loadTasks: () => this._store.getMcpTasks(),
|
|
92678
|
+
saveTasks: (list) => this._store.setMcpTasks(list),
|
|
92679
|
+
getPassphrase: () => this._store.getTaskPassphrase(),
|
|
92680
|
+
getLock: () => this._store.getTaskLock(),
|
|
92681
|
+
saveLock: (lock) => this._store.setTaskLock(lock),
|
|
92682
|
+
},
|
|
92683
|
+
});
|
|
92684
|
+
this._mcpTasks.recover();
|
|
92685
|
+
|
|
92357
92686
|
// ask_role hand-offs per Planner run (CRE-011 AC4).
|
|
92358
92687
|
this._handoffs = new HandoffCap();
|
|
92359
92688
|
|
|
@@ -93227,6 +93556,64 @@ const botController$1 = {
|
|
|
93227
93556
|
return this._store.getTeamSettings(workspaceId);
|
|
93228
93557
|
},
|
|
93229
93558
|
|
|
93559
|
+
// ---- Tasks via MCP (TEAM-016) ------------------------------------------
|
|
93560
|
+
|
|
93561
|
+
/** Does this dashboard's team take tasks via MCP? Off unless turned on. */
|
|
93562
|
+
takesMcpTasks(workspaceId) {
|
|
93563
|
+
return this._store.getTeamSettings(workspaceId).takesMcpTasks === true;
|
|
93564
|
+
},
|
|
93565
|
+
|
|
93566
|
+
setTakesMcpTasks(workspaceId, on) {
|
|
93567
|
+
return this._store.setTeamSettings(workspaceId, {
|
|
93568
|
+
takesMcpTasks: !!on,
|
|
93569
|
+
});
|
|
93570
|
+
},
|
|
93571
|
+
|
|
93572
|
+
/** The task store (mcpTasks.js), for the MCP tools. */
|
|
93573
|
+
mcpTasks() {
|
|
93574
|
+
return this._mcpTasks;
|
|
93575
|
+
},
|
|
93576
|
+
|
|
93577
|
+
/** Recent tasks via MCP, newest first — all, or one team's. */
|
|
93578
|
+
listMcpTasks({ teamId = null, limit = 20 } = {}) {
|
|
93579
|
+
return this._mcpTasks.list({ teamId, limit });
|
|
93580
|
+
},
|
|
93581
|
+
|
|
93582
|
+
/** Settings › MCP Server: is a passphrase set, and is it short? Never the phrase. */
|
|
93583
|
+
getTaskPassphraseState() {
|
|
93584
|
+
const phrase = this._store.getTaskPassphrase();
|
|
93585
|
+
return {
|
|
93586
|
+
set: !!phrase,
|
|
93587
|
+
short: phrase ? !!checkPassphrase(phrase).short : false,
|
|
93588
|
+
lockedUntil: this._mcpTasks.lockedUntil(),
|
|
93589
|
+
};
|
|
93590
|
+
},
|
|
93591
|
+
|
|
93592
|
+
/** Its Show button. */
|
|
93593
|
+
revealTaskPassphrase() {
|
|
93594
|
+
return this._store.getTaskPassphrase();
|
|
93595
|
+
},
|
|
93596
|
+
|
|
93597
|
+
/** Set it: { ok, short } or { ok: false, error }. */
|
|
93598
|
+
setTaskPassphrase(text) {
|
|
93599
|
+
const check = checkPassphrase(text);
|
|
93600
|
+
if (!check.ok) return check;
|
|
93601
|
+
this._store.setTaskPassphrase(String(text).trim());
|
|
93602
|
+
this._mcpTasks.unlock();
|
|
93603
|
+
return check;
|
|
93604
|
+
},
|
|
93605
|
+
|
|
93606
|
+
removeTaskPassphrase() {
|
|
93607
|
+
this._store.setTaskPassphrase(null);
|
|
93608
|
+
return { ok: true };
|
|
93609
|
+
},
|
|
93610
|
+
|
|
93611
|
+
/** "Unlock now" after 5 wrong passphrases. */
|
|
93612
|
+
unlockMcpTasks() {
|
|
93613
|
+
this._mcpTasks.unlock();
|
|
93614
|
+
return { ok: true };
|
|
93615
|
+
},
|
|
93616
|
+
|
|
93230
93617
|
/** Hide the lead's one-time introduction card on that dashboard. */
|
|
93231
93618
|
dismissLeadIntro(workspaceId) {
|
|
93232
93619
|
return this._store.setTeamSettings(workspaceId, { introDismissed: true });
|
|
@@ -93293,6 +93680,10 @@ const botController$1 = {
|
|
|
93293
93680
|
return {
|
|
93294
93681
|
paused: this._pause.isPaused(botId),
|
|
93295
93682
|
overBudget: this._budgets.isOverBudget(botId, (bot || {}).workspaceId),
|
|
93683
|
+
// Why a task's lead wouldn't start at all (TEAM-016): checked before
|
|
93684
|
+
// the user is asked for their passphrase.
|
|
93685
|
+
allPaused: this._pause.isGloballyPaused(),
|
|
93686
|
+
otherProfile: !this._inActiveProfile(bot),
|
|
93296
93687
|
};
|
|
93297
93688
|
},
|
|
93298
93689
|
|
|
@@ -113269,6 +113660,12 @@ var handoff = { extractHandoff: extractHandoff$1, withoutHandoff: withoutHandoff
|
|
|
113269
113660
|
* ask_team_lead — run a dashboard's lead with a question and return its
|
|
113270
113661
|
* answer, labelled with the team. Recorded on the lead's
|
|
113271
113662
|
* run as via "mcp" ("Asked through Dash's MCP server").
|
|
113663
|
+
* give_task, confirm_task, get_task_status, list_tasks
|
|
113664
|
+
* — give a team a task to do (TEAM-016). It starts only
|
|
113665
|
+
* once the user's task passphrase checks out
|
|
113666
|
+
* (bots/mcpTasks.js), and only on a team the user let
|
|
113667
|
+
* take tasks. The lead's run is via "mcp-task[:<from>]",
|
|
113668
|
+
* which may run its bots — an ask (via "mcp") can't.
|
|
113272
113669
|
*
|
|
113273
113670
|
* A paused or over-budget lead returns that status instead of an answer; a
|
|
113274
113671
|
* question that fans out to many teams is capped (5 leads per 2 minutes).
|
|
@@ -113283,6 +113680,8 @@ const {
|
|
|
113283
113680
|
const { extractHandoff, withoutHandoff } = handoff;
|
|
113284
113681
|
|
|
113285
113682
|
const CAP_LIMIT = 5;
|
|
113683
|
+
// How long confirm_task waits for the team before saying it's still going.
|
|
113684
|
+
const TASK_WAIT_MS = 45 * 1000;
|
|
113286
113685
|
|
|
113287
113686
|
const TEAM_TOOLS = [
|
|
113288
113687
|
{
|
|
@@ -113309,8 +113708,115 @@ const TEAM_TOOLS = [
|
|
|
113309
113708
|
required: ["dashboard", "question"],
|
|
113310
113709
|
},
|
|
113311
113710
|
},
|
|
113711
|
+
{
|
|
113712
|
+
name: "give_task",
|
|
113713
|
+
description:
|
|
113714
|
+
"Give one of the user's teams a task to do (not a question — use ask_team_lead for those). The team starts only after the user's task passphrase checks out: if the user said it along with the task, pass it as 'passphrase'; otherwise give_task returns a taskId — ask the user for their task passphrase and call confirm_task. Never guess or reuse a passphrase the user didn't just say. 'team' is a dashboard name or id from list_teams (only teams with takesTasks).",
|
|
113715
|
+
inputSchema: {
|
|
113716
|
+
type: "object",
|
|
113717
|
+
properties: {
|
|
113718
|
+
task: {
|
|
113719
|
+
type: "string",
|
|
113720
|
+
description: "What the user wants done, in their words.",
|
|
113721
|
+
},
|
|
113722
|
+
team: {
|
|
113723
|
+
type: "string",
|
|
113724
|
+
description: "The team's dashboard name or id (from list_teams).",
|
|
113725
|
+
},
|
|
113726
|
+
passphrase: {
|
|
113727
|
+
type: "string",
|
|
113728
|
+
description:
|
|
113729
|
+
"The user's task passphrase, only if they said it with this task.",
|
|
113730
|
+
},
|
|
113731
|
+
from: {
|
|
113732
|
+
type: "string",
|
|
113733
|
+
description:
|
|
113734
|
+
"Your app's short name (e.g. 'ha-bridge'), shown next to the task in Dash.",
|
|
113735
|
+
},
|
|
113736
|
+
},
|
|
113737
|
+
required: ["task"],
|
|
113738
|
+
},
|
|
113739
|
+
},
|
|
113740
|
+
{
|
|
113741
|
+
name: "confirm_task",
|
|
113742
|
+
description:
|
|
113743
|
+
"Start a task from give_task with the passphrase the user just said. Returns the team's answer if it finishes within about a minute; otherwise it's still running — check with get_task_status.",
|
|
113744
|
+
inputSchema: {
|
|
113745
|
+
type: "object",
|
|
113746
|
+
properties: {
|
|
113747
|
+
taskId: { type: "string", description: "From give_task." },
|
|
113748
|
+
passphrase: {
|
|
113749
|
+
type: "string",
|
|
113750
|
+
description: "The user's task passphrase, as they said it.",
|
|
113751
|
+
},
|
|
113752
|
+
},
|
|
113753
|
+
required: ["taskId", "passphrase"],
|
|
113754
|
+
},
|
|
113755
|
+
},
|
|
113756
|
+
{
|
|
113757
|
+
name: "get_task_status",
|
|
113758
|
+
description:
|
|
113759
|
+
"How a task from give_task is going: waiting for the passphrase, running, done (with the team's summary), failed (with why), or expired.",
|
|
113760
|
+
inputSchema: {
|
|
113761
|
+
type: "object",
|
|
113762
|
+
properties: {
|
|
113763
|
+
taskId: { type: "string", description: "From give_task." },
|
|
113764
|
+
},
|
|
113765
|
+
required: ["taskId"],
|
|
113766
|
+
},
|
|
113767
|
+
},
|
|
113768
|
+
{
|
|
113769
|
+
name: "list_tasks",
|
|
113770
|
+
description:
|
|
113771
|
+
"The most recent tasks given to teams via MCP, newest first, with their status.",
|
|
113772
|
+
inputSchema: { type: "object", properties: {}, required: [] },
|
|
113773
|
+
},
|
|
113312
113774
|
];
|
|
113313
113775
|
|
|
113776
|
+
const json = (body, isError = false) => ({
|
|
113777
|
+
content: [{ type: "text", text: JSON.stringify(body) }],
|
|
113778
|
+
...(isError ? { isError: true } : {}),
|
|
113779
|
+
});
|
|
113780
|
+
|
|
113781
|
+
const timeOf = (iso) => {
|
|
113782
|
+
try {
|
|
113783
|
+
return new Date(iso).toLocaleTimeString([], {
|
|
113784
|
+
hour: "numeric",
|
|
113785
|
+
minute: "2-digit",
|
|
113786
|
+
});
|
|
113787
|
+
} catch (_e) {
|
|
113788
|
+
return iso;
|
|
113789
|
+
}
|
|
113790
|
+
};
|
|
113791
|
+
|
|
113792
|
+
/** A task as the agent sees it — no internal ids. */
|
|
113793
|
+
const taskView = (t) => ({
|
|
113794
|
+
taskId: t.id,
|
|
113795
|
+
task: t.task,
|
|
113796
|
+
team: t.teamName,
|
|
113797
|
+
status: t.status,
|
|
113798
|
+
createdAt: t.createdAt,
|
|
113799
|
+
...(t.status === "waiting" ? { expiresAt: t.expiresAt } : {}),
|
|
113800
|
+
...(t.summary ? { summary: t.summary } : {}),
|
|
113801
|
+
...(t.error ? { error: t.error } : {}),
|
|
113802
|
+
...(t.endedAt ? { endedAt: t.endedAt } : {}),
|
|
113803
|
+
});
|
|
113804
|
+
|
|
113805
|
+
const STATUS_MESSAGE = {
|
|
113806
|
+
waiting: (t) =>
|
|
113807
|
+
`Waiting for the user's task passphrase (expires at ${timeOf(t.expiresAt)}). Ask them for it and call confirm_task.`,
|
|
113808
|
+
running: (t) => `${t.teamName} is working on it.`,
|
|
113809
|
+
done: (t) => `${t.teamName} finished: ${t.summary || "(no summary)"}`,
|
|
113810
|
+
failed: (t) => `${t.teamName} couldn't do it: ${t.error}`,
|
|
113811
|
+
expired: () =>
|
|
113812
|
+
"It expired before the passphrase was given. Give the task again if the user still wants it.",
|
|
113813
|
+
};
|
|
113814
|
+
|
|
113815
|
+
/** What the lead is asked: the task, and that the user stands behind it. */
|
|
113816
|
+
function taskPrompt(t) {
|
|
113817
|
+
return `${t.task}\n\n(A task given via MCP${t.from ? ` by ${t.from}` : ""}; the user confirmed it with their task passphrase. Do it with your team's bots, then sum up in a few sentences what was done and anything still waiting on the user.)`;
|
|
113818
|
+
}
|
|
113819
|
+
|
|
113314
113820
|
const reply = (text, isError = false) => ({
|
|
113315
113821
|
content: [{ type: "text", text }],
|
|
113316
113822
|
...(isError ? { isError: true } : {}),
|
|
@@ -113332,6 +113838,7 @@ function makeTeamToolHandlers({
|
|
|
113332
113838
|
getWorkspaces,
|
|
113333
113839
|
bots,
|
|
113334
113840
|
cap = new AskCap({ limit: CAP_LIMIT }),
|
|
113841
|
+
taskWaitMs = TASK_WAIT_MS,
|
|
113335
113842
|
}) {
|
|
113336
113843
|
const lastRunAt = (botId) => {
|
|
113337
113844
|
try {
|
|
@@ -113343,13 +113850,247 @@ function makeTeamToolHandlers({
|
|
|
113343
113850
|
}
|
|
113344
113851
|
};
|
|
113345
113852
|
|
|
113853
|
+
const takesTasks = (id) => {
|
|
113854
|
+
try {
|
|
113855
|
+
return !!(bots.takesMcpTasks && bots.takesMcpTasks(id));
|
|
113856
|
+
} catch (_e) {
|
|
113857
|
+
return false;
|
|
113858
|
+
}
|
|
113859
|
+
};
|
|
113860
|
+
|
|
113861
|
+
// A task's run, from the passphrase on: the lead does it with its bots
|
|
113862
|
+
// (allowed — the user confirmed it), and the task follows the run.
|
|
113863
|
+
const startTask = (task) => {
|
|
113864
|
+
const tasks = bots.tasks();
|
|
113865
|
+
tasks.running(task.id);
|
|
113866
|
+
const via = `mcp-task${task.from ? `:${task.from}` : ""}`;
|
|
113867
|
+
return Promise.resolve()
|
|
113868
|
+
.then(() => bots.askLead(task.leadId, taskPrompt(task), { via }))
|
|
113869
|
+
.then((result) => {
|
|
113870
|
+
if (result && result.skipped) {
|
|
113871
|
+
return tasks.failed(
|
|
113872
|
+
task.id,
|
|
113873
|
+
result.reason && result.reason !== "a run is already in progress"
|
|
113874
|
+
? `The team lead didn't start: ${result.reason}.`
|
|
113875
|
+
: "The team lead was busy with something else. Give the task again in a moment.",
|
|
113876
|
+
);
|
|
113877
|
+
}
|
|
113878
|
+
// Only a finished run is done: one stopped in Dash, or cut off when
|
|
113879
|
+
// Dash closed, has at most part of an answer.
|
|
113880
|
+
if (result && result.status === "stopped") {
|
|
113881
|
+
return tasks.failed(task.id, "It was stopped in Dash.");
|
|
113882
|
+
}
|
|
113883
|
+
if (result && result.status === "interrupted") {
|
|
113884
|
+
return tasks.failed(task.id, "Dash closed before the team finished.");
|
|
113885
|
+
}
|
|
113886
|
+
if (!result || result.status !== "completed" || result.error) {
|
|
113887
|
+
return tasks.failed(
|
|
113888
|
+
task.id,
|
|
113889
|
+
(result && result.error) || "unknown error",
|
|
113890
|
+
);
|
|
113891
|
+
}
|
|
113892
|
+
return tasks.done(task.id, {
|
|
113893
|
+
summary: withoutHandoff(result.output) || "",
|
|
113894
|
+
runAt: result.startedAt || null,
|
|
113895
|
+
});
|
|
113896
|
+
})
|
|
113897
|
+
.catch((err) =>
|
|
113898
|
+
tasks.failed(task.id, (err && err.message) || String(err)),
|
|
113899
|
+
);
|
|
113900
|
+
};
|
|
113901
|
+
|
|
113902
|
+
/** Passphrase checks out → start; otherwise say what to do next. */
|
|
113903
|
+
const confirm = async (task, passphrase) => {
|
|
113904
|
+
const tasks = bots.tasks();
|
|
113905
|
+
const check = tasks.verify(passphrase);
|
|
113906
|
+
if (check.notSet) {
|
|
113907
|
+
return json({
|
|
113908
|
+
taskId: task.id,
|
|
113909
|
+
status: task.status,
|
|
113910
|
+
message:
|
|
113911
|
+
"The user hasn't set a task passphrase. They can set one in Dash: Settings › MCP Server › Task passphrase.",
|
|
113912
|
+
});
|
|
113913
|
+
}
|
|
113914
|
+
if (check.locked) {
|
|
113915
|
+
const why = check.wrong
|
|
113916
|
+
? "That passphrase isn't right either, and that was 5 wrong ones"
|
|
113917
|
+
: "There were 5 wrong passphrases";
|
|
113918
|
+
return json({
|
|
113919
|
+
taskId: task.id,
|
|
113920
|
+
status: task.status,
|
|
113921
|
+
message: `${why}: tasks are locked until ${timeOf(
|
|
113922
|
+
check.locked,
|
|
113923
|
+
)}. The user can unlock them in Dash: Settings › MCP Server.`,
|
|
113924
|
+
});
|
|
113925
|
+
}
|
|
113926
|
+
if (check.wrong) {
|
|
113927
|
+
return json({
|
|
113928
|
+
taskId: task.id,
|
|
113929
|
+
status: task.status,
|
|
113930
|
+
message: `That passphrase isn't right. ${check.triesLeft} ${
|
|
113931
|
+
check.triesLeft === 1 ? "try" : "tries"
|
|
113932
|
+
} left before tasks lock for 15 minutes. Ask the user to say it again.`,
|
|
113933
|
+
});
|
|
113934
|
+
}
|
|
113935
|
+
// Still allowed? The team could have been turned off or paused since.
|
|
113936
|
+
const blocked = teamBlocked(task.teamId, task.leadId, task.teamName);
|
|
113937
|
+
if (blocked) {
|
|
113938
|
+
tasks.failed(task.id, blocked);
|
|
113939
|
+
return json({ taskId: task.id, status: "failed", message: blocked });
|
|
113940
|
+
}
|
|
113941
|
+
const finished = startTask(task);
|
|
113942
|
+
let timer;
|
|
113943
|
+
const wait = new Promise((resolve) => {
|
|
113944
|
+
timer = setTimeout(() => resolve(null), taskWaitMs);
|
|
113945
|
+
});
|
|
113946
|
+
let done;
|
|
113947
|
+
try {
|
|
113948
|
+
done = await Promise.race([finished, wait]);
|
|
113949
|
+
} finally {
|
|
113950
|
+
clearTimeout(timer);
|
|
113951
|
+
}
|
|
113952
|
+
const now = done || tasks.get(task.id) || task;
|
|
113953
|
+
return json({
|
|
113954
|
+
...taskView(now),
|
|
113955
|
+
message: done
|
|
113956
|
+
? STATUS_MESSAGE[now.status](now)
|
|
113957
|
+
: `${task.teamName} has started. It's still working — check with get_task_status(taskId).`,
|
|
113958
|
+
});
|
|
113959
|
+
};
|
|
113960
|
+
|
|
113961
|
+
// Why this team can't take a task now, or null.
|
|
113962
|
+
const teamBlocked = (teamId, leadId, name) => {
|
|
113963
|
+
if (!takesTasks(teamId)) {
|
|
113964
|
+
return `${name} doesn't take tasks via MCP. The user can turn on "Takes tasks via MCP" in that dashboard's Bots view.`;
|
|
113965
|
+
}
|
|
113966
|
+
const lead = bots.list().find((b) => b.id === leadId);
|
|
113967
|
+
if (!lead) {
|
|
113968
|
+
return `${name} has no team lead. The user can turn one on in that dashboard's Bots view.`;
|
|
113969
|
+
}
|
|
113970
|
+
const avail = bots.leadAvailability(leadId) || {};
|
|
113971
|
+
if (avail.otherProfile) {
|
|
113972
|
+
return `${name} isn't in the profile Dash has open. The user can switch profiles in Dash.`;
|
|
113973
|
+
}
|
|
113974
|
+
if (avail.allPaused) {
|
|
113975
|
+
return "All bots are paused in Dash. The user can resume them there.";
|
|
113976
|
+
}
|
|
113977
|
+
if (avail.paused) {
|
|
113978
|
+
return `${name}'s team is paused. The user can resume it in the dashboard's Bots view.`;
|
|
113979
|
+
}
|
|
113980
|
+
if (avail.overBudget) {
|
|
113981
|
+
return `${name}'s team is over its budget. The user can raise it in Settings › Bots.`;
|
|
113982
|
+
}
|
|
113983
|
+
return null;
|
|
113984
|
+
};
|
|
113985
|
+
|
|
113346
113986
|
return {
|
|
113987
|
+
async give_task(args = {}) {
|
|
113988
|
+
const text = String((args && args.task) || "").trim();
|
|
113989
|
+
if (!text) return json({ message: "give_task needs a 'task'." }, true);
|
|
113990
|
+
const tasks = bots.tasks();
|
|
113991
|
+
const locked = tasks.lockedUntil();
|
|
113992
|
+
if (locked) {
|
|
113993
|
+
return json({
|
|
113994
|
+
status: "locked",
|
|
113995
|
+
message: `Tasks are locked after 5 wrong passphrases until ${timeOf(
|
|
113996
|
+
locked,
|
|
113997
|
+
)}. The user can unlock them in Dash: Settings › MCP Server.`,
|
|
113998
|
+
});
|
|
113999
|
+
}
|
|
114000
|
+
const workspaces = getWorkspaces();
|
|
114001
|
+
const teams = summarizeTeams({
|
|
114002
|
+
workspaces,
|
|
114003
|
+
bots: bots.list(),
|
|
114004
|
+
lastRunAt: () => null,
|
|
114005
|
+
}).filter((t) => takesTasks(t.id));
|
|
114006
|
+
const names = teams.map((t) => `${t.name} (id ${t.id})`).join(", ");
|
|
114007
|
+
if (!args.team) {
|
|
114008
|
+
return json({
|
|
114009
|
+
status: "needs-team",
|
|
114010
|
+
message: teams.length
|
|
114011
|
+
? `Which team? Teams that take tasks: ${names}. Call give_task again with 'team'.`
|
|
114012
|
+
: `No team takes tasks via MCP yet. The user can turn on "Takes tasks via MCP" in a dashboard's Bots view.`,
|
|
114013
|
+
});
|
|
114014
|
+
}
|
|
114015
|
+
const found = resolveDashboard(
|
|
114016
|
+
workspaces.filter((w) => teams.some((t) => sameId(t.id, w.id))),
|
|
114017
|
+
args.team,
|
|
114018
|
+
);
|
|
114019
|
+
if (found.none) {
|
|
114020
|
+
return json({
|
|
114021
|
+
status: "needs-team",
|
|
114022
|
+
message: `No team that takes tasks matches "${args.team}". ${
|
|
114023
|
+
teams.length
|
|
114024
|
+
? `Teams that take tasks: ${names}.`
|
|
114025
|
+
: `No team takes tasks via MCP yet. The user can turn on "Takes tasks via MCP" in a dashboard's Bots view.`
|
|
114026
|
+
}`,
|
|
114027
|
+
});
|
|
114028
|
+
}
|
|
114029
|
+
if (found.ambiguous) {
|
|
114030
|
+
return json({
|
|
114031
|
+
status: "needs-team",
|
|
114032
|
+
message: `Several teams match "${args.team}": ${found.ambiguous
|
|
114033
|
+
.map((w) => `${w.name} (id ${w.id})`)
|
|
114034
|
+
.join(", ")}. Ask the user which one, then call again with its id.`,
|
|
114035
|
+
});
|
|
114036
|
+
}
|
|
114037
|
+
const ws = found.match;
|
|
114038
|
+
const name = ws.name || "Untitled";
|
|
114039
|
+
const lead = bots
|
|
114040
|
+
.list()
|
|
114041
|
+
.find((b) => b.role === "lead" && sameId(b.workspaceId, ws.id));
|
|
114042
|
+
const blocked = teamBlocked(ws.id, lead && lead.id, name);
|
|
114043
|
+
if (blocked) return json({ status: "blocked", message: blocked });
|
|
114044
|
+
|
|
114045
|
+
const task = tasks.create({
|
|
114046
|
+
task: text,
|
|
114047
|
+
team: { id: ws.id, name, leadId: lead.id },
|
|
114048
|
+
from: args.from,
|
|
114049
|
+
});
|
|
114050
|
+
if (args.passphrase) return confirm(task, args.passphrase);
|
|
114051
|
+
return json({
|
|
114052
|
+
...taskView(task),
|
|
114053
|
+
message: `${name} will do: "${text}". Ask the user for their task passphrase, then call confirm_task(taskId, passphrase). It expires at ${timeOf(
|
|
114054
|
+
task.expiresAt,
|
|
114055
|
+
)}.`,
|
|
114056
|
+
});
|
|
114057
|
+
},
|
|
114058
|
+
|
|
114059
|
+
async confirm_task(args = {}) {
|
|
114060
|
+
const task = bots.tasks().get(String((args && args.taskId) || ""));
|
|
114061
|
+
if (!task) {
|
|
114062
|
+
return json({ message: "No task with that taskId." }, true);
|
|
114063
|
+
}
|
|
114064
|
+
if (task.status !== "waiting") {
|
|
114065
|
+
return json({
|
|
114066
|
+
...taskView(task),
|
|
114067
|
+
message: STATUS_MESSAGE[task.status](task),
|
|
114068
|
+
});
|
|
114069
|
+
}
|
|
114070
|
+
return confirm(task, args.passphrase);
|
|
114071
|
+
},
|
|
114072
|
+
|
|
114073
|
+
async get_task_status(args = {}) {
|
|
114074
|
+
const task = bots.tasks().get(String((args && args.taskId) || ""));
|
|
114075
|
+
if (!task) {
|
|
114076
|
+
return json({ message: "No task with that taskId." }, true);
|
|
114077
|
+
}
|
|
114078
|
+
return json({
|
|
114079
|
+
...taskView(task),
|
|
114080
|
+
message: STATUS_MESSAGE[task.status](task),
|
|
114081
|
+
});
|
|
114082
|
+
},
|
|
114083
|
+
|
|
114084
|
+
async list_tasks() {
|
|
114085
|
+
return json({ tasks: bots.tasks().list({ limit: 10 }).map(taskView) });
|
|
114086
|
+
},
|
|
114087
|
+
|
|
113347
114088
|
async list_teams() {
|
|
113348
114089
|
const teams = summarizeTeams({
|
|
113349
114090
|
workspaces: getWorkspaces(),
|
|
113350
114091
|
bots: bots.list(),
|
|
113351
114092
|
lastRunAt,
|
|
113352
|
-
});
|
|
114093
|
+
}).map((t) => ({ ...t, takesTasks: takesTasks(t.id) }));
|
|
113353
114094
|
return reply(
|
|
113354
114095
|
JSON.stringify({
|
|
113355
114096
|
teams,
|
|
@@ -113469,6 +114210,8 @@ function registerTeamTools$1() {
|
|
|
113469
114210
|
getRuns: (id, opts) => botController.getRuns(id, opts),
|
|
113470
114211
|
leadAvailability: (id) => botController.leadAvailability(id),
|
|
113471
114212
|
askLead: (id, q, opts) => botController.askLead(id, q, opts),
|
|
114213
|
+
takesMcpTasks: (id) => botController.takesMcpTasks(id),
|
|
114214
|
+
tasks: () => botController.mcpTasks(),
|
|
113472
114215
|
},
|
|
113473
114216
|
});
|
|
113474
114217
|
|