@markus-global/cli 0.9.0 → 0.9.2
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/commands/start.js +25 -0
- package/dist/commands/start.js.map +1 -1
- package/dist/markus.mjs +211 -24
- package/dist/web-ui/assets/{CommentInput-Ccv0KCzc.js → CommentInput-D3jx82c7.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-BbN7QT3E.js → ContentRenderer-CQ9uMng0.js} +2 -2
- package/dist/web-ui/assets/{Deliverables-Dzfujlqv.js → Deliverables-DKy2_HPY.js} +1 -1
- package/dist/web-ui/assets/Notifications-1YKMlJ91.js +1 -0
- package/dist/web-ui/assets/{Search-Va12fH-V.js → Search-D5P2V5tM.js} +1 -1
- package/dist/web-ui/assets/{Settings-D_0MEUGb.js → Settings-C86a_mG8.js} +6 -6
- package/dist/web-ui/assets/{Store-dRlOlppM.js → Store-Ca8mvyTT.js} +1 -1
- package/dist/web-ui/assets/Team-DHmWU23x.js +40 -0
- package/dist/web-ui/assets/{Work-C6pfFbRU.js → Work-zJLJ6A3I.js} +5 -5
- package/dist/web-ui/assets/{arc-w52qYN0j.js → arc-s5quZ9MF.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-Dq5t04Vy.js → architectureDiagram-3BPJPVTR-iZhZ9wDV.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-dMSQ7RYP.js → blockDiagram-GPEHLZMM-lYMBEpQb.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-yG4K-xPW.js → c4Diagram-AAUBKEIU-C8vbScKq.js} +1 -1
- package/dist/web-ui/assets/channel-D2RoSw08.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-BMCCyFP7.js → chunk-2J33WTMH-DhvC5Teh.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-DrZE__0f.js → chunk-4BX2VUAB-Do4f1QNX.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-BHAPJ9Eo.js → chunk-55IACEB6-BCDgVda5.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-Ctfjl9vK.js → chunk-727SXJPM-n9W-gHJL.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-SVZPGzSA.js → chunk-AQP2D5EJ-joCNa2WM.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-DeTpOrnv.js → chunk-FMBD7UC4-Cp9QtfEA.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-CudW1r3G.js → chunk-ND2GUHAM-Dt_ZkR0s.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-CJSQIoVy.js → chunk-QZHKN3VN-CVGCkc4k.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-DGebyJZN.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-DGebyJZN.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-CcCOSPt7.js → cose-bilkent-S5V4N54A-B4Q2AELl.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-F3l9565T.js → dagre-BM42HDAG-DoazhTnM.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-B5Ep5hBX.js → diagram-2AECGRRQ-C7KY67Fn.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-Ba-Xi40Z.js → diagram-5GNKFQAL-dPjx6DBc.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-nq3nvV52.js → diagram-KO2AKTUF-D4BEU7N2.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-BLQG5suI.js → diagram-LMA3HP47-D9PLmyge.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-BZwEfL_A.js → diagram-OG6HWLK6-Dg6SRSYN.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-x0d6Urzc.js → erDiagram-TEJ5UH35-D97ueERw.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-Bps4iInm.js → flowDiagram-I6XJVG4X-Cm-sRIL_.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-BQhqabZG.js → ganttDiagram-6RSMTGT7-CXq6jqCz.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-CZsFUtiG.js → gitGraphDiagram-PVQCEYII-CJ50_J0p.js} +1 -1
- package/dist/web-ui/assets/{index-BVZKeNvh.js → index-CHkb08MZ.js} +55 -55
- package/dist/web-ui/assets/index-CPULIfuW.css +1 -0
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-bUkRpixn.js → infoDiagram-5YYISTIA-CbTpYpwF.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-C71uSHjN.js → ishikawaDiagram-YF4QCWOH-CUt9Btxt.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-CH4cq7H3.js → journeyDiagram-JHISSGLW-F9zmJizG.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-B1plHCmn.js → kanban-definition-UN3LZRKU-jNs9ezLz.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-BtKFJxef.js → mermaid.core-Cxm0p7KD.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-BRinAMnx.js → mindmap-definition-RKZ34NQL-BuW2AA71.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-B8r7cm8D.js → pieDiagram-4H26LBE5-BKrViKGj.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-BlYE_3Bv.js → quadrantDiagram-W4KKPZXB-Hh0Kzhcb.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-XHqns5Oh.js → requirementDiagram-4Y6WPE33-B1ga-7j9.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP--WceN9u7.js → sankeyDiagram-5OEKKPKP-2uQ075vI.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-NXQDJA2d.js → sequenceDiagram-3UESZ5HK-97k-cDlv.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-Cs8Vl8wX.js → stateDiagram-AJRCARHV-PTiMHe-8.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-CNP7uL0K.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-V9TBhcGA.js → timeline-definition-PNZ67QCA-Gji5tIlk.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-BkrjAkwE.js → vennDiagram-CIIHVFJN-B91fyhQC.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-DnYl7xFk.js → wardley-L42UT6IY-C9MIuW9C.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-Bgjk8gUy.js → wardleyDiagram-YWT4CUSO-CtXjrE4d.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-DVv-I1Er.js → xychartDiagram-2RQKCTM6-BgVdUlxT.js} +1 -1
- package/dist/web-ui/index.html +2 -2
- package/package.json +1 -1
- package/dist/web-ui/assets/Notifications-DMI9cmK5.js +0 -1
- package/dist/web-ui/assets/Team-D8m98W3b.js +0 -40
- package/dist/web-ui/assets/channel-0x_SxlyN.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-D4o-x8Tr.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-D4o-x8Tr.js +0 -1
- package/dist/web-ui/assets/index-BDWvYwl1.css +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-Cmof_fUq.js +0 -1
package/dist/markus.mjs
CHANGED
|
@@ -56510,6 +56510,7 @@ var init_browser_session = __esm({
|
|
|
56510
56510
|
remindedKeys = /* @__PURE__ */ new Set();
|
|
56511
56511
|
_bringToFront = false;
|
|
56512
56512
|
_autoCloseTabs = true;
|
|
56513
|
+
ownershipListeners = /* @__PURE__ */ new Set();
|
|
56513
56514
|
get bringToFront() {
|
|
56514
56515
|
return this._bringToFront;
|
|
56515
56516
|
}
|
|
@@ -56522,6 +56523,68 @@ var init_browser_session = __esm({
|
|
|
56522
56523
|
set autoCloseTabs(v) {
|
|
56523
56524
|
this._autoCloseTabs = v;
|
|
56524
56525
|
}
|
|
56526
|
+
/** Subscribe to tab claim/release events (UI badge wiring). */
|
|
56527
|
+
onOwnershipChange(listener) {
|
|
56528
|
+
this.ownershipListeners.add(listener);
|
|
56529
|
+
return () => {
|
|
56530
|
+
this.ownershipListeners.delete(listener);
|
|
56531
|
+
};
|
|
56532
|
+
}
|
|
56533
|
+
/** Snapshot of currently owned tabs for UI hydration. */
|
|
56534
|
+
listOwnership() {
|
|
56535
|
+
const out = [];
|
|
56536
|
+
for (const [ownerKey, owned] of this.ownedPages) {
|
|
56537
|
+
const agentId2 = this.agentIdFromOwnerKey(ownerKey);
|
|
56538
|
+
for (const pageId of owned) {
|
|
56539
|
+
out.push({ pageId, agentId: agentId2, ownerKey });
|
|
56540
|
+
}
|
|
56541
|
+
}
|
|
56542
|
+
return out;
|
|
56543
|
+
}
|
|
56544
|
+
agentIdFromOwnerKey(ownerKey) {
|
|
56545
|
+
const idx = ownerKey.indexOf("::");
|
|
56546
|
+
return idx === -1 ? ownerKey : ownerKey.slice(0, idx);
|
|
56547
|
+
}
|
|
56548
|
+
emitOwnership(event) {
|
|
56549
|
+
for (const listener of this.ownershipListeners) {
|
|
56550
|
+
try {
|
|
56551
|
+
listener(event);
|
|
56552
|
+
} catch (err) {
|
|
56553
|
+
log21.warn("Ownership listener error", { error: String(err) });
|
|
56554
|
+
}
|
|
56555
|
+
}
|
|
56556
|
+
}
|
|
56557
|
+
/** Claim a page for an owner key; emits `claimed` when newly assigned. */
|
|
56558
|
+
assignPage(ownerKey, pageId) {
|
|
56559
|
+
const owned = this.getOwned(ownerKey);
|
|
56560
|
+
if (owned.has(pageId))
|
|
56561
|
+
return;
|
|
56562
|
+
const other = this.findOwnerOfPage(pageId);
|
|
56563
|
+
if (other && other !== ownerKey) {
|
|
56564
|
+
this.releasePage(other, pageId);
|
|
56565
|
+
}
|
|
56566
|
+
owned.add(pageId);
|
|
56567
|
+
this.emitOwnership({
|
|
56568
|
+
action: "claimed",
|
|
56569
|
+
pageId,
|
|
56570
|
+
agentId: this.agentIdFromOwnerKey(ownerKey),
|
|
56571
|
+
ownerKey
|
|
56572
|
+
});
|
|
56573
|
+
}
|
|
56574
|
+
/** Release a page from an owner key; emits `released` when removed. */
|
|
56575
|
+
releasePage(ownerKey, pageId) {
|
|
56576
|
+
const owned = this.ownedPages.get(ownerKey);
|
|
56577
|
+
if (!owned?.has(pageId))
|
|
56578
|
+
return false;
|
|
56579
|
+
owned.delete(pageId);
|
|
56580
|
+
this.emitOwnership({
|
|
56581
|
+
action: "released",
|
|
56582
|
+
pageId,
|
|
56583
|
+
agentId: this.agentIdFromOwnerKey(ownerKey),
|
|
56584
|
+
ownerKey
|
|
56585
|
+
});
|
|
56586
|
+
return true;
|
|
56587
|
+
}
|
|
56525
56588
|
/**
|
|
56526
56589
|
* Register a reconnect callback for a specific MCP server of an agent.
|
|
56527
56590
|
* Multiple servers can each have their own reconnector without overwriting.
|
|
@@ -56543,8 +56606,8 @@ var init_browser_session = __esm({
|
|
|
56543
56606
|
handleTabClosed(pageId) {
|
|
56544
56607
|
if (pageId === void 0)
|
|
56545
56608
|
return;
|
|
56546
|
-
for (const
|
|
56547
|
-
if (
|
|
56609
|
+
for (const key2 of [...this.ownedPages.keys()]) {
|
|
56610
|
+
if (this.releasePage(key2, pageId)) {
|
|
56548
56611
|
log21.debug(`Removed closed page ${pageId} from ownership set ${key2}`);
|
|
56549
56612
|
}
|
|
56550
56613
|
}
|
|
@@ -56604,9 +56667,9 @@ var init_browser_session = __esm({
|
|
|
56604
56667
|
const prefix = `${agentId2}::`;
|
|
56605
56668
|
for (const [key2, owned] of this.ownedPages) {
|
|
56606
56669
|
if (key2 === agentId2 || key2.startsWith(prefix)) {
|
|
56607
|
-
for (const pageId of owned) {
|
|
56670
|
+
for (const pageId of [...owned]) {
|
|
56608
56671
|
if (!liveIds.has(pageId)) {
|
|
56609
|
-
|
|
56672
|
+
this.releasePage(key2, pageId);
|
|
56610
56673
|
log21.debug(`Pruned stale page ${pageId} from ${key2}`);
|
|
56611
56674
|
}
|
|
56612
56675
|
}
|
|
@@ -56815,8 +56878,7 @@ var init_browser_session = __esm({
|
|
|
56815
56878
|
const notPrevOwned = pages.filter((p) => !prevIds.has(p.id));
|
|
56816
56879
|
const newPage = notPrevOwned.find((p) => p.selected) ?? (notPrevOwned.length > 0 ? notPrevOwned.reduce((a, b) => a.id > b.id ? a : b) : void 0) ?? pages.find((p) => p.selected) ?? (pages.length > 0 ? pages.reduce((a, b) => a.id > b.id ? a : b) : void 0);
|
|
56817
56880
|
if (newPage) {
|
|
56818
|
-
|
|
56819
|
-
currentOwned.add(newPage.id);
|
|
56881
|
+
this.assignPage(ownerKey, newPage.id);
|
|
56820
56882
|
this.currentPage.set(ownerKey, newPage.id);
|
|
56821
56883
|
this.lastActiveSession.set(agentId2, { ownerKey, pageId: newPage.id });
|
|
56822
56884
|
log21.debug(`Page ${newPage.id} (${newPage.url}) assigned to ${ownerKey}`);
|
|
@@ -56876,7 +56938,7 @@ var init_browser_session = __esm({
|
|
|
56876
56938
|
const ok2 = await this.reconnectMcp(agentId2);
|
|
56877
56939
|
if (ok2) {
|
|
56878
56940
|
if (pageId !== void 0) {
|
|
56879
|
-
this.
|
|
56941
|
+
this.releasePage(ownerKey, pageId);
|
|
56880
56942
|
if (this.currentPage.get(ownerKey) === pageId) {
|
|
56881
56943
|
this.currentPage.delete(ownerKey);
|
|
56882
56944
|
}
|
|
@@ -56885,7 +56947,7 @@ var init_browser_session = __esm({
|
|
|
56885
56947
|
}
|
|
56886
56948
|
}
|
|
56887
56949
|
if (pageId !== void 0 && !this.isToolError(result)) {
|
|
56888
|
-
|
|
56950
|
+
this.assignPage(ownerKey, pageId);
|
|
56889
56951
|
this.currentPage.set(ownerKey, pageId);
|
|
56890
56952
|
this.lastActiveSession.set(agentId2, { ownerKey, pageId });
|
|
56891
56953
|
}
|
|
@@ -56913,7 +56975,7 @@ Claimed shared user tab ${pageId}. You may now operate on it in this session.`;
|
|
|
56913
56975
|
}
|
|
56914
56976
|
return this.withAgentLock(agentId2, async () => {
|
|
56915
56977
|
if (pageId !== void 0) {
|
|
56916
|
-
this.
|
|
56978
|
+
this.releasePage(ownerKey, pageId);
|
|
56917
56979
|
if (this.currentPage.get(ownerKey) === pageId) {
|
|
56918
56980
|
const remaining = this.getOwned(ownerKey);
|
|
56919
56981
|
const next = remaining.size > 0 ? [...remaining][remaining.size - 1] : void 0;
|
|
@@ -57000,11 +57062,10 @@ Claimed shared user tab ${pageId}. You may now operate on it in this session.`;
|
|
|
57000
57062
|
result = await newPageHandler.execute(newPageArgs);
|
|
57001
57063
|
}
|
|
57002
57064
|
if (!this.isStalePageError(result)) {
|
|
57003
|
-
const owned = this.getOwned(ownerKey);
|
|
57004
57065
|
const pages = this.parsePageEntries(result);
|
|
57005
57066
|
const newPage = pages.length > 0 ? pages.reduce((a, b) => a.id > b.id ? a : b) : void 0;
|
|
57006
57067
|
if (newPage) {
|
|
57007
|
-
|
|
57068
|
+
this.assignPage(ownerKey, newPage.id);
|
|
57008
57069
|
this.currentPage.set(ownerKey, newPage.id);
|
|
57009
57070
|
this.lastActiveSession.set(agentId2, { ownerKey, pageId: newPage.id });
|
|
57010
57071
|
log21.info(`Auto-created page ${newPage.id} (${newPage.url}) for ${ownerKey}`);
|
|
@@ -57046,7 +57107,7 @@ Claimed shared user tab ${pageId}. You may now operate on it in this session.`;
|
|
|
57046
57107
|
const ok2 = await this.reconnectMcp(agentId2);
|
|
57047
57108
|
if (ok2) {
|
|
57048
57109
|
if (currentPageId !== void 0) {
|
|
57049
|
-
this.
|
|
57110
|
+
this.releasePage(ownerKey, currentPageId);
|
|
57050
57111
|
this.currentPage.delete(ownerKey);
|
|
57051
57112
|
}
|
|
57052
57113
|
return `The tab you were operating on was closed externally. ${this.ownedPagesSummary(ownerKey)} Call navigate_page or new_page to create a new tab, then retry.`;
|
|
@@ -57062,9 +57123,12 @@ Claimed shared user tab ${pageId}. You may now operate on it in this session.`;
|
|
|
57062
57123
|
cleanupAgent(agentId2) {
|
|
57063
57124
|
const prefix = `${agentId2}::`;
|
|
57064
57125
|
let total = 0;
|
|
57065
|
-
for (const [key2, owned] of this.ownedPages) {
|
|
57126
|
+
for (const [key2, owned] of [...this.ownedPages]) {
|
|
57066
57127
|
if (key2 === agentId2 || key2.startsWith(prefix)) {
|
|
57067
57128
|
total += owned.size;
|
|
57129
|
+
for (const pageId of [...owned]) {
|
|
57130
|
+
this.releasePage(key2, pageId);
|
|
57131
|
+
}
|
|
57068
57132
|
this.ownedPages.delete(key2);
|
|
57069
57133
|
this.currentPage.delete(key2);
|
|
57070
57134
|
}
|
|
@@ -65909,6 +65973,9 @@ var init_agent_manager = __esm({
|
|
|
65909
65973
|
this.triggerChromeDialogAutoClick(serverName);
|
|
65910
65974
|
});
|
|
65911
65975
|
this.browserSessionManager = new BrowserSessionManager();
|
|
65976
|
+
this.browserSessionManager.onOwnershipChange((event) => {
|
|
65977
|
+
this.eventBus.emit("browser:tab-ownership", event);
|
|
65978
|
+
});
|
|
65912
65979
|
this.browserBridge = new MarkusBrowserBridge();
|
|
65913
65980
|
this.globalSecurityPolicy = options.securityPolicy;
|
|
65914
65981
|
this.globalMcpServers = options.mcpServers;
|
|
@@ -66060,6 +66127,19 @@ Priority: ${delegation.priority}`, envelope.from, { name: envelope.from, role: "
|
|
|
66060
66127
|
getBrowserBridge() {
|
|
66061
66128
|
return this.browserBridge;
|
|
66062
66129
|
}
|
|
66130
|
+
/** Current agent→page ownership for embedded-browser UI badges. */
|
|
66131
|
+
getBrowserTabOwnership() {
|
|
66132
|
+
return this.browserSessionManager.listOwnership().map(({ pageId, agentId: agentId2 }) => {
|
|
66133
|
+
let agentName = agentId2;
|
|
66134
|
+
try {
|
|
66135
|
+
const agent = this.agents.get(agentId2);
|
|
66136
|
+
if (agent)
|
|
66137
|
+
agentName = agent.config.name || agentId2;
|
|
66138
|
+
} catch {
|
|
66139
|
+
}
|
|
66140
|
+
return { pageId, agentId: agentId2, agentName };
|
|
66141
|
+
});
|
|
66142
|
+
}
|
|
66063
66143
|
async runQuickBrowserTest() {
|
|
66064
66144
|
return runQuickBrowserTest(this.browserBridge, this.browserSessionManager);
|
|
66065
66145
|
}
|
|
@@ -73362,6 +73442,8 @@ var init_router2 = __esm({
|
|
|
73362
73442
|
assignments: {}
|
|
73363
73443
|
};
|
|
73364
73444
|
_routingDefaultModel;
|
|
73445
|
+
/** Hub is_default (or first catalog id) from the last Markus catalog refresh. */
|
|
73446
|
+
_markusCatalogPreferredId;
|
|
73365
73447
|
CIRCUIT_OPEN_AFTER = 2;
|
|
73366
73448
|
CIRCUIT_RESET_MS = 5 * 60 * 1e3;
|
|
73367
73449
|
/** Rate-limit (429) failures recover much faster than generic errors */
|
|
@@ -73669,15 +73751,47 @@ var init_router2 = __esm({
|
|
|
73669
73751
|
}
|
|
73670
73752
|
const ids = new Set(defs.map((d) => d.id));
|
|
73671
73753
|
const preferred = models.find((m) => m.is_default)?.id ?? defs[0].id;
|
|
73672
|
-
|
|
73673
|
-
|
|
73674
|
-
|
|
73675
|
-
log54.info("Markus
|
|
73754
|
+
this._markusCatalogPreferredId = preferred;
|
|
73755
|
+
const healed = this.healMarkusRoutingAgainstCatalog(ids, preferred);
|
|
73756
|
+
if (healed) {
|
|
73757
|
+
log54.info("Markus routing healed from Hub catalog", {
|
|
73758
|
+
activeModel: provider.model,
|
|
73759
|
+
routingDefaultModel: this._routingDefaultModel,
|
|
73760
|
+
count: defs.length
|
|
73761
|
+
});
|
|
73676
73762
|
} else {
|
|
73677
73763
|
log54.info("Markus Hub catalog refreshed", { model: provider.model, count: defs.length });
|
|
73678
73764
|
}
|
|
73679
73765
|
return defs.length;
|
|
73680
73766
|
}
|
|
73767
|
+
/**
|
|
73768
|
+
* Drop sticky Markus defaults that are no longer in the Hub catalog
|
|
73769
|
+
* (e.g. CN geo-filter removes anthropic/claude-opus-5 while chip still shows it).
|
|
73770
|
+
* Returns true when active model and/or routingDefaultModel were rewritten.
|
|
73771
|
+
*/
|
|
73772
|
+
healMarkusRoutingAgainstCatalog(ids, preferred) {
|
|
73773
|
+
const provider = this.providers.get("markus");
|
|
73774
|
+
if (!provider)
|
|
73775
|
+
return false;
|
|
73776
|
+
const catalogIds = ids ?? new Set((this.customModelCatalog.get("markus") ?? []).map((d) => d.id));
|
|
73777
|
+
if (catalogIds.size === 0)
|
|
73778
|
+
return false;
|
|
73779
|
+
const fallback = preferred ?? this._markusCatalogPreferredId ?? (this.customModelCatalog.get("markus") ?? [])[0]?.id;
|
|
73780
|
+
if (!fallback)
|
|
73781
|
+
return false;
|
|
73782
|
+
let healed = false;
|
|
73783
|
+
const activeObsolete = isObsoleteMarkusModel(provider.model) || !catalogIds.has(provider.model);
|
|
73784
|
+
if (activeObsolete) {
|
|
73785
|
+
provider.configure({ provider: "markus", model: fallback });
|
|
73786
|
+
healed = true;
|
|
73787
|
+
}
|
|
73788
|
+
const rdm = this._routingDefaultModel;
|
|
73789
|
+
if (rdm && rdm.provider === "markus" && (isObsoleteMarkusModel(rdm.model) || !catalogIds.has(rdm.model))) {
|
|
73790
|
+
this._routingDefaultModel = { provider: "markus", model: fallback };
|
|
73791
|
+
healed = true;
|
|
73792
|
+
}
|
|
73793
|
+
return healed;
|
|
73794
|
+
}
|
|
73681
73795
|
/**
|
|
73682
73796
|
* Overlay live pricing from ModelCatalogService onto a builtin model definition.
|
|
73683
73797
|
* The catalog (from LiteLLM) is refreshed every 24h so prices stay current.
|
|
@@ -91321,7 +91435,7 @@ Action: ${guidance}` : ""
|
|
|
91321
91435
|
this.updateScheduleConfig(task.id, config).catch((err) => log70.error("Failed to persist recalculated scheduleConfig", { taskId: task.id, error: String(err) }));
|
|
91322
91436
|
}
|
|
91323
91437
|
cancelTask(id, cascade, updatedBy, updatedByType) {
|
|
91324
|
-
const task = this.updateTaskStatus(id, "cancelled", updatedBy,
|
|
91438
|
+
const task = this.updateTaskStatus(id, "cancelled", updatedBy, true, false, updatedByType);
|
|
91325
91439
|
if (task.taskType === "scheduled" && task.scheduleConfig && !task.scheduleConfig.paused) {
|
|
91326
91440
|
task.scheduleConfig.paused = true;
|
|
91327
91441
|
this.updateScheduleConfig(id, task.scheduleConfig).catch((err) => log70.warn("Failed to pause schedule on cancel", { taskId: id, error: String(err) }));
|
|
@@ -206195,6 +206309,38 @@ var init_api_server = __esm({
|
|
|
206195
206309
|
return void 0;
|
|
206196
206310
|
}
|
|
206197
206311
|
}
|
|
206312
|
+
/**
|
|
206313
|
+
* Persist healed Markus active model + routingDefaultModel after catalog geo-filter.
|
|
206314
|
+
* No-op when router state already matches disk.
|
|
206315
|
+
*/
|
|
206316
|
+
persistHealedMarkusRouting() {
|
|
206317
|
+
if (!this.llmRouter)
|
|
206318
|
+
return;
|
|
206319
|
+
try {
|
|
206320
|
+
const cfg = loadConfig();
|
|
206321
|
+
const diskMarkus = cfg.llm.providers?.["markus"] ?? {};
|
|
206322
|
+
const active = this.llmRouter.getProvider("markus")?.model;
|
|
206323
|
+
const rdm = this.llmRouter.routingDefaultModel;
|
|
206324
|
+
const diskRdm = cfg.llm.routingDefaultModel;
|
|
206325
|
+
const modelChanged = !!active && active !== diskMarkus.model;
|
|
206326
|
+
const rdmChanged = JSON.stringify(rdm ?? null) !== JSON.stringify(diskRdm ?? null);
|
|
206327
|
+
if (!modelChanged && !rdmChanged)
|
|
206328
|
+
return;
|
|
206329
|
+
const updates = {};
|
|
206330
|
+
if (rdmChanged)
|
|
206331
|
+
updates.routingDefaultModel = rdm ?? null;
|
|
206332
|
+
if (modelChanged) {
|
|
206333
|
+
updates.providers = { markus: { ...diskMarkus, model: active } };
|
|
206334
|
+
}
|
|
206335
|
+
saveConfig({ llm: updates }, this.markusConfigPath);
|
|
206336
|
+
log80.info("Persisted healed Markus routing after catalog filter", {
|
|
206337
|
+
model: active,
|
|
206338
|
+
routingDefaultModel: rdm
|
|
206339
|
+
});
|
|
206340
|
+
} catch (err) {
|
|
206341
|
+
log80.warn("Failed to persist healed Markus routing", { error: String(err) });
|
|
206342
|
+
}
|
|
206343
|
+
}
|
|
206198
206344
|
/** Legacy Worker-era keys look like `markus_<hex>`; OpenRouter keys start with `sk-or-`. */
|
|
206199
206345
|
isLegacyMarkusSubscriptionKey(apiKey) {
|
|
206200
206346
|
if (!apiKey)
|
|
@@ -212009,9 +212155,12 @@ EXPLANATION_END`;
|
|
|
212009
212155
|
});
|
|
212010
212156
|
if (syncRes.ok) {
|
|
212011
212157
|
const sync = await syncRes.json();
|
|
212012
|
-
|
|
212013
|
-
|
|
212014
|
-
|
|
212158
|
+
const remaining = Math.max(0, Number(sync.remainingCu ?? 0));
|
|
212159
|
+
const used = Math.max(0, Number(sync.usedCu ?? 0));
|
|
212160
|
+
const budget = Number(sync.creditsBudgetCu ?? 0) > 0 ? Number(sync.creditsBudgetCu) : used + remaining > 0 ? used + remaining : Number(sync.entitlementCu ?? 0);
|
|
212161
|
+
hubLimit = budget;
|
|
212162
|
+
hubRemaining = remaining;
|
|
212163
|
+
totalCuUsed = used || totalCuUsed || 0;
|
|
212015
212164
|
this.llmRouter?.setMarkusHubRemainingHint(hubRemaining);
|
|
212016
212165
|
}
|
|
212017
212166
|
}
|
|
@@ -212021,8 +212170,9 @@ EXPLANATION_END`;
|
|
|
212021
212170
|
});
|
|
212022
212171
|
if (planRes.ok) {
|
|
212023
212172
|
const plan = await planRes.json();
|
|
212024
|
-
const
|
|
212173
|
+
const face = Number(plan.monthlyQuotaCu ?? 0) + Number(plan.bonusCu ?? 0) + Number(plan.purchasedCu ?? 0);
|
|
212025
212174
|
const consumed = Number(plan.totalConsumedThisPeriod ?? 0);
|
|
212175
|
+
const entitlement = Number(plan.creditsBudgetCu ?? 0) > 0 ? Number(plan.creditsBudgetCu) : face;
|
|
212026
212176
|
hubLimit = entitlement;
|
|
212027
212177
|
hubRemaining = Math.max(0, entitlement - consumed);
|
|
212028
212178
|
totalCuUsed = consumed;
|
|
@@ -212308,6 +212458,7 @@ EXPLANATION_END`;
|
|
|
212308
212458
|
try {
|
|
212309
212459
|
this.ensureMarkusDirectConfig();
|
|
212310
212460
|
const count = await this.llmRouter?.refreshMarkusCatalog() ?? 0;
|
|
212461
|
+
this.persistHealedMarkusRouting();
|
|
212311
212462
|
const settings = this.llmRouter?.getEnhancedSettings();
|
|
212312
212463
|
const models = settings?.providers?.["markus"]?.models ?? [];
|
|
212313
212464
|
this.json(res, 200, {
|
|
@@ -212360,8 +212511,15 @@ EXPLANATION_END`;
|
|
|
212360
212511
|
}
|
|
212361
212512
|
const preview = this.llmRouter.getEnhancedSettings();
|
|
212362
212513
|
const markus = preview.providers?.["markus"];
|
|
212363
|
-
if (markus?.configured
|
|
212364
|
-
|
|
212514
|
+
if (markus?.configured) {
|
|
212515
|
+
const ids = new Set((markus.models ?? []).map((m) => m.id));
|
|
212516
|
+
if (ids.size === 0) {
|
|
212517
|
+
await this.llmRouter.refreshMarkusCatalog();
|
|
212518
|
+
} else {
|
|
212519
|
+
const preferred = markus.model && ids.has(markus.model) ? markus.model : [...ids][0];
|
|
212520
|
+
this.llmRouter.healMarkusRoutingAgainstCatalog(ids, preferred);
|
|
212521
|
+
}
|
|
212522
|
+
this.persistHealedMarkusRouting();
|
|
212365
212523
|
}
|
|
212366
212524
|
} catch {
|
|
212367
212525
|
}
|
|
@@ -215586,6 +215744,11 @@ You can now:
|
|
|
215586
215744
|
});
|
|
215587
215745
|
return;
|
|
215588
215746
|
}
|
|
215747
|
+
if (path === "/api/browser/tab-ownership" && req.method === "GET") {
|
|
215748
|
+
const am = this.orgService.getAgentManager();
|
|
215749
|
+
this.json(res, 200, { ownership: am.getBrowserTabOwnership() });
|
|
215750
|
+
return;
|
|
215751
|
+
}
|
|
215589
215752
|
if (path === "/api/system/storage" && req.method === "GET") {
|
|
215590
215753
|
try {
|
|
215591
215754
|
const dataDir = join34(homedir20(), ".markus");
|
|
@@ -217067,6 +217230,7 @@ You can now:
|
|
|
217067
217230
|
exact("/api/system/resume-all", "POST"),
|
|
217068
217231
|
exact("/api/system/emergency-stop", "POST"),
|
|
217069
217232
|
exact("/api/system/status", "GET"),
|
|
217233
|
+
exact("/api/browser/tab-ownership", "GET"),
|
|
217070
217234
|
exact("/api/system/storage", "GET"),
|
|
217071
217235
|
exact("/api/system/storage/orphans", "GET", "DELETE"),
|
|
217072
217236
|
exact("/api/system/announcements", "GET", "POST"),
|
|
@@ -236130,6 +236294,29 @@ async function startServerCore(config, values, opts) {
|
|
|
236130
236294
|
log102.warn("Failed to persist heartbeat interval change", { agentId: agentId2, error: String(e) });
|
|
236131
236295
|
}
|
|
236132
236296
|
});
|
|
236297
|
+
agentManager.getEventBus().on("browser:tab-ownership", (evt) => {
|
|
236298
|
+
const event = evt;
|
|
236299
|
+
let agentName = event.agentId;
|
|
236300
|
+
try {
|
|
236301
|
+
const agent = agentManager.getAgent(event.agentId);
|
|
236302
|
+
agentName = agent?.config?.name || event.agentId;
|
|
236303
|
+
} catch {
|
|
236304
|
+
}
|
|
236305
|
+
try {
|
|
236306
|
+
ws.broadcast({
|
|
236307
|
+
type: "ui:browser_ownership",
|
|
236308
|
+
payload: {
|
|
236309
|
+
action: event.action,
|
|
236310
|
+
pageId: event.pageId,
|
|
236311
|
+
agentId: event.action === "released" ? null : event.agentId,
|
|
236312
|
+
agentName: event.action === "released" ? null : agentName
|
|
236313
|
+
},
|
|
236314
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
236315
|
+
});
|
|
236316
|
+
} catch (e) {
|
|
236317
|
+
log102.warn("Failed to broadcast browser ownership", { pageId: event.pageId, error: String(e) });
|
|
236318
|
+
}
|
|
236319
|
+
});
|
|
236133
236320
|
agentManager.getEventBus().on("agent:ui-layout", (evt) => {
|
|
236134
236321
|
const event = evt;
|
|
236135
236322
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,u as T,r as a,e as ee}from"./index-BVZKeNvh.js";const te=1920,ne=10*1024*1024,W=5,re=.8;function se(l,u,i){return new Promise((g,f)=>{const y=new Image;y.onload=()=>{let{width:s,height:r}=y;if(s<=u&&r<=u){g(l);return}s>r?(r=Math.round(r*(u/s)),s=u):(s=Math.round(s*(u/r)),r=u);const x=document.createElement("canvas");x.width=s,x.height=r;const b=x.getContext("2d");if(!b){f(new Error("Failed to get canvas context"));return}b.drawImage(y,0,0,s,r),g(x.toDataURL("image/jpeg",i))},y.onerror=()=>f(new Error("Failed to load image")),y.src=l})}function ae({candidates:l,filter:u,anchorRef:i,onSelect:g,selectedIndex:f,onIndexChange:y}){const{t:s}=T("common"),[r,x]=a.useState(null),b=a.useRef(null),w=l.filter(d=>d.name.toLowerCase().includes(u));return a.useEffect(()=>{const d=i.current;if(!d)return;const h=d.getBoundingClientRect();x({top:h.top+window.scrollY-4,left:h.left+window.scrollX+8})},[i,u]),a.useEffect(()=>{if(!b.current||!r)return;if(b.current.getBoundingClientRect().top<8){const h=i.current;if(!h)return;const c=h.getBoundingClientRect();x({top:c.bottom+window.scrollY+4,left:r.left})}},[r,i]),a.useEffect(()=>{f>=w.length&&y(Math.max(0,w.length-1))},[w.length,f,y]),a.useEffect(()=>{if(!b.current)return;b.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[f]),!r||w.length===0?null:ee.createPortal(t.jsxs("div",{ref:b,style:{position:"absolute",top:r.top,left:r.left,transform:"translateY(-100%)"},className:"w-60 bg-surface-overlay border border-border-default rounded-lg shadow-xl z-[9999] max-h-48 overflow-y-auto",children:[t.jsx("div",{className:"px-2.5 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:s("commentInput.mentionHeading")}),w.map((d,h)=>t.jsxs("button",{"data-selected":h===f,onMouseDown:c=>{c.preventDefault(),g(d)},onMouseEnter:()=>y(h),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${h===f?"bg-brand-500/15 text-brand-500":"hover:bg-surface-elevated"}`,children:[t.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${d.type==="human"?"bg-green-500/20 text-green-500":"bg-brand-500/20 text-brand-500"}`,children:d.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-fg-primary font-medium",children:d.name}),t.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:d.subtitle??d.type})]}),d.type==="agent"&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${d.online?"bg-green-400":"bg-gray-500"}`})]},d.id))]}),document.body)}function oe(l){return/^\w+$/.test(l)?`@${l}`:`@[${l}]`}const K=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function ie(l){const u=[];let i;for(K.lastIndex=0;(i=K.exec(l))!==null;)u.push(i[1]??i[2]);return u}function ce(l,u,i){const g=[];let f=0;const y=u.map(r=>r.name).sort((r,x)=>x.length-r.length);let s=0;for(;s<l.length;){const r=l.indexOf("@",s);if(r<0){g.push(t.jsx("span",{children:l.slice(s)},f++));break}if(r>s&&g.push(t.jsx("span",{children:l.slice(s,r)},f++)),l[r+1]==="["){const c=l.indexOf("]",r+2);if(c>r+2){const m=l.slice(r+2,c),j=u.find(k=>k.name.toLowerCase()===m.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&j?"cursor-pointer hover:underline":""}`,onClick:i&&j?k=>i(j,k):void 0,title:j?`${j.name} (${j.role})`:void 0,children:["@",m]},f++)),s=c+1;continue}}const x=l.slice(r+1),b=x.toLowerCase(),w=y.find(c=>b.startsWith(c.toLowerCase()));if(w){const c=u.find(m=>m.name.toLowerCase()===w.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&c?"cursor-pointer hover:underline":""}`,onClick:i&&c?m=>i(c,m):void 0,title:c?`${c.name} (${c.role})`:void 0,children:["@",w]},f++)),s=r+1+w.length;continue}const d=/^([\w\p{L}\p{N}]+)/u,h=x.match(d);if(h){const c=h[1],m=u.find(j=>j.name.toLowerCase()===c.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&m?"cursor-pointer hover:underline":""}`,onClick:i&&m?j=>i(m,j):void 0,title:m?`${m.name} (${m.role})`:void 0,children:["@",c]},f++)),s=r+1+c.length;continue}g.push(t.jsx("span",{children:"@"},f++)),s=r+1}return g.length>0?g:[t.jsx("span",{children:l},0)]}function de({agents:l,humans:u,onSubmit:i,placeholder:g,replyTo:f,onCancelReply:y}){const{t:s}=T("common"),[r,x]=a.useState(""),[b,w]=a.useState(!1),[d,h]=a.useState(null),[c,m]=a.useState(!1),[j,k]=a.useState(""),[C,S]=a.useState([]),[B,I]=a.useState(0),[N,M]=a.useState([]),[z,A]=a.useState(!1),F=a.useRef(null),U=a.useRef(null),L=a.useRef(null),$=a.useMemo(()=>{const e=(u??[]).map(n=>({id:n.id,name:n.name,type:"human",subtitle:n.role}));for(const n of l)e.push({id:n.id,name:n.name,type:"agent",subtitle:n.role,online:n.status==="idle"||n.status==="working"});return e},[l,u]),D=$.filter(e=>e.name.toLowerCase().includes(j)),E=a.useCallback(e=>{const n=Array.from(e).filter(o=>o.type.startsWith("image/"));if(n.length!==0)for(const o of n){if(o.size>ne)continue;const p=new FileReader;p.onload=()=>{const R=p.result;se(R,te,re).then(v=>{M(_=>_.length>=W?_:[..._,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:v,name:o.name}])})},p.readAsDataURL(o)}},[]),X=a.useCallback(e=>{M(n=>n.filter(o=>o.id!==e))},[]),Y=a.useCallback(e=>{const n=e.clipboardData?.files;if(n&&n.length>0){const o=Array.from(n).filter(p=>p.type.startsWith("image/"));o.length>0&&(e.preventDefault(),E(o))}},[E]),q=a.useCallback(e=>{e.preventDefault(),A(!1);const n=e.dataTransfer?.files;n&&n.length>0&&E(Array.from(n).filter(o=>o.type.startsWith("image/")))},[E]),G=a.useCallback(e=>{e.preventDefault(),A(!0)},[]),H=a.useCallback(()=>{A(!1)},[]),O=async()=>{if(!(!r.trim()&&N.length===0)){w(!0),h(null),L.current={content:r,mentions:[...C],images:[...N]};try{await i(r,C,[...N],f?.id),x(""),S([]),M([]),L.current=null,y?.()}catch(e){h(String(e instanceof Error?e.message:e)||s("commentInput.sendFailed"))}w(!1)}},Q=async()=>{if(!L.current)return;const{content:e,mentions:n,images:o}=L.current;w(!0),h(null);try{await i(e,n,o),x(""),S([]),M([]),L.current=null}catch(p){h(String(p instanceof Error?p.message:p)||s("commentInput.sendFailed"))}w(!1)},P=a.useCallback(e=>{x(n=>{const o=n.lastIndexOf("@"),p=oe(e.name);return o>=0?n.slice(0,o)+p+" ":n+p+" "}),C.includes(e.id)||S(n=>[...n,e.id]),m(!1),k(""),I(0),F.current?.focus()},[C]),V=e=>{x(e),h(null);const n=e.lastIndexOf("@");if(n>=0&&(n===0||e[n-1]===" ")){const p=e.slice(n+1).toLowerCase();if($.some(v=>v.name.toLowerCase().includes(p))){k(p),m(!0),I(0);return}}m(!1)},Z=e=>{if(c&&D.length>0){const n=e.key==="ArrowUp"||e.ctrlKey&&e.key==="p",o=e.key==="ArrowDown"||e.ctrlKey&&e.key==="n",p=e.key==="Enter"||e.key==="Tab",R=e.key==="Escape";if(n){e.preventDefault(),I(v=>(v-1+D.length)%D.length);return}if(o){e.preventDefault(),I(v=>(v+1)%D.length);return}if(p){e.preventDefault();const v=D[B];v&&P(v);return}if(R){e.preventDefault(),m(!1);return}}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),O())},J=a.useCallback(()=>{setTimeout(()=>m(!1),200)},[]);return t.jsxs("div",{className:"relative",onDragOver:G,onDragLeave:H,onDrop:q,children:[z&&t.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-brand-500/10 rounded-lg border-2 border-dashed border-brand-500",children:t.jsx("span",{className:"text-sm text-brand-500 font-medium",children:s("commentInput.dragDropHint")})}),c&&t.jsx(ae,{candidates:$,filter:j,anchorRef:F,onSelect:P,selectedIndex:B,onIndexChange:I}),t.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[f&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:f.authorName}),t.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:f.content})]}),t.jsx("button",{onClick:y,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),C.length>0&&t.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:C.map(e=>{const n=$.find(o=>o.id===e);return t.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded-full ${n?.type==="human"?"bg-green-500/15 text-green-500":"bg-brand-500/15 text-brand-500"}`,children:["@",n?.name??e,t.jsx("button",{onClick:()=>S(o=>o.filter(p=>p!==e)),className:"hover:text-red-400",children:"×"})]},e)})}),t.jsx("textarea",{ref:F,value:r,onChange:e=>V(e.target.value),onKeyDown:Z,onBlur:J,onPaste:Y,placeholder:g??s("commentInput.placeholder"),rows:2,className:"w-full px-2.5 py-2 text-xs bg-transparent text-fg-primary placeholder-fg-tertiary outline-none resize-none"}),N.length>0&&t.jsx("div",{className:"flex items-center gap-1.5 px-2.5 pb-1.5 overflow-x-auto",children:N.map(e=>t.jsxs("div",{className:"relative group/img shrink-0",children:[t.jsx("img",{src:e.dataUrl,alt:e.name,className:"w-12 h-12 rounded-lg object-cover border border-border-default"}),t.jsx("button",{onClick:()=>X(e.id),className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-[10px] opacity-0 group-hover/img:opacity-100 transition-opacity",title:s("commentInput.removeImage"),children:"×"})]},e.id))}),d&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-1.5",children:[t.jsx("span",{className:"text-[11px] text-red-400 flex-1 truncate",children:d}),t.jsxs("button",{onClick:Q,disabled:b,className:"text-[11px] text-amber-500 hover:text-amber-400 font-medium transition-colors flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),s("commentInput.retry")]})]}),t.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2",children:[t.jsx("button",{type:"button",onClick:()=>U.current?.click(),disabled:b||N.length>=W,className:"p-1 text-fg-tertiary hover:text-brand-500 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:s("commentInput.attachImage"),children:t.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("polyline",{points:"21 15 16 10 5 21"})]})}),t.jsx("input",{ref:U,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&E(e.target.files),e.target.value=""}}),t.jsx("button",{onClick:O,disabled:!r.trim()&&N.length===0||b,className:"px-3 py-1 text-[11px] font-medium bg-brand-500 text-white rounded-md hover:bg-brand-600 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:s(b?"commentInput.sending":"commentInput.submit")})]})]}),t.jsx("p",{className:"mt-1 text-center text-[10px] text-fg-tertiary/80 select-none",children:s("aiDisclaimer")})]})}export{de as C,ie as p,ce as r};
|
|
1
|
+
import{j as t,u as T,r as a,e as ee}from"./index-CHkb08MZ.js";const te=1920,ne=10*1024*1024,W=5,re=.8;function se(l,u,i){return new Promise((g,f)=>{const y=new Image;y.onload=()=>{let{width:s,height:r}=y;if(s<=u&&r<=u){g(l);return}s>r?(r=Math.round(r*(u/s)),s=u):(s=Math.round(s*(u/r)),r=u);const x=document.createElement("canvas");x.width=s,x.height=r;const b=x.getContext("2d");if(!b){f(new Error("Failed to get canvas context"));return}b.drawImage(y,0,0,s,r),g(x.toDataURL("image/jpeg",i))},y.onerror=()=>f(new Error("Failed to load image")),y.src=l})}function ae({candidates:l,filter:u,anchorRef:i,onSelect:g,selectedIndex:f,onIndexChange:y}){const{t:s}=T("common"),[r,x]=a.useState(null),b=a.useRef(null),w=l.filter(d=>d.name.toLowerCase().includes(u));return a.useEffect(()=>{const d=i.current;if(!d)return;const h=d.getBoundingClientRect();x({top:h.top+window.scrollY-4,left:h.left+window.scrollX+8})},[i,u]),a.useEffect(()=>{if(!b.current||!r)return;if(b.current.getBoundingClientRect().top<8){const h=i.current;if(!h)return;const c=h.getBoundingClientRect();x({top:c.bottom+window.scrollY+4,left:r.left})}},[r,i]),a.useEffect(()=>{f>=w.length&&y(Math.max(0,w.length-1))},[w.length,f,y]),a.useEffect(()=>{if(!b.current)return;b.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[f]),!r||w.length===0?null:ee.createPortal(t.jsxs("div",{ref:b,style:{position:"absolute",top:r.top,left:r.left,transform:"translateY(-100%)"},className:"w-60 bg-surface-overlay border border-border-default rounded-lg shadow-xl z-[9999] max-h-48 overflow-y-auto",children:[t.jsx("div",{className:"px-2.5 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:s("commentInput.mentionHeading")}),w.map((d,h)=>t.jsxs("button",{"data-selected":h===f,onMouseDown:c=>{c.preventDefault(),g(d)},onMouseEnter:()=>y(h),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${h===f?"bg-brand-500/15 text-brand-500":"hover:bg-surface-elevated"}`,children:[t.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${d.type==="human"?"bg-green-500/20 text-green-500":"bg-brand-500/20 text-brand-500"}`,children:d.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-fg-primary font-medium",children:d.name}),t.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:d.subtitle??d.type})]}),d.type==="agent"&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${d.online?"bg-green-400":"bg-gray-500"}`})]},d.id))]}),document.body)}function oe(l){return/^\w+$/.test(l)?`@${l}`:`@[${l}]`}const K=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function ie(l){const u=[];let i;for(K.lastIndex=0;(i=K.exec(l))!==null;)u.push(i[1]??i[2]);return u}function ce(l,u,i){const g=[];let f=0;const y=u.map(r=>r.name).sort((r,x)=>x.length-r.length);let s=0;for(;s<l.length;){const r=l.indexOf("@",s);if(r<0){g.push(t.jsx("span",{children:l.slice(s)},f++));break}if(r>s&&g.push(t.jsx("span",{children:l.slice(s,r)},f++)),l[r+1]==="["){const c=l.indexOf("]",r+2);if(c>r+2){const m=l.slice(r+2,c),j=u.find(k=>k.name.toLowerCase()===m.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&j?"cursor-pointer hover:underline":""}`,onClick:i&&j?k=>i(j,k):void 0,title:j?`${j.name} (${j.role})`:void 0,children:["@",m]},f++)),s=c+1;continue}}const x=l.slice(r+1),b=x.toLowerCase(),w=y.find(c=>b.startsWith(c.toLowerCase()));if(w){const c=u.find(m=>m.name.toLowerCase()===w.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&c?"cursor-pointer hover:underline":""}`,onClick:i&&c?m=>i(c,m):void 0,title:c?`${c.name} (${c.role})`:void 0,children:["@",w]},f++)),s=r+1+w.length;continue}const d=/^([\w\p{L}\p{N}]+)/u,h=x.match(d);if(h){const c=h[1],m=u.find(j=>j.name.toLowerCase()===c.toLowerCase());g.push(t.jsxs("span",{className:`text-brand-500 font-medium ${i&&m?"cursor-pointer hover:underline":""}`,onClick:i&&m?j=>i(m,j):void 0,title:m?`${m.name} (${m.role})`:void 0,children:["@",c]},f++)),s=r+1+c.length;continue}g.push(t.jsx("span",{children:"@"},f++)),s=r+1}return g.length>0?g:[t.jsx("span",{children:l},0)]}function de({agents:l,humans:u,onSubmit:i,placeholder:g,replyTo:f,onCancelReply:y}){const{t:s}=T("common"),[r,x]=a.useState(""),[b,w]=a.useState(!1),[d,h]=a.useState(null),[c,m]=a.useState(!1),[j,k]=a.useState(""),[C,S]=a.useState([]),[B,I]=a.useState(0),[N,M]=a.useState([]),[z,A]=a.useState(!1),F=a.useRef(null),U=a.useRef(null),L=a.useRef(null),$=a.useMemo(()=>{const e=(u??[]).map(n=>({id:n.id,name:n.name,type:"human",subtitle:n.role}));for(const n of l)e.push({id:n.id,name:n.name,type:"agent",subtitle:n.role,online:n.status==="idle"||n.status==="working"});return e},[l,u]),D=$.filter(e=>e.name.toLowerCase().includes(j)),E=a.useCallback(e=>{const n=Array.from(e).filter(o=>o.type.startsWith("image/"));if(n.length!==0)for(const o of n){if(o.size>ne)continue;const p=new FileReader;p.onload=()=>{const R=p.result;se(R,te,re).then(v=>{M(_=>_.length>=W?_:[..._,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:v,name:o.name}])})},p.readAsDataURL(o)}},[]),X=a.useCallback(e=>{M(n=>n.filter(o=>o.id!==e))},[]),Y=a.useCallback(e=>{const n=e.clipboardData?.files;if(n&&n.length>0){const o=Array.from(n).filter(p=>p.type.startsWith("image/"));o.length>0&&(e.preventDefault(),E(o))}},[E]),q=a.useCallback(e=>{e.preventDefault(),A(!1);const n=e.dataTransfer?.files;n&&n.length>0&&E(Array.from(n).filter(o=>o.type.startsWith("image/")))},[E]),G=a.useCallback(e=>{e.preventDefault(),A(!0)},[]),H=a.useCallback(()=>{A(!1)},[]),O=async()=>{if(!(!r.trim()&&N.length===0)){w(!0),h(null),L.current={content:r,mentions:[...C],images:[...N]};try{await i(r,C,[...N],f?.id),x(""),S([]),M([]),L.current=null,y?.()}catch(e){h(String(e instanceof Error?e.message:e)||s("commentInput.sendFailed"))}w(!1)}},Q=async()=>{if(!L.current)return;const{content:e,mentions:n,images:o}=L.current;w(!0),h(null);try{await i(e,n,o),x(""),S([]),M([]),L.current=null}catch(p){h(String(p instanceof Error?p.message:p)||s("commentInput.sendFailed"))}w(!1)},P=a.useCallback(e=>{x(n=>{const o=n.lastIndexOf("@"),p=oe(e.name);return o>=0?n.slice(0,o)+p+" ":n+p+" "}),C.includes(e.id)||S(n=>[...n,e.id]),m(!1),k(""),I(0),F.current?.focus()},[C]),V=e=>{x(e),h(null);const n=e.lastIndexOf("@");if(n>=0&&(n===0||e[n-1]===" ")){const p=e.slice(n+1).toLowerCase();if($.some(v=>v.name.toLowerCase().includes(p))){k(p),m(!0),I(0);return}}m(!1)},Z=e=>{if(c&&D.length>0){const n=e.key==="ArrowUp"||e.ctrlKey&&e.key==="p",o=e.key==="ArrowDown"||e.ctrlKey&&e.key==="n",p=e.key==="Enter"||e.key==="Tab",R=e.key==="Escape";if(n){e.preventDefault(),I(v=>(v-1+D.length)%D.length);return}if(o){e.preventDefault(),I(v=>(v+1)%D.length);return}if(p){e.preventDefault();const v=D[B];v&&P(v);return}if(R){e.preventDefault(),m(!1);return}}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),O())},J=a.useCallback(()=>{setTimeout(()=>m(!1),200)},[]);return t.jsxs("div",{className:"relative",onDragOver:G,onDragLeave:H,onDrop:q,children:[z&&t.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-brand-500/10 rounded-lg border-2 border-dashed border-brand-500",children:t.jsx("span",{className:"text-sm text-brand-500 font-medium",children:s("commentInput.dragDropHint")})}),c&&t.jsx(ae,{candidates:$,filter:j,anchorRef:F,onSelect:P,selectedIndex:B,onIndexChange:I}),t.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[f&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:f.authorName}),t.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:f.content})]}),t.jsx("button",{onClick:y,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),C.length>0&&t.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:C.map(e=>{const n=$.find(o=>o.id===e);return t.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded-full ${n?.type==="human"?"bg-green-500/15 text-green-500":"bg-brand-500/15 text-brand-500"}`,children:["@",n?.name??e,t.jsx("button",{onClick:()=>S(o=>o.filter(p=>p!==e)),className:"hover:text-red-400",children:"×"})]},e)})}),t.jsx("textarea",{ref:F,value:r,onChange:e=>V(e.target.value),onKeyDown:Z,onBlur:J,onPaste:Y,placeholder:g??s("commentInput.placeholder"),rows:2,className:"w-full px-2.5 py-2 text-xs bg-transparent text-fg-primary placeholder-fg-tertiary outline-none resize-none"}),N.length>0&&t.jsx("div",{className:"flex items-center gap-1.5 px-2.5 pb-1.5 overflow-x-auto",children:N.map(e=>t.jsxs("div",{className:"relative group/img shrink-0",children:[t.jsx("img",{src:e.dataUrl,alt:e.name,className:"w-12 h-12 rounded-lg object-cover border border-border-default"}),t.jsx("button",{onClick:()=>X(e.id),className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-[10px] opacity-0 group-hover/img:opacity-100 transition-opacity",title:s("commentInput.removeImage"),children:"×"})]},e.id))}),d&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-1.5",children:[t.jsx("span",{className:"text-[11px] text-red-400 flex-1 truncate",children:d}),t.jsxs("button",{onClick:Q,disabled:b,className:"text-[11px] text-amber-500 hover:text-amber-400 font-medium transition-colors flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),s("commentInput.retry")]})]}),t.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2",children:[t.jsx("button",{type:"button",onClick:()=>U.current?.click(),disabled:b||N.length>=W,className:"p-1 text-fg-tertiary hover:text-brand-500 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:s("commentInput.attachImage"),children:t.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("polyline",{points:"21 15 16 10 5 21"})]})}),t.jsx("input",{ref:U,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&E(e.target.files),e.target.value=""}}),t.jsx("button",{onClick:O,disabled:!r.trim()&&N.length===0||b,className:"px-3 py-1 text-[11px] font-medium bg-brand-500 text-white rounded-md hover:bg-brand-600 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:s(b?"commentInput.sending":"commentInput.submit")})]})]}),t.jsx("p",{className:"mt-1 text-center text-[10px] text-fg-tertiary/80 select-none",children:s("aiDisclaimer")})]})}export{de as C,ie as p,ce as r};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{j as i,r as s,_ as f}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CHkb08MZ.js","assets/index-CPULIfuW.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{j as i,r as s,_ as f}from"./index-CHkb08MZ.js";const b=s.lazy(()=>f(()=>import("./index-CHkb08MZ.js").then(e=>e.aA),__vite__mapDeps([0,1])).then(e=>({default:e.MarkdownMessage})));function x(e){switch(e.split(".").pop()?.toLowerCase()){case"md":case"markdown":return"markdown";case"html":case"htm":return"html";case"json":return"json";case"csv":case"tsv":return"csv";default:return}}function w(e){const t=e.trimStart();if(/^<!doctype\s+html/i.test(t)||/^<html[\s>]/i.test(t))return"html";if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(e),"json"}catch{}}function E(e){if(e.format)return e.format;if(e.reference){const t=x(e.reference);if(t)return t}if(e.content){const t=w(e.content);if(t)return t}return"markdown"}function v({content:e,className:t,onSelection:r}){const c=s.useRef(null),[l,g]=s.useState(null);s.useEffect(()=>{const o=d=>{d.data?.type==="__htmlpreview_height"&&typeof d.data.height=="number"&&g(d.data.height),d.data?.type==="__htmlpreview_selection"&&r&&r(d.data)};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[r]);const h=`<script>
|
|
3
3
|
(function(){
|
|
4
4
|
function getXPath(el){
|
|
5
5
|
if(!el||el.nodeType!==1)return'';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as st,j as e,r as s,e as rs,A as xt,w as ft,s as as,g as Ot,f as L,k as os,l as ls,m as zt,o as is,p as cs,q as ds,t as tt,v as us,R as xs,x as fs,y as ms,z as ps,a as hs,B as gs,C as bs,b as ys,D as vs,P as Te,M as js,n as Ge,E as ws}from"./index-
|
|
1
|
+
import{u as st,j as e,r as s,e as rs,A as xt,w as ft,s as as,g as Ot,f as L,k as os,l as ls,m as zt,o as is,p as cs,q as ds,t as tt,v as us,R as xs,x as fs,y as ms,z as ps,a as hs,B as gs,C as bs,b as ys,D as vs,P as Te,M as js,n as Ge,E as ws}from"./index-CHkb08MZ.js";import{resolveFormat as ks,ContentRenderer as Ns}from"./ContentRenderer-CQ9uMng0.js";function Ne(c){return Array.isArray(c)?c.map(h=>String(h).trim()).filter(Boolean):typeof c=="string"&&c?c.split(",").map(h=>h.trim()).filter(Boolean):[]}function Ss(c){return c.files&&typeof c.files=="object"&&!Array.isArray(c.files)?c.files:null}function Ue({label:c,value:h}){return h?e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:h})]}):null}function Ye({label:c,value:h,color:f}){if(!h)return null;const r={purple:"bg-brand-500/15 text-brand-500",cyan:"bg-blue-500/15 text-blue-600",indigo:"bg-brand-500/15 text-brand-500",gray:"bg-gray-500/15 text-fg-secondary",emerald:"bg-green-500/15 text-green-600"};return e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:c}),e.jsx("div",{className:`mt-0.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${r[f]??r.gray} capitalize inline-block`,children:h})]})}function Nt({files:c}){const{t:h}=st(["builder","common"]),[f,r]=s.useState(Object.keys(c)[0]??""),v=Object.keys(c);return v.length===0?null:e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:h("builder:artifact.files",{count:v.length})}),e.jsxs("div",{className:"mt-1 bg-surface-elevated/50 rounded-lg border border-border-default/30 overflow-hidden",children:[e.jsx("div",{className:"flex gap-0.5 px-1.5 py-1 border-b border-border-default/30 overflow-x-auto",children:v.map(_=>e.jsx("button",{onClick:()=>r(_),className:`px-2 py-0.5 text-[10px] rounded whitespace-nowrap transition-colors ${f===_?"bg-brand-600/30 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:_},_))}),f&&c[f]!=null&&e.jsx("pre",{className:"p-2 text-[10px] text-fg-secondary max-h-[120px] overflow-auto whitespace-pre-wrap font-mono",children:c[f]})]})]})}function Cs({artifact:c,mode:h}){const{t:f}=st(["builder","common"]),r=Ss(c),v=c.agent,_=c.team,K=c.dependencies,z=c.displayName??c.name;if(h==="agent"){const U=v?.roleName,F=v?.agentRole,M=v?.llmProvider,q=v?.llmModel,E=Ne(K?.env),P=Ne(K?.skills);return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(Ue,{label:f("builder:artifact.name"),value:z}),e.jsx(Ue,{label:f("builder:artifact.description"),value:c.description}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[U&&e.jsx(Ye,{label:f("builder:artifact.baseTemplate"),value:U,color:"indigo"}),e.jsx(Ye,{label:f("builder:artifact.agentRole"),value:F,color:F==="manager"?"purple":"cyan"})]}),Ne(c.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:Ne(c.tags).map(k=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:k},k))}),(M||q)&&e.jsxs("div",{className:"flex gap-2",children:[M&&e.jsx(Ye,{label:f("builder:artifact.llmProvider"),value:M,color:"gray"}),q&&e.jsx(Ye,{label:f("builder:artifact.llmModel"),value:q,color:"gray"})]}),E.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:f("builder:artifact.requiredEnv")}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:E.map(k=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/10 text-amber-600 rounded font-mono",children:k},k))})]}),P.length>0&&e.jsx(Ue,{label:f("builder:artifact.skills"),value:P.join(", ")}),r&&e.jsx(Nt,{files:r})]})}if(h==="team"){const F=_?.members??[];return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(Ue,{label:f("builder:artifact.name"),value:z}),e.jsx(Ue,{label:f("builder:artifact.description"),value:c.description}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(Ye,{label:f("builder:artifact.category"),value:c.category,color:"indigo"})}),Ne(c.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:Ne(c.tags).map(M=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:M},M))}),r&&e.jsx(Nt,{files:r}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:f("builder:artifact.members",{count:F.length})}),e.jsx("div",{className:"mt-1.5 space-y-1.5",children:F.map((M,q)=>e.jsxs("div",{className:"bg-surface-elevated/30 rounded-lg px-2 py-1.5 border border-border-default/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center text-[10px] font-bold ${M.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:M.role==="manager"?"★":q+1}),e.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:M.name}),typeof M.roleName=="string"&&M.roleName&&e.jsx("span",{className:"text-[10px] text-brand-500/70 font-mono",children:M.roleName}),e.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",String(M.count??1)]})]}),Ne(M.skills).length>0&&e.jsx("div",{className:"mt-1 ml-7 flex flex-wrap gap-1",children:Ne(M.skills).map(E=>e.jsx("span",{className:"px-1 py-0.5 text-[9px] bg-green-500/10 text-green-600 rounded font-mono",children:E},E))})]},q))})]})]})}return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(Ue,{label:f("builder:artifact.name"),value:z}),e.jsx(Ue,{label:f("builder:artifact.description"),value:c.description}),e.jsx("div",{className:"flex gap-2",children:e.jsx(Ye,{label:f("builder:artifact.category"),value:c.category,color:"indigo"})}),r&&e.jsx(Nt,{files:r}),Ne(c.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:Ne(c.tags).map(U=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:U},U))})]})}const Ut={agent:"🤖",project:"📁",requirement:"📋",task:"✅",deliverable:"📦",workflow:"⚙️"},Is=["project","requirement","task","deliverable","workflow","agent"];function Vt(c){return c.dataUrl.startsWith("data:image/")}function Ls(c,h){if(Vt({dataUrl:h}))return null;const f=c.split(".").pop()?.toLowerCase()??"";return{pdf:"📄",docx:"📝",doc:"📝",xlsx:"📊",xls:"📊",pptx:"📎",csv:"📊",json:"🔧",xml:"🔧",html:"🌐",epub:"📚"}[f]??"📁"}function Ms({value:c,onChange:h,onSend:f,disabled:r=!1,placeholder:v="",sending:_=!1,onStop:K,contextChips:z,mentionItems:U,pendingFiles:F,onAttach:M,onPaste:q,onDrop:E,onDragOver:P,onRemoveFile:k,replyTo:Z,onClearReply:ne,fileInputRef:ge,visionWarning:We,maxFiles:Fe=5,className:Se="",compact:oe=!1,onMentionChipsChange:fe}){const{t:be}=st(["team","common"]),G=s.useRef(null),le=s.useRef(null);s.useRef(null);const[ie,ce]=s.useState(!1),[ye,me]=s.useState(""),[Y,J]=s.useState(0),[ee,ve]=s.useState(null),[W,Ce]=s.useState([]),n=(U??[]).filter(o=>o.name.toLowerCase().includes(ye)),de=(()=>{if(n.length===0)return[];const o=new Map;for(const O of n){const A=O.type??"agent";o.has(A)||o.set(A,[]),o.get(A).push(O)}const D=[];for(const O of Is){const A=o.get(O);A?.length&&D.push({type:O,items:A})}return D})();s.useEffect(()=>{if(!ie||!G.current){ve(null);return}const o=G.current.getBoundingClientRect();ve({left:o.left+16,bottom:window.innerHeight-o.top+4})},[ie]);const Ee=s.useCallback(()=>{const o=le.current;o&&(o.style.height="auto",o.style.height=`${Math.min(o.scrollHeight,oe?80:120)}px`)},[oe]);s.useEffect(()=>{Ee()},[c,Ee]);const He=s.useCallback(o=>{if(h(o),!U?.length){ce(!1);return}const D=le.current?.selectionStart??o.length,O=o.slice(0,D),A=O.lastIndexOf("@");if(A>=0){const V=A===0?"":O[A-1];if(A===0||/[\s\n,,。!?!?;;::、()()\[\]【】]/.test(V)){const re=O.slice(A+1);if(!re.includes(" ")&&!re.includes(`
|
|
2
2
|
`)){ce(!0),me(re.toLowerCase()),J(0);return}}}ce(!1)},[h,U]),Ae=s.useCallback(o=>{const D=le.current?.selectionStart??c.length,A=c.slice(0,D).lastIndexOf("@"),V=c.slice(D),Q=c.slice(0,A)+V.replace(/^\s/,"");h(Q);const re={id:`mention_${Date.now()}_${o.id}`,entityId:o.id,name:o.name,entityType:o.type},Be=[...W,re];Ce(Be),fe?.(Be),ce(!1),J(0),requestAnimationFrame(()=>{const ue=A;le.current?.setSelectionRange(ue,ue),le.current?.focus()})},[c,h,W,fe]),Ie=s.useCallback(()=>{f(),Ce([]),fe?.([])},[f,fe]),X=s.useCallback(o=>{if(ie&&n.length>0){const D=o.key==="ArrowUp"||o.ctrlKey&&o.key==="p",O=o.key==="ArrowDown"||o.ctrlKey&&o.key==="n",A=o.key==="Enter"||o.key==="Tab",V=o.key==="Escape";if(D){o.preventDefault(),J(Q=>(Q-1+n.length)%n.length);return}if(O){o.preventDefault(),J(Q=>(Q+1)%n.length);return}if(A){o.preventDefault();const Q=n[Y];Q&&Ae(Q);return}if(V){o.preventDefault(),ce(!1);return}}o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),Ie())},[ie,n,Y,Ae,Ie]),je=F??[],Re=ie&&n.length>0&&ee&&rs.createPortal(e.jsx("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden max-h-64 overflow-y-auto min-w-[220px]",style:{left:ee.left,bottom:ee.bottom,zIndex:9999},children:(()=>{let o=0;return de.map(D=>{const O=Ut[D.type],A=be(`page.mentionType.${D.type}`);return e.jsxs("div",{children:[e.jsxs("div",{className:"px-3 py-1 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default bg-surface-secondary/50 flex items-center gap-1.5 sticky top-0",children:[e.jsx("span",{children:O}),e.jsx("span",{children:A})]}),D.items.map(V=>{const Q=o++;return e.jsxs("button",{ref:re=>{Q===Y&&re&&re.scrollIntoView({block:"nearest"})},onMouseDown:re=>{re.preventDefault(),Ae(V)},onMouseEnter:()=>J(Q),className:`w-full text-left px-4 py-2 text-sm flex items-center gap-2 transition-colors ${Q===Y?"bg-brand-500/15 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,children:[V.type==="agent"?e.jsx(xt,{name:V.name,avatarUrl:V.avatarUrl,size:20,bgClass:"bg-brand-500/20 text-brand-500"}):e.jsx("span",{className:"text-xs w-5 h-5 flex items-center justify-center shrink-0",children:O}),e.jsx("span",{className:"flex-1 min-w-0 truncate",children:V.name}),V.role&&e.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto shrink-0",children:V.role})]},V.id)})]},D.type)})})()}),document.body);return e.jsxs("div",{ref:G,className:`relative bg-surface-primary border border-border-default shadow-lg shadow-black/10 rounded-2xl p-3 ${Se}`,onDrop:E,onDragOver:P,children:[Re,(z&&z.length>0||W.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[W.map(o=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full bg-brand-500/10 border border-brand-500/30 text-xs text-brand-400 max-w-[200px]",children:[e.jsx("span",{className:"shrink-0 text-[10px]",children:Ut[o.entityType]}),e.jsx("span",{className:"truncate font-medium",children:o.name}),e.jsx("button",{onClick:()=>{const D=W.filter(O=>O.id!==o.id);Ce(D),fe?.(D)},className:"shrink-0 text-brand-400/60 hover:text-red-400 transition-colors",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},o.id)),z?.map(o=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-surface-elevated border border-border-default text-xs text-fg-secondary max-w-[200px]",children:[e.jsx("span",{className:"truncate",children:o.label}),o.onRemove&&e.jsx("button",{onClick:o.onRemove,className:"shrink-0 text-fg-tertiary hover:text-red-500 transition-colors",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},o.id))]}),je.length>0&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 overflow-x-auto pb-1",children:[je.map(o=>e.jsxs("div",{className:"relative group/img shrink-0",children:[Vt(o)?e.jsx("img",{src:o.dataUrl,alt:o.name,className:"w-16 h-16 rounded-lg object-cover border border-border-default"}):e.jsxs("div",{className:"w-16 h-16 rounded-lg border border-border-default bg-surface-elevated flex flex-col items-center justify-center gap-0.5",title:o.name,children:[e.jsx("span",{className:"text-xl leading-none",children:Ls(o.name,o.dataUrl)}),e.jsx("span",{className:"text-[9px] text-fg-tertiary truncate max-w-[56px] px-0.5",children:o.name.split(".").pop()?.toUpperCase()})]}),k&&e.jsx("button",{onClick:()=>k(o.id),className:"absolute -top-1.5 -right-1.5 w-5 h-5 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-xs opacity-0 group-hover/img:opacity-100 transition-opacity",children:"×"})]},o.id)),je.length<Fe&&M&&e.jsx("button",{onClick:M,className:"w-16 h-16 rounded-lg border border-dashed border-gray-600 flex items-center justify-center text-fg-tertiary hover:text-fg-secondary hover:border-gray-400 transition-colors shrink-0",title:be("page.addMoreFiles"),children:e.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})})]}),We&&e.jsxs("div",{className:"text-[10px] text-amber-500/80 mb-1.5 flex items-center gap-1",children:[e.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M12 9v4m0 4h.01M12 2L2 22h20L12 2z",strokeLinecap:"round",strokeLinejoin:"round"})}),be("page.visionWarning")]}),Z&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 px-3 py-1.5 bg-surface-elevated rounded-lg border border-border-default/50",children:[e.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[e.jsx("span",{className:"text-[11px] font-medium text-brand-500",children:Z.sender}),e.jsx("p",{className:"text-[11px] text-fg-tertiary truncate",children:Z.text})]}),ne&&e.jsx("button",{onClick:ne,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsxs("div",{className:"flex gap-2 items-end",children:[M&&e.jsx("button",{onClick:M,disabled:r,className:"px-2.5 py-2.5 text-fg-tertiary hover:text-fg-secondary disabled:opacity-40 transition-colors rounded-xl hover:bg-surface-elevated",title:be("page.attachFilesTitle"),children:e.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("textarea",{ref:le,value:c,onChange:o=>He(o.target.value),onKeyDown:X,onPaste:q,placeholder:v,disabled:r,rows:oe?1:2,className:"flex-1 px-4 py-3 bg-transparent rounded-xl text-sm outline-none disabled:opacity-40 transition-colors resize-none overflow-hidden leading-relaxed placeholder:text-fg-secondary",style:{minHeight:oe?"36px":"52px",maxHeight:oe?"80px":"120px"}}),_&&K&&e.jsx("button",{onClick:K,className:"px-3 py-2.5 bg-red-600 hover:bg-red-500 text-white text-sm rounded-xl transition-colors flex items-center gap-1.5",title:be("page.stopAgent"),children:e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})}),e.jsx("button",{onClick:Ie,disabled:r||!c.trim()&&je.length===0&&W.length===0,className:"px-5 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:be("common:send")})]})]})}function Ts({agentId:c,sessionId:h,agents:f,authUser:r,onClose:v,contextChips:_,extraMentionItems:K,width:z,className:U=""}){const{t:F}=st(["team","common"]),M=f.find(d=>d.id===c),q=M?.name??F("page.fallbackAgent"),E=r?.name??F("page.fallbackYou"),[P,k]=s.useState([]),[Z,ne]=s.useState(h??null),[ge,We]=s.useState(!0),[Fe,Se]=s.useState(!1),[oe,fe]=s.useState(""),[be,G]=s.useState([]),[le,ie]=s.useState([]),ce=s.useRef(null),ye=s.useRef(null),me=s.useRef(null),Y=s.useRef(!0),J=s.useRef(Z);J.current=Z;const ee=s.useMemo(()=>({today:F("page.dateToday"),yesterday:F("page.dateYesterday")}),[F]),ve=s.useMemo(()=>{const d=F("page.chatGreetings",{returnObjects:!0});return Array.isArray(d)&&d.length>0?d[Math.floor(Math.random()*d.length)]:""},[F]),W=s.useCallback((d="auto")=>{ye.current?.scrollIntoView({behavior:d})},[]);s.useEffect(()=>{let d=!1;return We(!0),k([]),(async()=>{try{let C=h??null;if(!C){const{sessions:H}=await L.sessions.listByAgent(c,10);C=H.find(R=>R.isMain)?.id??H[0]?.id??null}if(d)return;if(ne(C),C){const H=await L.sessions.getMessages(C,50);if(d)return;const T=H.messages.map(fs).filter(R=>R.sender!=="agent"||R.text||R.segments&&R.segments.length>0);k(T)}}catch{}d||We(!1)})(),()=>{d=!0}},[c,h]);const Ce=s.useRef(!0);s.useEffect(()=>{Ce.current&&!ge&&P.length>0&&requestAnimationFrame(()=>{requestAnimationFrame(()=>W())}),Ce.current=ge},[ge,P.length,W]),s.useEffect(()=>{!ge&&Y.current&&requestAnimationFrame(()=>W())},[P,W,ge]),s.useEffect(()=>ft.on("chat:proactive_message",N=>{const C=N.payload,H=C.agentId??"";if(H!==c)return;const T=C.targetUserId;if(T&&T!==r?.id)return;const R=C.message??"",pe=C.sessionId??"",te=C.messageId??"";if(!R||R==="[cancelled]"||R==="[Stream cancelled]"||pe&&J.current&&pe!==J.current)return;const S=C.metadata??{},he=S.role==="user",{cleaned:se,priority:Le}=as(R),l=!he&&(!!S.notifyUser||se!==R),g=typeof S.userText=="string"?S.userText:"",i=typeof S.userMessageId=="string"?S.userMessageId:"",x=typeof S.createdAt=="string"&&S.createdAt||(typeof N.timestamp=="string"?N.timestamp:void 0)||new Date().toISOString(),p=(()=>{try{return new Date(x).toLocaleTimeString()}catch{return new Date().toLocaleTimeString()}})(),b={id:te||`proactive_${Date.now()}`,sender:he?"user":"agent",text:se,time:p,rawCreatedAt:x,...he?{}:{agentName:C.agentName??q,agentId:H,...l?{isNotification:!0,notifyPriority:S.priority??Le}:{}}};k(j=>{if(j.some(y=>y.id===b.id))return j;let I=j;return!he&&g&&(I.some(w=>i&&w.id===i||w.sender==="user"&&w.text===g)||(I=Ot(I,{id:i||`feishu_user_${b.id}`,sender:"user",text:g,time:p,rawCreatedAt:x}))),Ot(I,b)})}),[c,q,r?.id]);const[n,de]=s.useState(!1),Ee=s.useCallback(()=>{const d=ce.current;if(!d)return;const N=d.scrollHeight-d.scrollTop-d.clientHeight<60;Y.current=N,de(!N)},[]),He=s.useCallback(()=>{me.current?.abort(),me.current=null,Se(!1),G([]),L.agents.cancelProcessing(c).catch(()=>{})},[c]),[Ae,Ie]=s.useState(null),[X,je]=s.useState(null),[Re,o]=s.useState(!1),D=s.useCallback(async(d,N)=>{let C=d?.trim()??"";if(!C){const l=[];if(le.length>0&&l.push(le.map(g=>`@[${g.name}](${g.entityType}:${g.entityId})`).join(" ")),_?.length)for(const g of _)l.push(`[${g.type}: ${g.label}]
|
|
3
3
|
${g.content}`);oe.trim()&&l.push(oe.trim()),C=l.join(`
|
|
4
4
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as o,a as l,j as e,M as t,N as n}from"./index-CHkb08MZ.js";function r({authUser:s}){const{t:a}=o("nav"),i=l();return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{"data-electron-drag":!0,className:"flex items-center gap-2 px-4 h-14",children:[i&&e.jsx(t,{}),e.jsx("h2",{className:"text-base font-bold",children:a("notifications")})]}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(n,{collapsed:!1,userId:s?.id,embeddedMode:!0})})]})}export{r as NotificationsPage};
|