@rubytech/create-maxy-code 0.1.49 → 0.1.51
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/package.json +1 -1
- package/payload/platform/plugins/admin/PLUGIN.md +1 -1
- package/payload/platform/plugins/admin/hooks/__tests__/turn-completed-graph-write.test.sh +54 -55
- package/payload/platform/plugins/admin/hooks/turn-completed-graph-write.sh +40 -47
- package/payload/platform/plugins/docs/PLUGIN.md +3 -1
- package/payload/platform/plugins/docs/references/admin-session.md +10 -0
- package/payload/platform/plugins/docs/references/internals.md +4 -0
- package/payload/platform/plugins/docs/references/platform.md +1 -1
- package/payload/platform/plugins/loop/PLUGIN.md +24 -0
- package/payload/platform/plugins/loop/mcp/src/__tests__/plugin-md-time-doctrine.test.ts +132 -0
- package/payload/platform/plugins/tasks/mcp/dist/index.js +1 -2
- package/payload/platform/plugins/tasks/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/tasks/mcp/dist/tools/session-name.d.ts.map +1 -1
- package/payload/platform/plugins/tasks/mcp/dist/tools/session-name.js +3 -2
- package/payload/platform/plugins/tasks/mcp/dist/tools/session-name.js.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
- package/payload/platform/services/claude-session-manager/dist/http-server.js +17 -2
- package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
- package/payload/premium-plugins/real-agent/plugins/loop/PLUGIN.md +24 -0
- package/payload/premium-plugins/real-agent/plugins/loop/mcp/src/__tests__/plugin-md-time-doctrine.test.ts +132 -0
- package/payload/server/{chunk-MEGIQYUD.js → chunk-CWI7NOWK.js} +1 -1
- package/payload/server/{chunk-XJVJ2B2Q.js → chunk-NPZKH5EC.js} +1 -1
- package/payload/server/{chunk-4P2MPERV.js → chunk-X3Y6ENKA.js} +0 -90
- package/payload/server/{cloudflare-task-tracker-R6MMORFU.js → cloudflare-task-tracker-TL6R364J.js} +2 -2
- package/payload/server/maxy-edge.js +2 -2
- package/payload/server/public/assets/{admin-DBuCWSPS.js → admin-BbcN8otj.js} +1 -1
- package/payload/server/public/assets/{architectureDiagram-Q4EWVU46-Ch-JZ1Q0.js → architectureDiagram-Q4EWVU46-DGHlapUl.js} +1 -1
- package/payload/server/public/assets/{blockDiagram-DXYQGD6D-C08tkD4C.js → blockDiagram-DXYQGD6D-Dgnf9J14.js} +1 -1
- package/payload/server/public/assets/{brand-DCdOhh-I.css → brand-CtilcX3W.css} +1 -1
- package/payload/server/public/assets/{c4Diagram-AHTNJAMY-IceRdWw3.js → c4Diagram-AHTNJAMY-GBVmghhJ.js} +1 -1
- package/payload/server/public/assets/channel-p5ZCfK_I.js +1 -0
- package/payload/server/public/assets/{chunk-336JU56O-Cey0rxmH.js → chunk-336JU56O-CSVC_J3A.js} +2 -2
- package/payload/server/public/assets/{chunk-426QAEUC-Dzk8s0or.js → chunk-426QAEUC-CK1Z0942.js} +1 -1
- package/payload/server/public/assets/{chunk-4TB4RGXK-C10nuKc8.js → chunk-4TB4RGXK-CaqJYLxL.js} +1 -1
- package/payload/server/public/assets/{chunk-5FUZZQ4R-B1B8871D.js → chunk-5FUZZQ4R-57BmPy_B.js} +1 -1
- package/payload/server/public/assets/{chunk-5PVQY5BW-jvHIkgqP.js → chunk-5PVQY5BW-Ud03uYx_.js} +1 -1
- package/payload/server/public/assets/{chunk-EDXVE4YY-7nDxvXHS.js → chunk-EDXVE4YY-p5KO0PoG.js} +1 -1
- package/payload/server/public/assets/{chunk-ENJZ2VHE-C8lJ1YYn.js → chunk-ENJZ2VHE-CkxgLujt.js} +1 -1
- package/payload/server/public/assets/{chunk-ICPOFSXX-CT1d7veI.js → chunk-ICPOFSXX-DwMkY8p7.js} +1 -1
- package/payload/server/public/assets/{chunk-OYMX7WX6-LTAfwxv0.js → chunk-OYMX7WX6-CyYOUKBw.js} +1 -1
- package/payload/server/public/assets/{chunk-U2HBQHQK-RoGrqrH0.js → chunk-U2HBQHQK-Dk5rfJM6.js} +1 -1
- package/payload/server/public/assets/{chunk-X2U36JSP-D89ZBg3z.js → chunk-X2U36JSP-D0qCg9Nq.js} +1 -1
- package/payload/server/public/assets/{chunk-YZCP3GAM-Cyg122Hf.js → chunk-YZCP3GAM-C0uFHrdT.js} +1 -1
- package/payload/server/public/assets/{chunk-ZZ45TVLE-Dg59YYuG.js → chunk-ZZ45TVLE-C7lSyGRs.js} +1 -1
- package/payload/server/public/assets/classDiagram-6PBFFD2Q-DqDM1D4-.js +1 -0
- package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-DeYvPD8H.js +1 -0
- package/payload/server/public/assets/clone-60k82qeh.js +1 -0
- package/payload/server/public/assets/{dagre-BPzUsxie.js → dagre-BWZ4wr8y.js} +1 -1
- package/payload/server/public/assets/{dagre-KV5264BT-CjDNXqPy.js → dagre-KV5264BT-C7mpqRpw.js} +1 -1
- package/payload/server/public/assets/data-oXs84UW6.js +1 -0
- package/payload/server/public/assets/{device-url-actions-B588ZlnE.js → device-url-actions-347cMDY4.js} +1 -1
- package/payload/server/public/assets/{diagram-5BDNPKRD-Bqq0vqWM.js → diagram-5BDNPKRD-BcQRB7_3.js} +1 -1
- package/payload/server/public/assets/{diagram-G4DWMVQ6-DSqocDhm.js → diagram-G4DWMVQ6-BLSGUKbc.js} +1 -1
- package/payload/server/public/assets/{diagram-MMDJMWI5-DZRWgKRL.js → diagram-MMDJMWI5-Ra1VvGJh.js} +1 -1
- package/payload/server/public/assets/{diagram-TYMM5635-DXRm-FXu.js → diagram-TYMM5635-Bx_r1USn.js} +1 -1
- package/payload/server/public/assets/{erDiagram-SMLLAGMA-CFVgkUCo.js → erDiagram-SMLLAGMA-CJhoN8dG.js} +1 -1
- package/payload/server/public/assets/{flowDiagram-DWJPFMVM-C82XCt9-.js → flowDiagram-DWJPFMVM-Bd5CZIoq.js} +1 -1
- package/payload/server/public/assets/{ganttDiagram-T4ZO3ILL-C4tnImlS.js → ganttDiagram-T4ZO3ILL-BNQJqJFh.js} +1 -1
- package/payload/server/public/assets/{gitGraphDiagram-UUTBAWPF-DXHutP-a.js → gitGraphDiagram-UUTBAWPF-DoE1AFmA.js} +1 -1
- package/payload/server/public/assets/graph-DcpqWbSs.js +1 -0
- package/payload/server/public/assets/graph-labels-DJvuUODB.js +1 -0
- package/payload/server/public/assets/{graphlib-BvR5tL62.js → graphlib-D7JFfLSw.js} +1 -1
- package/payload/server/public/assets/{infoDiagram-42DDH7IO-DgFMqgZy.js → infoDiagram-42DDH7IO-BtsKRO-J.js} +1 -1
- package/payload/server/public/assets/{ishikawaDiagram-UXIWVN3A-_5gmh1-V.js → ishikawaDiagram-UXIWVN3A-DapnDR0V.js} +1 -1
- package/payload/server/public/assets/{journeyDiagram-VCZTEJTY-CNfDVgwI.js → journeyDiagram-VCZTEJTY-BLqfwMMu.js} +1 -1
- package/payload/server/public/assets/{kanban-definition-6JOO6SKY-Djifb_Z6.js → kanban-definition-6JOO6SKY-DqiSbvUW.js} +1 -1
- package/payload/server/public/assets/{line-0fRVrNiw.js → line-DcwBbbhp.js} +1 -1
- package/payload/server/public/assets/{mermaid-parser.core-DXA7LKDt.js → mermaid-parser.core-BZwNRInp.js} +1 -1
- package/payload/server/public/assets/{mermaid.core-BCfYtdMJ.js → mermaid.core-DnsyVInc.js} +3 -3
- package/payload/server/public/assets/{mindmap-definition-QFDTVHPH-sTRvikWi.js → mindmap-definition-QFDTVHPH-MPPO8aDx.js} +1 -1
- package/payload/server/public/assets/{page-nAY64ID7.js → page-Cz_pVOv_.js} +1 -1
- package/payload/server/public/assets/{page-DDyny08O.js → page-pXt2BdOS.js} +1 -1
- package/payload/server/public/assets/{pieDiagram-DEJITSTG-QLTieded.js → pieDiagram-DEJITSTG-BKzbjD_5.js} +1 -1
- package/payload/server/public/assets/{public-rUUducAl.js → public-C-0V5aC8.js} +3 -3
- package/payload/server/public/assets/{quadrantDiagram-34T5L4WZ-DOKCcqAZ.js → quadrantDiagram-34T5L4WZ-CvvvRvae.js} +1 -1
- package/payload/server/public/assets/{requirementDiagram-MS252O5E-BX6Zpq1X.js → requirementDiagram-MS252O5E-BxXZA7z2.js} +1 -1
- package/payload/server/public/assets/{sankeyDiagram-XADWPNL6-B05NdgZX.js → sankeyDiagram-XADWPNL6-BRRFjjao.js} +1 -1
- package/payload/server/public/assets/{sequenceDiagram-FGHM5R23-CHF8ZdUb.js → sequenceDiagram-FGHM5R23-DOy_E8xe.js} +1 -1
- package/payload/server/public/assets/{stateDiagram-FHFEXIEX-DTAt7Ytz.js → stateDiagram-FHFEXIEX-CDqat01p.js} +1 -1
- package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-DHckg-aj.js +1 -0
- package/payload/server/public/assets/{timeline-definition-GMOUNBTQ-Dzd6X_ei.js → timeline-definition-GMOUNBTQ-AK1yuR8Z.js} +1 -1
- package/payload/server/public/assets/{vennDiagram-DHZGUBPP-BAbM4QlQ.js → vennDiagram-DHZGUBPP-CCKJ7H16.js} +1 -1
- package/payload/server/public/assets/{wardleyDiagram-NUSXRM2D-CIOXXKJd.js → wardleyDiagram-NUSXRM2D-CKHKJnG_.js} +1 -1
- package/payload/server/public/assets/{xychartDiagram-5P7HB3ND-oF9sZesS.js → xychartDiagram-5P7HB3ND-BBD35k9e.js} +1 -1
- package/payload/server/public/data.html +5 -5
- package/payload/server/public/graph.html +5 -5
- package/payload/server/public/index.html +7 -7
- package/payload/server/public/public.html +4 -4
- package/payload/server/server.js +97 -74
- package/payload/server/public/assets/channel-8QQB2Zoe.js +0 -1
- package/payload/server/public/assets/classDiagram-6PBFFD2Q-CViZOOjI.js +0 -1
- package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-Dm7eGBqB.js +0 -1
- package/payload/server/public/assets/clone-BC8oes11.js +0 -1
- package/payload/server/public/assets/data-BeblX4m4.js +0 -1
- package/payload/server/public/assets/graph-ZuBiYril.js +0 -1
- package/payload/server/public/assets/graph-labels-CnbJR6cp.js +0 -1
- package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-2bJIW7wn.js +0 -1
- /package/payload/server/public/assets/{brand-Dln107gD.js → brand-B6pMzF6h.js} +0 -0
package/payload/server/server.js
CHANGED
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
vncLog,
|
|
61
61
|
waitForExit,
|
|
62
62
|
walkPremiumBundles
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-CWI7NOWK.js";
|
|
64
64
|
import {
|
|
65
65
|
CLOUDFLARE_TASK_DIAGNOSTICS,
|
|
66
66
|
appendCloudflareSteps,
|
|
@@ -69,16 +69,14 @@ import {
|
|
|
69
69
|
openCloudflareTask,
|
|
70
70
|
readTunnelState,
|
|
71
71
|
resolveUnitGoneVerdict
|
|
72
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-NPZKH5EC.js";
|
|
73
73
|
import {
|
|
74
74
|
GREETING_DIRECTIVE,
|
|
75
|
-
HAIKU_MODEL,
|
|
76
75
|
deleteAgentProjection,
|
|
77
76
|
deleteConversation,
|
|
78
77
|
embed,
|
|
79
78
|
ensureConversation,
|
|
80
79
|
fetchBranding,
|
|
81
|
-
generateSessionLabel,
|
|
82
80
|
getAgentSessionIdForConversation,
|
|
83
81
|
getRecentMessages,
|
|
84
82
|
getSession,
|
|
@@ -93,7 +91,7 @@ import {
|
|
|
93
91
|
verifyAndGetConversationUpdatedAt,
|
|
94
92
|
verifyConversationOwnership,
|
|
95
93
|
writeAdminUserAndPerson
|
|
96
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-X3Y6ENKA.js";
|
|
97
95
|
import {
|
|
98
96
|
__commonJS,
|
|
99
97
|
__toESM
|
|
@@ -4166,6 +4164,16 @@ async function callOauthLlm(params) {
|
|
|
4166
4164
|
return { kind: "ok", text: textBlock.text, stopReason, outputTokens };
|
|
4167
4165
|
}
|
|
4168
4166
|
|
|
4167
|
+
// ../lib/models/src/index.ts
|
|
4168
|
+
var OPUS_MODEL = "claude-opus-4-7";
|
|
4169
|
+
var SONNET_MODEL = "claude-sonnet-4-6";
|
|
4170
|
+
var HAIKU_MODEL = "claude-haiku-4-5";
|
|
4171
|
+
var MODEL_CONTEXT_WINDOW = {
|
|
4172
|
+
[OPUS_MODEL]: 2e5,
|
|
4173
|
+
[SONNET_MODEL]: 2e5,
|
|
4174
|
+
[HAIKU_MODEL]: 2e5
|
|
4175
|
+
};
|
|
4176
|
+
|
|
4169
4177
|
// ../lib/screening-patterns/src/index.ts
|
|
4170
4178
|
var PROMPT_INJECTION_PATTERNS = [
|
|
4171
4179
|
"ignore your instructions",
|
|
@@ -7772,33 +7780,6 @@ app14.post("/:id/resume", async (c) => {
|
|
|
7772
7780
|
}
|
|
7773
7781
|
});
|
|
7774
7782
|
});
|
|
7775
|
-
app14.post("/:id/label", requireAdminSession, async (c) => {
|
|
7776
|
-
const conversationId = c.req.param("id");
|
|
7777
|
-
const cacheKey = c.var.cacheKey;
|
|
7778
|
-
const accountId = getAccountIdForSession(cacheKey);
|
|
7779
|
-
if (!accountId) return c.json({ error: "Account not found for session" }, 401);
|
|
7780
|
-
const owned = await verifyConversationOwnership(conversationId, accountId);
|
|
7781
|
-
if (!owned) return c.json({ error: "Conversation not found" }, 404);
|
|
7782
|
-
console.error(`[admin] manual-label: requesting suggestion for ${conversationId}`);
|
|
7783
|
-
try {
|
|
7784
|
-
const messages = await getRecentMessages(conversationId, 50);
|
|
7785
|
-
const userMessages = messages.filter((m) => m.role === "user").map((m) => m.content);
|
|
7786
|
-
if (userMessages.length === 0) {
|
|
7787
|
-
console.error(`[admin] manual-label: haiku failed for ${conversationId} \u2014 no user messages`);
|
|
7788
|
-
return c.json({ label: null });
|
|
7789
|
-
}
|
|
7790
|
-
const label = await generateSessionLabel(userMessages);
|
|
7791
|
-
if (label) {
|
|
7792
|
-
console.error(`[admin] manual-label: haiku suggested "${label}" for ${conversationId}`);
|
|
7793
|
-
} else {
|
|
7794
|
-
console.error(`[admin] manual-label: haiku failed for ${conversationId} \u2014 null response`);
|
|
7795
|
-
}
|
|
7796
|
-
return c.json({ label });
|
|
7797
|
-
} catch (err) {
|
|
7798
|
-
console.error(`[admin] manual-label: haiku failed for ${conversationId} \u2014 ${err instanceof Error ? err.message : String(err)}`);
|
|
7799
|
-
return c.json({ label: null });
|
|
7800
|
-
}
|
|
7801
|
-
});
|
|
7802
7783
|
app14.put("/:id/label", requireAdminSession, async (c) => {
|
|
7803
7784
|
const conversationId = c.req.param("id");
|
|
7804
7785
|
const cacheKey = c.var.cacheKey;
|
|
@@ -8129,54 +8110,32 @@ function managerBase2() {
|
|
|
8129
8110
|
return `http://127.0.0.1:${port2}`;
|
|
8130
8111
|
}
|
|
8131
8112
|
var app15 = new Hono();
|
|
8132
|
-
|
|
8133
|
-
app15.post("/", async (c) => {
|
|
8134
|
-
const routeStart = Date.now();
|
|
8135
|
-
const cacheKey = c.get("cacheKey") ?? "";
|
|
8136
|
-
const senderId = getAccountIdForSession(cacheKey) ?? "";
|
|
8137
|
-
if (!senderId) {
|
|
8138
|
-
console.error(`${TAG18} reject reason=no-account-id cacheKey-prefix=${cacheKey.slice(0, 8)}`);
|
|
8139
|
-
return c.json({ error: "admin-account-not-resolved" }, 500);
|
|
8140
|
-
}
|
|
8141
|
-
const userId = getUserIdForSession(cacheKey);
|
|
8142
|
-
let body = {};
|
|
8143
|
-
try {
|
|
8144
|
-
body = await c.req.json();
|
|
8145
|
-
} catch {
|
|
8146
|
-
}
|
|
8147
|
-
const channel = typeof body.channel === "string" ? body.channel : "browser";
|
|
8148
|
-
const initialMessage = typeof body.initialMessage === "string" && body.initialMessage.trim() ? body.initialMessage : null;
|
|
8149
|
-
const permissionMode = typeof body.permissionMode === "string" ? body.permissionMode : void 0;
|
|
8150
|
-
console.log(`${TAG18} spawn-request-in cacheKey-prefix=${cacheKey.slice(0, 8)} senderId=${senderId.slice(0, 8)} userId=${userId ? userId.slice(0, 8) : "absent"} channel=${channel} permissionMode=${permissionMode ?? "default"} initialMessage=${initialMessage ? "yes" : "no"}`);
|
|
8113
|
+
async function performSpawnWithInitialMessage(args) {
|
|
8151
8114
|
const ownerStart = Date.now();
|
|
8152
|
-
const aboutOwner = await resolveOwnerProfileBlock(senderId, userId);
|
|
8115
|
+
const aboutOwner = await resolveOwnerProfileBlock(args.senderId, args.userId);
|
|
8153
8116
|
const ownerMs = Date.now() - ownerStart;
|
|
8154
8117
|
const aboutOwnerStatus = aboutOwner == null ? "absent" : "ok" in aboutOwner && aboutOwner.ok === false ? `unresolved:${aboutOwner.reason}` : "ok";
|
|
8155
8118
|
console.log(`${TAG18} about-owner-resolved status=${aboutOwnerStatus} ms=${ownerMs}`);
|
|
8156
|
-
const
|
|
8157
|
-
const
|
|
8158
|
-
|
|
8159
|
-
const activeStart = Date.now();
|
|
8160
|
-
const activePlugins = computeActivePlugins(senderId);
|
|
8161
|
-
console.log(`${TAG18} active-plugins-computed count=${activePlugins.length} ms=${Date.now() - activeStart}`);
|
|
8162
|
-
const specStart = Date.now();
|
|
8163
|
-
const specialistDomains = computeSpecialistDomains(senderId);
|
|
8164
|
-
console.log(`${TAG18} specialist-domains-computed count=${specialistDomains.length} ms=${Date.now() - specStart}`);
|
|
8119
|
+
const dormantPlugins = computeDormantPlugins(args.senderId);
|
|
8120
|
+
const activePlugins = computeActivePlugins(args.senderId);
|
|
8121
|
+
const specialistDomains = computeSpecialistDomains(args.senderId);
|
|
8165
8122
|
const tunnelUrl = resolveTunnelUrl();
|
|
8166
8123
|
console.log(`${TAG18} tunnel-url-resolved value=${tunnelUrl ?? "null"}`);
|
|
8167
|
-
const forwardStart = Date.now();
|
|
8168
8124
|
const upstreamPayload = JSON.stringify({
|
|
8169
|
-
senderId,
|
|
8170
|
-
role:
|
|
8171
|
-
channel,
|
|
8172
|
-
permissionMode,
|
|
8125
|
+
senderId: args.senderId,
|
|
8126
|
+
role: args.role,
|
|
8127
|
+
channel: args.channel,
|
|
8128
|
+
permissionMode: args.permissionMode,
|
|
8129
|
+
hidden: args.hidden,
|
|
8130
|
+
specialist: args.specialist,
|
|
8173
8131
|
aboutOwner,
|
|
8174
8132
|
dormantPlugins,
|
|
8175
8133
|
activePlugins,
|
|
8176
8134
|
specialistDomains,
|
|
8177
8135
|
tunnelUrl
|
|
8178
8136
|
});
|
|
8179
|
-
console.log(`${TAG18} forward-spawn-start managerBase=${managerBase2()} bytes=${upstreamPayload.length}`);
|
|
8137
|
+
console.log(`${TAG18} forward-spawn-start managerBase=${managerBase2()} bytes=${upstreamPayload.length} hidden=${args.hidden} specialist=${args.specialist ?? "none"}`);
|
|
8138
|
+
const forwardStart = Date.now();
|
|
8180
8139
|
const upstream = await fetch(`${managerBase2()}/spawn`, {
|
|
8181
8140
|
method: "POST",
|
|
8182
8141
|
headers: { "content-type": "application/json" },
|
|
@@ -8185,25 +8144,89 @@ app15.post("/", async (c) => {
|
|
|
8185
8144
|
console.error(`${TAG18} fetch-failed op=spawn message=${err instanceof Error ? err.message : String(err)} ms=${Date.now() - forwardStart}`);
|
|
8186
8145
|
return null;
|
|
8187
8146
|
});
|
|
8188
|
-
if (!upstream) return
|
|
8189
|
-
console.log(`${TAG18} forward-spawn-done status=${upstream.status} ms=${Date.now() - forwardStart}
|
|
8147
|
+
if (!upstream) return new Response(JSON.stringify({ error: "manager-unreachable" }), { status: 503, headers: { "content-type": "application/json" } });
|
|
8148
|
+
console.log(`${TAG18} forward-spawn-done status=${upstream.status} ms=${Date.now() - forwardStart}`);
|
|
8190
8149
|
let spawnedSessionId = null;
|
|
8191
|
-
if (upstream.ok && initialMessage) {
|
|
8150
|
+
if (upstream.ok && args.initialMessage) {
|
|
8192
8151
|
const buffered = await upstream.clone().json().catch(() => null);
|
|
8193
8152
|
if (buffered && typeof buffered.sessionId === "string" && buffered.sessionId) {
|
|
8194
8153
|
spawnedSessionId = buffered.sessionId;
|
|
8195
8154
|
}
|
|
8196
8155
|
}
|
|
8197
|
-
if (initialMessage && spawnedSessionId) {
|
|
8198
|
-
|
|
8156
|
+
if (args.initialMessage && spawnedSessionId) {
|
|
8157
|
+
const inputBytes = Buffer.byteLength(args.initialMessage, "utf8");
|
|
8158
|
+
console.log(`${TAG18} initial-input-start sessionId=${spawnedSessionId.slice(0, 8)} bytes=${inputBytes}`);
|
|
8159
|
+
await fetch(`${managerBase2()}/${encodeURIComponent(spawnedSessionId)}/input`, {
|
|
8199
8160
|
method: "POST",
|
|
8200
8161
|
headers: { "content-type": "application/json" },
|
|
8201
|
-
body: JSON.stringify({ text: initialMessage })
|
|
8162
|
+
body: JSON.stringify({ text: args.initialMessage })
|
|
8202
8163
|
}).catch((err) => {
|
|
8203
8164
|
console.error(`${TAG18} fetch-failed op=initial-input message=${err instanceof Error ? err.message : String(err)}`);
|
|
8204
8165
|
});
|
|
8205
8166
|
}
|
|
8206
8167
|
return new Response(upstream.body, { status: upstream.status, headers: upstream.headers });
|
|
8168
|
+
}
|
|
8169
|
+
app15.post("/recorder-spawn", async (c) => {
|
|
8170
|
+
const remoteAddr = c.env?.incoming?.socket?.remoteAddress ?? "";
|
|
8171
|
+
const isLoopback = remoteAddr === "127.0.0.1" || remoteAddr === "::1" || remoteAddr === "::ffff:127.0.0.1";
|
|
8172
|
+
if (!isLoopback) {
|
|
8173
|
+
console.error(`${TAG18} recorder-spawn reject reason=non-loopback remoteAddr=${remoteAddr}`);
|
|
8174
|
+
return c.json({ error: "recorder-route-loopback-only" }, 403);
|
|
8175
|
+
}
|
|
8176
|
+
let body = {};
|
|
8177
|
+
try {
|
|
8178
|
+
body = await c.req.json();
|
|
8179
|
+
} catch {
|
|
8180
|
+
return c.json({ error: "body-not-json" }, 400);
|
|
8181
|
+
}
|
|
8182
|
+
if (body.senderId !== "turn-recorder") {
|
|
8183
|
+
return c.json({ error: "recorder-senderId-required" }, 400);
|
|
8184
|
+
}
|
|
8185
|
+
const specialist = typeof body.specialist === "string" && /^[A-Za-z0-9_-]{1,64}$/.test(body.specialist) ? body.specialist : void 0;
|
|
8186
|
+
const initialMessage = typeof body.initialMessage === "string" && body.initialMessage.length > 0 ? body.initialMessage : null;
|
|
8187
|
+
console.log(`${TAG18} recorder-spawn accept specialist=${specialist ?? "none"} initialMessageBytes=${initialMessage ? Buffer.byteLength(initialMessage, "utf8") : 0}`);
|
|
8188
|
+
return performSpawnWithInitialMessage({
|
|
8189
|
+
senderId: "turn-recorder",
|
|
8190
|
+
userId: void 0,
|
|
8191
|
+
role: "admin",
|
|
8192
|
+
channel: "browser",
|
|
8193
|
+
permissionMode: void 0,
|
|
8194
|
+
hidden: true,
|
|
8195
|
+
specialist,
|
|
8196
|
+
initialMessage
|
|
8197
|
+
});
|
|
8198
|
+
});
|
|
8199
|
+
app15.use("*", requireAdminSession);
|
|
8200
|
+
app15.post("/", async (c) => {
|
|
8201
|
+
const routeStart = Date.now();
|
|
8202
|
+
const cacheKey = c.get("cacheKey") ?? "";
|
|
8203
|
+
const senderId = getAccountIdForSession(cacheKey) ?? "";
|
|
8204
|
+
if (!senderId) {
|
|
8205
|
+
console.error(`${TAG18} reject reason=no-account-id cacheKey-prefix=${cacheKey.slice(0, 8)}`);
|
|
8206
|
+
return c.json({ error: "admin-account-not-resolved" }, 500);
|
|
8207
|
+
}
|
|
8208
|
+
const userId = getUserIdForSession(cacheKey);
|
|
8209
|
+
let body = {};
|
|
8210
|
+
try {
|
|
8211
|
+
body = await c.req.json();
|
|
8212
|
+
} catch {
|
|
8213
|
+
}
|
|
8214
|
+
const channel = typeof body.channel === "string" ? body.channel : "browser";
|
|
8215
|
+
const initialMessage = typeof body.initialMessage === "string" && body.initialMessage.trim() ? body.initialMessage : null;
|
|
8216
|
+
const permissionMode = typeof body.permissionMode === "string" ? body.permissionMode : void 0;
|
|
8217
|
+
console.log(`${TAG18} spawn-request-in cacheKey-prefix=${cacheKey.slice(0, 8)} senderId=${senderId.slice(0, 8)} userId=${userId ? userId.slice(0, 8) : "absent"} channel=${channel} permissionMode=${permissionMode ?? "default"} initialMessage=${initialMessage ? "yes" : "no"}`);
|
|
8218
|
+
const result = await performSpawnWithInitialMessage({
|
|
8219
|
+
senderId,
|
|
8220
|
+
userId: userId ?? void 0,
|
|
8221
|
+
role: "admin",
|
|
8222
|
+
channel,
|
|
8223
|
+
permissionMode,
|
|
8224
|
+
hidden: false,
|
|
8225
|
+
specialist: void 0,
|
|
8226
|
+
initialMessage
|
|
8227
|
+
});
|
|
8228
|
+
console.log(`${TAG18} route-done status=${result.status} route-ms=${Date.now() - routeStart}`);
|
|
8229
|
+
return result;
|
|
8207
8230
|
});
|
|
8208
8231
|
app15.get("/events", async (c) => {
|
|
8209
8232
|
const upstream = await fetch(`${managerBase2()}/events`, {
|
|
@@ -13527,7 +13550,7 @@ reconcileEnabledPlugins(bootAccount?.accountDir, bootAccount?.config);
|
|
|
13527
13550
|
(async () => {
|
|
13528
13551
|
if (!bootAccount) return;
|
|
13529
13552
|
try {
|
|
13530
|
-
const { recoverRunningCloudflareTasks } = await import("./cloudflare-task-tracker-
|
|
13553
|
+
const { recoverRunningCloudflareTasks } = await import("./cloudflare-task-tracker-TL6R364J.js");
|
|
13531
13554
|
const result = await recoverRunningCloudflareTasks(
|
|
13532
13555
|
bootAccount.accountId,
|
|
13533
13556
|
configDirForWhatsApp,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{it as e,rt as t}from"./chunk-ICPOFSXX-CT1d7veI.js";var n=(n,r)=>e.lang.round(t.parse(n)[r]);export{n as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as e}from"./src-CWiyyVfn.js";import"./chunk-ICPOFSXX-CT1d7veI.js";import"./dist-BzAsli7o.js";import"./chunk-5PVQY5BW-jvHIkgqP.js";import"./chunk-U2HBQHQK-RoGrqrH0.js";import"./chunk-FMBD7UC4-C_E43NFJ.js";import"./chunk-BSJP7CBP-L79XKVcb.js";import"./chunk-ZZ45TVLE-Dg59YYuG.js";import"./chunk-YZCP3GAM-Cyg122Hf.js";import"./chunk-55IACEB6-BwZyF7vR.js";import"./chunk-EDXVE4YY-7nDxvXHS.js";import"./chunk-X2U36JSP-D89ZBg3z.js";import"./chunk-5FUZZQ4R-B1B8871D.js";import"./chunk-ENJZ2VHE-C8lJ1YYn.js";import"./chunk-336JU56O-Cey0rxmH.js";import{i as t,n,r,t as i}from"./chunk-4TB4RGXK-C10nuKc8.js";var a={parser:n,get db(){return new i},renderer:r,styles:t,init:e(e=>{e.class||={},e.class.arrowMarkerAbsolute=e.arrowMarkerAbsolute},`init`)};export{a as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as e}from"./src-CWiyyVfn.js";import"./chunk-ICPOFSXX-CT1d7veI.js";import"./dist-BzAsli7o.js";import"./chunk-5PVQY5BW-jvHIkgqP.js";import"./chunk-U2HBQHQK-RoGrqrH0.js";import"./chunk-FMBD7UC4-C_E43NFJ.js";import"./chunk-BSJP7CBP-L79XKVcb.js";import"./chunk-ZZ45TVLE-Dg59YYuG.js";import"./chunk-YZCP3GAM-Cyg122Hf.js";import"./chunk-55IACEB6-BwZyF7vR.js";import"./chunk-EDXVE4YY-7nDxvXHS.js";import"./chunk-X2U36JSP-D89ZBg3z.js";import"./chunk-5FUZZQ4R-B1B8871D.js";import"./chunk-ENJZ2VHE-C8lJ1YYn.js";import"./chunk-336JU56O-Cey0rxmH.js";import{i as t,n,r,t as i}from"./chunk-4TB4RGXK-C10nuKc8.js";var a={parser:n,get db(){return new i},renderer:r,styles:t,init:e(e=>{e.class||={},e.class.arrowMarkerAbsolute=e.arrowMarkerAbsolute},`init`)};export{a as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./graphlib-BvR5tL62.js";var t=4;function n(n){return e(n,t)}export{n as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,p as t}from"./brand-Dln107gD.js";import"./graph-labels-CnbJR6cp.js";import{t as n}from"./page-nAY64ID7.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,p as t}from"./brand-Dln107gD.js";import"./graph-labels-CnbJR6cp.js";import{n}from"./page-DDyny08O.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-DD-I1_y5.js";import{a as t,c as n,d as r,f as i,h as a,l as o,o as s,r as c,s as l,t as u,u as d}from"./brand-Dln107gD.js";var f=i(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),p=i(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),m=i(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),h=i(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),g=i(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),_=i(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),v=i(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),y=i(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),ee=i(`menu`,[[`path`,{d:`M4 5h16`,key:`1tepv9`}],[`path`,{d:`M4 12h16`,key:`1lakjw`}],[`path`,{d:`M4 19h16`,key:`1djgab`}]]),te=i(`panel-right-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),b=i(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),x=i(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),S=i(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),C=i(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),w=i(`share-2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),T=i(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),E=i(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),D=i(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),ne=i(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),O=e(a(),1),k=s(),A=`maxy-shell-side-px`;function j(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function M(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-j());return Math.min(Math.max(e,248),n)}function re(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(A);if(!e)return 264;let t=parseInt(e,10);if(Number.isFinite(t)&&t>=248)return M(t)}catch{}return 264}function ie({targetSelector:e=`.platform`}){let t=(0,O.useRef)(null),[n,r]=(0,O.useState)(()=>re()),i=(0,O.useRef)(n);(0,O.useEffect)(()=>{let t=document.querySelector(e);!t||!(t instanceof HTMLElement)||(t.style.setProperty(`--side-px`,`${n}px`),i.current=n)},[n,e]);let a=(0,O.useCallback)(()=>{r(e=>{let t=M(e);return t===e?e:t})},[]);(0,O.useEffect)(()=>{a(),window.addEventListener(`resize`,a);let t=document.querySelector(e),n=null;return t instanceof HTMLElement&&(n=new MutationObserver(a),n.observe(t,{attributes:!0,attributeFilter:[`data-artefact`,`class`]})),()=>{window.removeEventListener(`resize`,a),n?.disconnect()}},[a,e]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(M(Math.round(e.clientX)))},s=()=>{if(n.releasePointerCapture(e.pointerId),n.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),!a)return;let t=i.current;try{window.localStorage.setItem(A,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=M(264);r(e);try{window.localStorage.removeItem(A)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,k.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}function N(e,t,n,r){let i=e===`pane`?`pane-action`:`sidebar-${t}`;console.info(`[admin-ui] ${i} sessionId=${n.slice(0,8)} action=${t} outcome=${r}`)}var P=/session_([A-Za-z0-9_-]+)/;function F(e){if(!e)return null;let t=e.match(P);return t?t[1]:null}async function I(e,t,n,r,i){let a=F(r)??`unknown`,o=e=>e.slice(0,8),s=t===`pane`?`pane-action action=resume-archive`:`sidebar-resume-archive`,c;try{let t=await fetch(`/api/admin/claude-sessions/${encodeURIComponent(n)}/archive?session_key=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({mode:`archive`})});c=t.ok?`ok`:t.status===409?`409`:`error`;let r=`[admin-ui] ${s} sourceSessionId=${o(n)} newSessionId=${o(a)} result=${c}`;c===`error`?console.error(r):console.info(r)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] ${s} sourceSessionId=${o(n)} newSessionId=${o(a)} result=error detail=${t}`)}finally{i.refetch()}}function ae(e,t,n=`pane`){let[r,i]=(0,O.useState)(null),a=(0,O.useCallback)(async r=>{if(!e)return{ok:!1,error:`no-cache-key`};i(`resume`);try{let i=await fetch(`/api/admin/claude-sessions/resume?session_key=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({claudeSessionId:r,channel:`browser`})}),a=await i.json();if(!i.ok||!(`sessionId`in a)){let e=a.error??`POST returned ${i.status}`;return N(n,`resume`,r,String(i.status)),{ok:!1,error:e}}return t.setSessions(e=>[a,...e.filter(e=>e.sessionId!==r)]),N(n,`resume`,r,`200`),I(e,n,r,a.url,t),{ok:!0}}catch(e){let i=e instanceof Error?e.message:String(e);return N(n,`resume`,r,`threw`),t.refetch(),{ok:!1,error:i}}finally{i(null)}},[e,t,n]),o=(0,O.useCallback)(async r=>{if(!e)return{ok:!1,error:`no-cache-key`};i(`end`);try{let i=await fetch(`/api/admin/claude-sessions/${encodeURIComponent(r)}/stop?session_key=${encodeURIComponent(e)}`,{method:`POST`});if(!i.ok){let e=await i.text().catch(()=>``);return N(n,`end`,r,String(i.status)),t.refetch(),{ok:!1,error:`POST /stop ${i.status} ${e.slice(0,200)}`}}return N(n,`end`,r,`204`),t.refetch(),{ok:!0}}catch(e){let i=e instanceof Error?e.message:String(e);return N(n,`end`,r,`threw`),t.refetch(),{ok:!1,error:i}}finally{i(null)}},[e,t,n]),s=(0,O.useCallback)(async r=>{if(!e)return{ok:!1,error:`no-cache-key`};i(`purge`);try{let i=await fetch(`/api/admin/claude-sessions/${encodeURIComponent(r)}?purge=1&session_key=${encodeURIComponent(e)}`,{method:`DELETE`});if(!i.ok){let e=await i.json().catch(()=>({})),t=e.detail||e.error||`DELETE ?purge=1 ${i.status}`;return N(n,`purge`,r,String(i.status)),{ok:!1,error:t}}return t.setSessions(e=>e.filter(e=>e.sessionId!==r)),N(n,`purge`,r,`200`),t.refetch(),{ok:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return N(n,`purge`,r,`threw`),{ok:!1,error:t}}finally{i(null)}},[e,t,n]),c=(0,O.useCallback)(async(r,a)=>{if(!e)return{ok:!1,error:`no-cache-key`};i(a);try{let i=await fetch(`/api/admin/claude-sessions/${encodeURIComponent(r)}/archive?session_key=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({mode:a})});if(!i.ok){let e=await i.json().catch(()=>({})),t=e.detail||e.error||`POST /archive ${i.status}`;return N(n,a,r,String(i.status)),{ok:!1,error:t}}return a===`archive`&&t.setSessions(e=>e.filter(e=>e.sessionId!==r)),t.refetch(),N(n,a,r,`200`),{ok:!0}}catch(e){let t=e instanceof Error?e.message:String(e);return N(n,a,r,`threw`),{ok:!1,error:t}}finally{i(null)}},[e,t,n]);return{inFlight:r,resume:a,end:o,purge:s,archive:(0,O.useCallback)(e=>c(e,`archive`),[c]),unarchive:(0,O.useCallback)(e=>c(e,`unarchive`),[c])}}function L(e){return`code.session.pinned.${e}`}function R(e){if(typeof window>`u`)return new Set;try{let t=window.localStorage.getItem(L(e));if(!t)return new Set;let n=JSON.parse(t);return Array.isArray(n)?new Set(n.filter(e=>typeof e==`string`)):new Set}catch{return new Set}}function z(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(L(e),JSON.stringify([...t]))}catch{}}function oe(e){let[t,n]=(0,O.useState)(()=>R(e));(0,O.useEffect)(()=>{n(R(e))},[e]);let r=(0,O.useCallback)(t=>{n(n=>{let r=new Set(n);return r.has(t)?r.delete(t):r.add(t),z(e,r),r})},[e]);return{pinned:t,isPinned:(0,O.useCallback)(e=>t.has(e),[t]),togglePin:r}}function se(e){let{businessName:t,cacheKey:n,conversationId:i,onLaunchBrowser:a,onNavigate:s,onToggleSidebar:d,sidebarOpen:f,onLogout:p,browserLaunching:_}=e,[x,S]=(0,O.useState)(!1),C=(0,O.useRef)(null),T=(0,O.useRef)(null),[E,D]=(0,O.useState)(null),[A,j]=(0,O.useState)(!1),[M,re]=(0,O.useState)(null),[ie,N]=(0,O.useState)(null),[P,F]=(0,O.useState)(null),[I,ae]=(0,O.useState)(``);(0,O.useEffect)(()=>{ae(window.location.hostname.startsWith(`admin.`)?window.location.origin.replace(`admin.`,`public.`):window.location.origin)},[]),(0,O.useEffect)(()=>{if(!x)return;let e=e=>{C.current&&!C.current.contains(e.target)&&S(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[x]),(0,O.useEffect)(()=>{if(!x)return;let e=e=>{e.key===`Escape`&&S(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[x]),(0,O.useEffect)(()=>{x&&T.current?.focus()},[x]),(0,O.useEffect)(()=>{if(!x)return;let e=!1;return fetch(`/api/admin/version`).then(e=>e.json()).then(t=>{e||F(t)}).catch(e=>{console.error(`[admin/version] menu-open client fetch failed:`,e)}),()=>{e=!0}},[x]);let L=(0,O.useCallback)(()=>{S(e=>{let t=!e;return t&&console.info(`[admin-ui] header-menu-open`),t})},[]),R=(0,O.useCallback)(()=>{S(!1),a()},[a]),z=(0,O.useCallback)(e=>{S(!1),s(e)},[s]),oe=(0,O.useCallback)(async()=>{if(E!==null){D(null),N(null);return}j(!0),re(null);try{let e=await fetch(`/api/admin/agents`);if(!e.ok)throw Error(`Failed to load agents`);D((await e.json()).agents??[])}catch(e){console.error(`[admin/agents] list failed:`,e),re(e instanceof Error?e.message:String(e)),D([])}finally{j(!1)}},[E]),se=(0,O.useCallback)(e=>{N(null),D(t=>t?.filter(t=>t.slug!==e)??null),fetch(`/api/admin/agents/${encodeURIComponent(e)}`,{method:`DELETE`}).catch(e=>console.error(`[admin/agents] delete failed:`,e))},[]),ce=(0,O.useCallback)(async()=>{if(S(!1),!n){console.warn(`[admin-ui] header-menu-report-turn cacheKey=null — skipping POST`);return}try{let e=await fetch(`/api/admin/failure-report`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionKey:n,conversationId:i??``,lastUserMessageId:``,lastAssistantMessageId:``,clickTs:new Date().toISOString(),clientSnapshot:{sseReadyState:``,lastEventType:``,lastAppliedMessageId:``}})});console.info(`[admin-ui] header-menu-report-turn ok=${e.ok} status=${e.status}`)}catch(e){console.error(`[admin-ui] header-menu-report-turn failed:`,e)}},[n,i]),B=(0,O.useCallback)(()=>{S(!1),p()},[p]),le=t||u.productName;return(0,k.jsxs)(`header`,{className:`admin-header`,children:[(0,k.jsx)(`button`,{type:`button`,className:`admin-sidebar-toggle`,"aria-label":f?`Hide sidebar`:`Show sidebar`,title:f?`Hide sidebar`:`Show sidebar`,"aria-expanded":f,onClick:d,children:f?(0,k.jsx)(te,{size:20}):(0,k.jsx)(b,{size:20})}),(0,k.jsxs)(`div`,{className:`chat-header-label`,children:[(0,k.jsx)(`span`,{className:`chat-logo-btn`,"aria-hidden":`true`,children:(0,k.jsx)(`img`,{src:c,alt:``,className:`chat-logo`})}),(0,k.jsx)(`h1`,{className:`chat-tagline`,children:le})]}),(0,k.jsxs)(`div`,{className:`chat-burger-wrap`,ref:C,children:[(0,k.jsx)(`button`,{type:`button`,className:`admin-burger`,onClick:L,"aria-label":`Menu`,"aria-haspopup":`true`,"aria-expanded":x,children:(0,k.jsx)(ee,{size:20})}),x&&(0,k.jsxs)(`div`,{className:`admin-menu`,role:`menu`,children:[(0,k.jsxs)(`button`,{ref:T,type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:R,disabled:_,children:[(0,k.jsx)(o,{size:14}),` Browser`,_&&(0,k.jsx)(v,{size:12,className:`spin`})]}),(0,k.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:()=>z(`data`),children:[(0,k.jsx)(m,{size:14}),` Data`]}),(0,k.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:()=>z(`graph`),children:[(0,k.jsx)(w,{size:14}),` Graph`]}),(0,k.jsx)(`div`,{className:`chat-menu-divider`}),(0,k.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:oe,children:[(0,k.jsx)(h,{size:14}),` Public`,A&&(0,k.jsx)(v,{size:12,className:`spin`})]}),E!==null&&(0,k.jsxs)(`div`,{className:`chat-menu-agents`,children:[M&&(0,k.jsx)(`span`,{className:`chat-menu-agent-error`,children:M}),E.length===0&&!M&&(0,k.jsx)(`span`,{className:`chat-menu-agent-empty`,children:`No public agents configured`}),E.map(e=>(0,k.jsxs)(`div`,{className:`chat-menu-item chat-menu-agent-item`,children:[(0,k.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),(0,k.jsxs)(`span`,{className:`agent-text`,children:[(0,k.jsx)(`span`,{className:`agent-display-name`,children:e.displayName}),(0,k.jsxs)(`span`,{className:`agent-slug`,children:[`/`,e.slug]})]}),ie===e.slug?(0,k.jsxs)(`span`,{className:`agent-actions agent-confirm`,children:[(0,k.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-yes`,title:`Confirm delete`,onClick:()=>se(e.slug),children:(0,k.jsx)(r,{size:12})}),(0,k.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-confirm-no`,title:`Cancel`,onClick:()=>N(null),children:(0,k.jsx)(ne,{size:12})})]}):(0,k.jsxs)(`span`,{className:`agent-actions`,children:[(0,k.jsx)(`a`,{href:`${I}/${e.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`agent-action-btn`,title:`Open agent`,onClick:()=>S(!1),children:(0,k.jsx)(h,{size:12})}),(0,k.jsx)(`button`,{type:`button`,className:`agent-action-btn agent-delete-btn`,title:`Delete agent`,onClick:()=>N(e.slug),children:(0,k.jsx)(l,{size:12})})]})]},e.slug))]}),(0,k.jsx)(`div`,{className:`chat-menu-divider`}),(0,k.jsxs)(`div`,{className:`chat-menu-version chat-menu-version-passive`,children:[(0,k.jsx)(g,{size:14}),(0,k.jsxs)(`span`,{className:`version-installed`,children:[P?`v${P.installed}`:`…`,P&&!P.updateAvailable&&(0,k.jsx)(`span`,{className:`version-uptodate-dot`}),P?.updateAvailable&&(0,k.jsx)(`span`,{className:`version-update-dot`})]})]}),(0,k.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,"data-testid":`report-turn`,onClick:ce,children:[(0,k.jsx)(g,{size:14}),` Report this turn`]}),(0,k.jsxs)(`button`,{type:`button`,className:`chat-menu-item`,role:`menuitem`,onClick:B,children:[(0,k.jsx)(y,{size:14}),` Log out`]})]})]})]})}var ce=`maxy-admin-session`,B=typeof BroadcastChannel<`u`;function le(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.type===`rotation`&&typeof t.newKey==`string`&&t.newKey.length>0&&(t.surface===`chat`||t.surface===`graph`||t.surface===`data`||t.surface===`sessions`)&&typeof t.ts==`number`}function V(e){if(!B)return()=>{};let t=new BroadcastChannel(ce),n=t=>{if(!le(t.data)){console.warn(`[admin-session-broadcast] outcome=received-malformed payload=${JSON.stringify(t.data)}`);return}e(t.data)};return t.addEventListener(`message`,n),()=>{t.removeEventListener(`message`,n),t.close()}}var ue=`maxy-admin-session-key`;function H(e,t){return`${e}${e.includes(`?`)?`&`:`?`}session_key=${encodeURIComponent(t)}`}async function U(e){let t;try{t=await e.clone().json()}catch{return`parse-failed`}if(typeof t!=`object`||!t)return`unknown-401`;let n=t.code;return n===`session-missing`||n===`session-not-registered`||n===`session-expired-age`||n===`grant-expired`?n:`unknown-401`}function de(){try{return sessionStorage.getItem(ue)}catch{return null}}function fe(e){let{initialCacheKey:t,surface:n}=e,[r,i]=(0,O.useState)(t),a=(0,O.useRef)(t);(0,O.useEffect)(()=>{a.current=r},[r]),(0,O.useEffect)(()=>{t!==a.current&&(i(t),a.current=t,s(e=>e+1))},[t]);let[o,s]=(0,O.useState)(0),[c,l]=(0,O.useState)(null);(0,O.useEffect)(()=>V(e=>{let t=a.current.slice(0,8),r=e.newKey.slice(0,8);e.newKey!==a.current&&(console.log(`[admin-session-broadcast] outcome=received oldKey=${t} newKey=${r} surface=${n} senderSurface=${e.surface}`),i(e.newKey),s(e=>e+1),l(null))}),[n]);let u=(0,O.useCallback)(()=>{try{sessionStorage.removeItem(ue)}catch{}window.location.href=`/`},[]);return{adminFetch:(0,O.useCallback)(async(e,t)=>{let r=a.current,o=H(e,r),c=await fetch(o,t);if(c.status!==401)return c;let d=await U(c);if(d===`session-missing`)return console.warn(`[useAdminFetch] outcome=redirect-to-login reason=${d} surface=${n} path=${e}`),u(),c;if(d!==`session-not-registered`)return console.warn(`[useAdminFetch] outcome=redirect-to-login reason=${d} surface=${n} path=${e}`),l({message:`Your admin session has expired. Click to reload and sign in.`,reason:d}),c;let f=de();if(!f||f===r)return console.warn(`[useAdminFetch] outcome=redirect-to-login reason=session-not-registered-no-fresh-key surface=${n} path=${e}`),l({message:`Your admin session was renewed in another tab. Click to reload.`,reason:`session-not-registered`}),c;i(f),a.current=f,s(e=>e+1),console.log(`[useAdminFetch] outcome=retry-after-rotation oldKey=${r.slice(0,8)} newKey=${f.slice(0,8)} surface=${n} path=${e}`);let p=H(e,f),m=await fetch(p,t);return m.status===401&&(console.warn(`[useAdminFetch] outcome=redirect-to-login reason=second-401-after-retry surface=${n} path=${e}`),l({message:`Your admin session has expired. Click to reload and sign in.`,reason:`session-not-registered`})),m},[u,n]),cacheKey:r,sessionRefetchNonce:o,banner:c,reloadToLogin:u}}var pe=`/api/admin/claude-sessions/events`,W=`admin-session-list-view`,G=`admin-session-list-include-subagents`,K=`admin-session-list-include-background`;function me(e){return e===`active`||e===`archived`||e===`all`}function q(){let e={rows:[],view:`active`,includeBackground:!1,connected:!1},t=new Map,n=new Set,r=null,i=null,a=0,o=0,s=null,c=!1,l=!1;function u(){let n=[...t.values()].sort((e,t)=>t.updatedAt===e.updatedAt?e.sessionId<t.sessionId?-1:1:t.updatedAt-e.updatedAt);e={...e,rows:n}}function d(){for(let e of n)e()}function f(e,n){if(e===`row-removed`){let e=n?.sessionId;if(typeof e!=`string`||!t.delete(e))return;u(),d();return}let r=n;if(typeof r.sessionId!=`string`)return;let i={sessionId:r.sessionId,live:r.live===!0,status:r.status===`busy`?`busy`:r.status===`idle`?`idle`:`gone`,agentLabel:typeof r.agentLabel==`string`&&r.agentLabel.length>0?r.agentLabel:null,bridgeSessionId:typeof r.bridgeSessionId==`string`?r.bridgeSessionId:null,cwd:typeof r.cwd==`string`?r.cwd:null,firstPrompt:typeof r.firstPrompt==`string`?r.firstPrompt:r.sessionId.slice(0,8),updatedAt:typeof r.updatedAt==`number`?r.updatedAt:0};t.set(i.sessionId,i),u(),d()}function p(t){if(r&&s===t||(r&&=(r.close(),null),!t))return;s=t,c=!1,l=!1;let n=H(pe,t);try{r=new EventSource(n)}catch(e){console.error(`[admin-ui] session-row-store EventSource construct failed:`,e),h(`auto`);return}r.addEventListener(`open`,()=>{c=!0,a=0,e={...e,connected:!0},d(),console.info(`[admin-ui] session-row-store connected events-received=${o}`)});for(let e of[`row-created`,`row-updated`,`row-archived`,`row-removed`])r.addEventListener(e,t=>{o+=1;try{f(e,JSON.parse(t.data))}catch(t){console.error(`[admin-ui] session-row-store parse failed kind=${e}:`,t)}});r.addEventListener(`error`,()=>{r&&=(r.close(),null),e={...e,connected:!1},d(),!c&&!l&&(l=!0,m(n)),h(`auto`)})}async function m(e){let t=a+1,n=0,r=`unknown`;try{let t=await fetch(e,{method:`GET`});n=t.status,r=t.status>=400&&t.status<500?await U(t):`unknown`}catch(e){console.error(`[admin-ui] session-row-store sse-error-probe-failed:`,e);return}console.error(`[admin-ui] session-row-store sse-error status=${n} code=${r} attempt=${t}`)}function h(e){if(i)return;a+=1;let t=Math.min(1e3*2**Math.min(a,5),3e4);console.info(`[admin-ui] session-row-store reconnect trigger=${e} attempt=${a} delay-ms=${t}`),i=setTimeout(()=>{i=null,s&&p(s)},t)}function g(){i&&=(clearTimeout(i),null),a=0,r&&=(r.close(),null),console.info(`[admin-ui] session-row-store reconnect trigger=manual attempt=0 delay-ms=0`),s&&p(s)}function _(){if(!(typeof window>`u`))try{let t=window.localStorage.getItem(W);me(t)&&(e={...e,view:t});let n=window.localStorage.getItem(G);if(n===null){let e=window.localStorage.getItem(K);e!==null&&(window.localStorage.setItem(G,e),window.localStorage.removeItem(K),n=e,console.info(`[admin-ui] session-list-storage-migrated from=${K} to=${G} value=${e}`))}n===`1`&&(e={...e,includeBackground:!0})}catch{}}function v(t){e={...e,view:t};try{window.localStorage.setItem(W,t)}catch{}d()}function y(t){e={...e,includeBackground:t};try{window.localStorage.setItem(G,t?`1`:`0`)}catch{}d()}function ee(e){return n.add(e),()=>{n.delete(e)}}function te(){return e}function b(){r&&=(r.close(),null),i&&=(clearTimeout(i),null),s=null,e={...e,connected:!1}}function x(e,t){f(e,t)}function S(t){e={...e,connected:t},d()}function C(){t.clear(),u(),d()}function w(e){let n=new Set(e),r=0;for(let e of[...t.keys()])n.has(e)||(t.delete(e),r+=1);r!==0&&(console.info(`[admin-ui] session-row-store reconcile evicted=${r} kept=${t.size}`),u(),d())}return _(),{subscribe:ee,getSnapshot:te,connect:p,disconnect:b,setView:v,setIncludeBackground:y,reconnectNow:g,reconcileFromList:w,_injectEventForTesting:x,_setConnectedForTesting:S,_clearRowsForTesting:C}}var J=q();J._injectEventForTesting,J.connect,J._setConnectedForTesting,J.getSnapshot,J.reconcileFromList;function he(e){let t=(0,O.useSyncExternalStore)(J.subscribe,J.getSnapshot,J.getSnapshot);(0,O.useEffect)(()=>{e&&J.connect(e)},[e]);let n=(0,O.useCallback)(e=>J.setView(e),[]),r=(0,O.useCallback)(e=>J.setIncludeBackground(e),[]),i=(0,O.useCallback)(()=>J.reconnectNow(),[]),a=(0,O.useCallback)(e=>J.reconcileFromList(e),[]);return{rows:t.rows,view:t.view,includeBackground:t.includeBackground,connected:t.connected,setView:n,setIncludeBackground:r,reconnectNow:i,reconcileFromList:a}}function ge(e,t,n){return e.filter(e=>!(t===`active`&&!e.live||t===`archived`&&e.live||!n&&e.agentLabel!==null&&e.agentLabel!==`admin`))}var Y=(0,O.forwardRef)(function(e,t){let{businessName:i,cacheKey:a,role:o,userName:s,userAvatar:c,sessions:m,sessionsLoading:g,sessionsError:y,ensureSessionsLoaded:ee,refetchSessions:te,onSelectArtefact:b,onSelectProjects:C,onSelectPeople:w,onSelectTasks:ne,onSelectAgents:A,onCloseMobileDrawer:j,onSelectSession:M,selectedSessionId:re,collapsed:ie,mobileDrawerOpen:N,recentsActions:P}=e,[F,I]=(0,O.useState)(null),[L,R]=(0,O.useState)(null),[z,se]=(0,O.useState)(!1);(0,O.useEffect)(()=>{ee()},[ee]);let ce=(0,O.useRef)(null),[B,le]=(0,O.useState)(!1),[V,ue]=(0,O.useState)(`default`),[H,U]=(0,O.useState)(null),de=u.productName,fe=typeof s==`string`?s:s===null?`name unavailable`:i||de,pe=(fe.trim().charAt(0)||`?`).toUpperCase(),W=oe(u.hostname),G=he(a),K=(0,O.useMemo)(()=>{let e=ge(G.rows,G.view,G.includeBackground);if(W.pinned.size===0)return e;let t=[],n=[];for(let r of e)(W.pinned.has(r.sessionId)?t:n).push(r);return[...t,...n]},[G.rows,G.view,G.includeBackground,W.pinned]),me=K.length,[q,J]=(0,O.useState)(`chat`),[Y,_e]=(0,O.useState)([]),[xe,Se]=(0,O.useState)(!1),[Ce,we]=(0,O.useState)(null),[Te,Ee]=(0,O.useState)(!1);(0,O.useImperativeHandle)(t,()=>({patchArtefact(e,t){_e(n=>n.map(n=>n.id===e?{...n,...t}:n))}}),[]);let[X,De]=(0,O.useState)(!1),Oe=(0,O.useRef)(null);(0,O.useEffect)(()=>{if(!X)return;function e(e){Oe.current&&!Oe.current.contains(e.target)&&(console.info(`[admin-ui] sidebar-mode-picker action=close mode=${V}`),De(!1))}function t(e){e.key===`Escape`&&(console.info(`[admin-ui] sidebar-mode-picker action=close mode=${V}`),De(!1))}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[X,V]);let ke={default:`Ask`,acceptEdits:`Accept edits`,plan:`Plan`,auto:`Auto`},Ae=[`default`,`acceptEdits`,`plan`,`auto`],Z=(0,O.useCallback)(async()=>{if(a){Ee(!0),we(null);try{let e=await fetch(`/api/admin/sidebar-artefacts?session_key=${encodeURIComponent(a)}`);if(!e.ok)throw Error(`status ${e.status}`);_e((await e.json()).artefacts??[]),Se(!0)}catch(e){let t=e instanceof Error?e.message:String(e);we(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{Ee(!1)}}},[a]),je=()=>{J(`chat`),console.info(`[admin-ui] sidebar-nav surface=sessions count=${me}`)},Me=()=>{J(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${xe?Y.length:0} collapsed=${ie}`),xe||Z()},Q=ie?24:16,Ne=q===`chat`?`Sessions`:`Artefacts`,Pe=q===`chat`?g?`…`:String(me):Te?`…`:String(Y.length),Fe=q===`chat`?g:Te,Ie=()=>{console.info(`[admin-ui] sidebar-refresh surface=${q}`),q===`chat`?te().then(e=>{e!==null&&G.reconcileFromList(e.map(e=>e.sessionId))}):Z()},Le=(0,O.useCallback)(async()=>{if(B||!a){console.info(`[admin-ui] sidebar-new-session-click-ignored startingSession=${B} cacheKey=${a?`set`:`missing`}`);return}let e=Date.now();console.info(`[admin-ui] sidebar-new-session-click permissionMode=${V} cacheKey-prefix=${a.slice(0,8)}`),le(!0),U(null);try{let t=new Date().toISOString();console.info(`[admin-ui] sidebar-new-session-fetch-start permissionMode=${V} initialMessage=${t}`);let n=await fetch(`/api/admin/claude-sessions?session_key=${encodeURIComponent(a)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({channel:`browser`,permissionMode:V,initialMessage:t})}),r=Date.now()-e;console.info(`[admin-ui] sidebar-new-session-fetch-done status=${n.status} ok=${n.ok} ms=${r}`);let i=await n.json();if(!n.ok||!(`sessionId`in i)){let t=i,r=t.error??`POST returned ${n.status}`,a=t.reason?`${r}: ${t.reason}`:r;console.error(`[admin-ui] sidebar-new-session-failed status=${n.status} ms=${Date.now()-e} error=${r} reason=${t.reason??`none`} tail=${JSON.stringify(t.stderrTail??``)}`),U(a);return}console.info(`[admin-ui] sidebar-new-session-ok pid=${i.pid} sessionId=${i.sessionId.slice(0,8)} permissionMode=${V} ms=${Date.now()-e}`),P.setSessions(e=>[i,...e])}catch(t){let n=t instanceof Error?t.message:String(t);U(n),console.error(`[admin-ui] sidebar-new-session-threw ms=${Date.now()-e} message=${n}`)}finally{le(!1)}},[a,B,P,V]),$=ae(a,P,`sidebar`),Re=(0,O.useCallback)(async e=>{let t=await $.resume(e);t.ok||console.error(`[admin-ui] sidebar-resume failed: ${t.error}`)},[$]),ze=(0,O.useCallback)(async e=>{se(!0),R(null);let t=await $.purge(e);t.ok?I(null):R(t.error??`purge failed`),se(!1)},[$]),Be=(0,O.useCallback)(async e=>{let t=await $.end(e);t.ok||console.error(`[admin-ui] sidebar-end-session failed: ${t.error}`)},[$]);return(0,k.jsxs)(`aside`,{className:`side`,children:[q===`chat`&&(0,k.jsxs)(`div`,{className:`side-new-session-row`,ref:Oe,children:[(0,k.jsxs)(`button`,{type:`button`,className:`side-new-session`,onClick:()=>void Le(),disabled:B||!a,children:[B?(0,k.jsx)(v,{size:14,className:`spinning`}):(0,k.jsx)(x,{size:14}),(0,k.jsx)(`span`,{children:`New session`})]}),(0,k.jsx)(`button`,{type:`button`,className:`side-mode-trigger`,onClick:()=>{let e=!X;console.info(`[admin-ui] sidebar-mode-picker action=${e?`open`:`close`} mode=${V}`),De(e)},disabled:B,"aria-haspopup":`menu`,"aria-expanded":X,"aria-label":`Permission mode for the next session`,children:ke[V]}),X&&(0,k.jsxs)(`div`,{className:`side-mode-popover`,role:`menu`,"aria-label":`Mode`,children:[(0,k.jsx)(`div`,{className:`side-mode-popover-head`,children:`Mode`}),Ae.map(e=>(0,k.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`side-mode-popover-item`,onClick:()=>{console.info(`[admin-ui] sidebar-mode-picker action=select mode=${e}`),ue(e),De(!1)},children:[(0,k.jsx)(`span`,{children:ke[e]}),e===V&&(0,k.jsx)(r,{size:12})]},e))]})]}),(0,k.jsxs)(`nav`,{className:`side-nav`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`nav-row${q===`chat`?` active`:``}`,onClick:je,children:[(0,k.jsx)(E,{size:Q}),(0,k.jsx)(`span`,{className:`label`,children:`Sessions`}),(0,k.jsx)(`span`,{className:`kbd`})]}),(0,k.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),w(),j()},children:[(0,k.jsx)(D,{size:Q}),(0,k.jsx)(`span`,{className:`label`,children:`People`}),(0,k.jsx)(`span`,{className:`kbd`})]}),(0,k.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),A(),j()},children:[(0,k.jsx)(f,{size:Q}),(0,k.jsx)(`span`,{className:`label`,children:`Agents`}),(0,k.jsx)(`span`,{className:`kbd`})]}),(0,k.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),C(),j()},children:[(0,k.jsx)(p,{size:Q}),(0,k.jsx)(`span`,{className:`label`,children:`Projects`}),(0,k.jsx)(`span`,{className:`kbd`})]}),(0,k.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),ne(),j()},children:[(0,k.jsx)(_,{size:Q}),(0,k.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,k.jsx)(`span`,{className:`kbd`})]}),(0,k.jsxs)(`button`,{type:`button`,className:`nav-row${q===`artefacts`?` active`:``}`,onClick:Me,children:[(0,k.jsx)(d,{size:Q}),(0,k.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,k.jsx)(`span`,{className:`kbd`})]})]}),(0,k.jsxs)(`div`,{className:`side-list`,ref:ce,children:[(0,k.jsxs)(`div`,{className:`group-head`,children:[(0,k.jsx)(`span`,{children:Ne}),(0,k.jsxs)(`span`,{className:`group-head-meta`,children:[(0,k.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh ${Ne.toLowerCase()}`,"aria-label":`Refresh ${Ne.toLowerCase()}`,onClick:Ie,disabled:Fe,children:(0,k.jsx)(S,{size:12,className:Fe?`spinning`:void 0})}),(0,k.jsx)(`span`,{children:Pe})]})]}),H&&q===`chat`&&(0,k.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:H}),q===`chat`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(ve,{view:G.view,setView:e=>{console.info(`[admin-ui] sidebar-view-change view=${e}`),G.setView(e)},includeBackground:G.includeBackground,setIncludeBackground:e=>{console.info(`[admin-ui] sidebar-background-toggle include=${e}`),G.setIncludeBackground(e)},connected:G.connected,reconnectNow:G.reconnectNow}),y&&(0,k.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:y}),K.map(e=>{let t=re===e.sessionId,r=e.agentLabel??`admin`;return(0,k.jsxs)(`div`,{className:`conv${t?` active`:``}`,children:[(0,k.jsxs)(`button`,{type:`button`,className:`conv-name-button`,onClick:()=>{M(e.sessionId),j()},title:`Show metadata`,children:[(0,k.jsx)(E,{size:12,className:`conv-channel-icon`,"aria-label":`claude session`}),(0,k.jsx)(ye,{live:e.live,status:e.status}),(0,k.jsx)(`span`,{className:`conv-name`,children:e.firstPrompt}),(0,k.jsx)(`span`,{className:`conv-agent-badge`,"data-kind":e.agentLabel?`specialist`:`admin`,children:r})]}),e.live?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`conversations-action`,title:`Open in new tab`,"aria-label":`Open in new tab`,onClick:()=>void be(e.sessionId,a),children:(0,k.jsx)(h,{size:13})}),(0,k.jsx)(`button`,{type:`button`,className:`conversations-action`,title:`End session`,"aria-label":`End session`,onClick:()=>void Be(e.sessionId),children:(0,k.jsx)(T,{size:13})})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`conversations-action`,title:`Resume session`,"aria-label":`Resume session`,onClick:()=>void Re(e.sessionId),children:(0,k.jsx)(n,{size:13})}),(0,k.jsx)(`button`,{type:`button`,className:`conversations-action`,title:`Purge JSONL`,"aria-label":`Purge JSONL`,onClick:()=>{R(null),I({sessionId:e.sessionId,displayName:e.firstPrompt})},children:(0,k.jsx)(l,{size:13})})]})]},e.sessionId)})]}),q===`artefacts`&&(0,k.jsxs)(k.Fragment,{children:[Ce&&(0,k.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:Ce}),xe&&!Ce&&Y.length===0&&(0,k.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),Y.map(e=>(0,k.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>{b({docId:e.id,name:e.name,content:e.content,editable:e.editable,mimeType:e.mimeType,skipReason:e.skipReason},`sidebar-artefacts`),j()},children:[(0,k.jsx)(`span`,{className:`conv-name`,children:e.name}),(0,k.jsx)(`span`,{className:`conv-kind`,"data-kind":e.kind===`agent-template`?`agent`:`doc`,children:e.kind===`agent-template`?`agent`:`doc`})]},e.id))]})]}),(0,k.jsxs)(`div`,{className:`side-foot`,children:[(0,k.jsx)(`div`,{className:`avatar`,children:c?(0,k.jsx)(`img`,{src:c,alt:fe}):pe}),(0,k.jsxs)(`div`,{className:`who`,children:[(0,k.jsx)(`span`,{className:`name`,children:fe}),(0,k.jsx)(`span`,{className:`role`,children:o??`operator`})]})]}),F&&(0,k.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`purge-confirm-title`,className:`modal-overlay`,onClick:e=>{e.target===e.currentTarget&&!z&&I(null)},children:(0,k.jsxs)(`div`,{className:`modal-card`,children:[(0,k.jsx)(`h3`,{id:`purge-confirm-title`,style:{margin:0,marginBottom:8,fontSize:16,fontWeight:600},children:`Purge session JSONL?`}),(0,k.jsxs)(`p`,{style:{margin:0,marginBottom:8,fontSize:13},children:[`This hard-deletes the transcript and sidecar for `,(0,k.jsx)(`strong`,{children:F.displayName}),`. The action cannot be undone.`]}),L&&(0,k.jsx)(`p`,{style:{margin:0,marginBottom:8,fontSize:12,color:`var(--text-tertiary)`},children:L}),(0,k.jsxs)(`div`,{className:`modal-action-row`,children:[(0,k.jsx)(`button`,{type:`button`,className:`modal-action-btn`,disabled:z,onClick:()=>I(null),children:`Cancel`}),(0,k.jsx)(`button`,{type:`button`,className:`modal-action-btn`,"data-variant":`danger`,disabled:z,onClick:()=>void ze(F.sessionId),children:z?(0,k.jsx)(v,{size:13,className:`spinning`}):`Purge`})]})]})})]})}),_e=[{value:`active`,label:`Active`},{value:`archived`,label:`Archived`},{value:`all`,label:`All`}];function ve(e){let{view:n,setView:r,includeBackground:i,setIncludeBackground:a,connected:o,reconnectNow:s}=e;return(0,k.jsxs)(`div`,{className:`session-view-controls`,children:[(0,k.jsx)(t,{checked:i,onChange:a,label:`Include subagents`}),(0,k.jsxs)(`div`,{className:`session-view-segmented`,role:`tablist`,"aria-label":`Session view`,children:[_e.map(e=>(0,k.jsx)(`button`,{type:`button`,role:`tab`,className:`session-view-tab${n===e.value?` active`:``}`,"aria-selected":n===e.value,onClick:()=>r(e.value),children:e.label},e.value)),o?(0,k.jsx)(`span`,{className:`session-view-connection connected`,"aria-label":`Live updates connected.`,title:`Live updates connected.`}):(0,k.jsx)(`button`,{type:`button`,className:`session-view-connection disconnected`,"aria-label":`Live updates paused. Click to retry.`,title:`Live updates paused. Click to retry.`,onClick:s})]})]})}function ye({live:e,status:t}){return e?t===`busy`?(0,k.jsxs)(`span`,{className:`session-status session-status-busy`,"aria-label":`session busy`,children:[(0,k.jsx)(`span`,{className:`session-status-dot`}),(0,k.jsx)(`span`,{className:`session-status-dot`}),(0,k.jsx)(`span`,{className:`session-status-dot`})]}):(0,k.jsx)(`span`,{className:`session-status session-status-idle`,"aria-label":`session idle`}):(0,k.jsx)(`span`,{className:`session-status session-status-archived`,"aria-label":`session archived`})}async function be(e,t){if(t){console.info(`[admin-ui] sidebar-open-session sessionId=${e.slice(0,8)}`);try{let n=await fetch(`/api/admin/claude-sessions/${encodeURIComponent(e)}/meta?session_key=${encodeURIComponent(t)}`);if(!n.ok){console.error(`[admin-ui] sidebar-open-session-meta-failed sessionId=${e.slice(0,8)} status=${n.status}`);return}let r=await n.json();r.url&&window.open(r.url,`_blank`,`noopener,noreferrer`)}catch(t){console.error(`[admin-ui] sidebar-open-session-meta-threw sessionId=${e.slice(0,8)} message=${t instanceof Error?t.message:String(t)}`)}}}function xe(e){return e.map(e=>[e.sessionId,e.claudeSessionId,e.displayName,e.lastMessageAt,e.status])}function Se(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r[0]!==i[0]||r[1]!==i[1]||r[2]!==i[2]||r[3]!==i[3]||r[4]!==i[4])return!1}return!0}function Ce(e){let[t,n]=(0,O.useState)([]),[r,i]=(0,O.useState)(!1),[a,o]=(0,O.useState)(null),[s,c]=(0,O.useState)(null),l=(0,O.useRef)([]),u=(0,O.useCallback)(async t=>{if(!e||!t&&s===e)return null;i(!0),o(null);try{let t=await fetch(`/api/admin/claude-sessions?session_key=${encodeURIComponent(e)}`);if(!t.ok)throw Error(`claude-sessions fetch returned ${t.status}`);let r=await t.json(),i=Array.isArray(r)?r:r.sessions??[],a=xe(i),o=Se(l.current,a);return o||(n(i),l.current=a),c(e),console.info(`[admin-ui] sessions-poll outcome=${o?`unchanged`:`changed`} count=${i.length} cacheKey=${e.slice(0,8)}`),i}catch(t){return console.info(`[admin-ui] sessions-poll outcome=error count=0 cacheKey=${e.slice(0,8)}`),console.error(`[admin/claude-sessions] fetch failed:`,t),o(t instanceof Error?t.message:String(t)),null}finally{i(!1)}},[e,s]);(0,O.useEffect)(()=>{e||(c(null),n([]),o(null),l.current=[])},[e]);let d=(0,O.useCallback)(()=>u(!1),[u]),f=(0,O.useCallback)(()=>u(!0),[u]);return{sessions:t,setSessions:n,loading:r,loaded:s!==null&&s===e,error:a,ensureLoaded:d,refetch:f}}var we=`admin-sidebar-collapsed`,Te=`admin-sidebar-drawer-open`;function Ee(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(we)===`1`}catch{return!1}}function X(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(we,`1`):window.sessionStorage.removeItem(we)}catch{}}function De(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Te)===`1`}catch{return!1}}function Oe(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Te,`1`):window.sessionStorage.removeItem(Te)}catch{}}var ke=720;function Ae(e){let{cacheKey:t,businessName:n,conversationId:r,onLaunchBrowser:i,onLogout:a,browserLaunching:o=!1,userName:s,userAvatar:c,role:l,selectedSessionId:u,onSelectSession:d,onSelectArtefact:f,dataArtefact:p=`closed`,children:m,footer:h}=e,[g,_]=(0,O.useState)(()=>Ee()),[v,y]=(0,O.useState)(()=>De()),[ee,te]=(0,O.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: ${ke}px)`).matches);(0,O.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: ${ke}px)`),t=e=>te(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let b=(0,O.useCallback)(e=>{X(e),_(e)},[]),x=(0,O.useCallback)(e=>{Oe(e),y(e)},[]);(0,O.useEffect)(()=>{if(typeof window>`u`)return;let e=window.location?.pathname??``;console.info(`[admin-ui] shell-mount route=${e} collapsed=${g} drawer=${v}`)},[]);let S=ee?v:!g,C=(0,O.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${ke}px)`).matches){let e=v;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),x(!e)}else{let e=g;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),b(!e)}},[g,v,b,x]),w=(0,O.useCallback)(e=>{console.info(`[admin-ui] header-menu-nav target=${e}`),window.location.href=e===`data`?`/data`:`/graph`},[]),T=(0,O.useCallback)(()=>{},[]),E=Ce(t),D=(0,O.useCallback)(e=>{if(d){d(e);return}window.location.assign(`/?sessionId=${encodeURIComponent(e)}`)},[d]),ne=(0,O.useCallback)(e=>{f&&f(e)},[f]),A={collapsed:g,mobileDrawerOpen:v,sidebarOpen:S,onToggleSidebar:C,setMobileDrawerOpen:x,sessionsState:E};return(0,k.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,k.jsx)(se,{businessName:n,cacheKey:t,conversationId:r,onLaunchBrowser:i??T,onNavigate:w,onToggleSidebar:C,sidebarOpen:S,onLogout:a,browserLaunching:o}),(0,k.jsxs)(`div`,{className:`platform${v?` menu-open`:``}${g?` sidebar-collapsed`:``}`,"data-artefact":p,children:[(0,k.jsx)(Y,{businessName:n,cacheKey:t,role:l??null,userName:s,userAvatar:c??null,sessions:E.sessions,sessionsLoading:E.loading,sessionsError:E.error,ensureSessionsLoaded:E.ensureLoaded,refetchSessions:E.refetch,onSelectArtefact:ne,onSelectProjects:()=>{window.location.href=`/graph?label=Project`},onSelectPeople:()=>{window.location.href=`/graph?label=Person`},onSelectTasks:()=>{window.location.href=`/graph?label=Task`},onSelectAgents:()=>{window.location.href=`/graph?label=Agent`},onCloseMobileDrawer:()=>x(!1),onSelectSession:D,selectedSessionId:u??null,collapsed:g,mobileDrawerOpen:v,recentsActions:{setSessions:E.setSessions,refetch:E.refetch}}),typeof m==`function`?m(A):m]}),v&&(0,k.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>x(!1)}),h]})}var Z={LocalBusiness:`#4F6B8A`,Service:`#6B85A0`,PriceSpecification:`#8AA0B8`,OpeningHoursSpecification:`#A8BACE`,Organization:`#8A6B47`,Person:`#B86E4A`,UserProfile:`#D08960`,Preference:`#DFA67A`,AdminUser:`#8C5230`,AccessGrant:`#66381F`,KnowledgeDocument:`#6E8A5A`,ConversationArchive:`#82A06A`,Section:`#8AA876`,Chunk:`#A6C194`,DigitalDocument:`#5A7548`,CreativeWork:`#B5C9A2`,Question:`#C7D6B5`,FAQPage:`#95B385`,DefinedTerm:`#76906A`,Review:`#3F5A2E`,ImageObject:`#A0BB8C`,Conversation:`#6B5A85`,AdminConversation:`#4F4070`,PublicConversation:`#8A75A8`,Message:`#6B7280`,UserMessage:`#DFA67A`,AssistantMessage:`#C9A876`,ToolCall:`#B5ABCB`,Task:`#B0617A`,Project:`#8E4A60`,Event:`#C68095`,Workflow:`#3A6F77`,WorkflowStep:`#5A8E96`,WorkflowRun:`#7AAAB2`,StepResult:`#9CC4CB`,Email:`#6F7F4A`,EmailAccount:`#91A063`,Agent:`#B8893D`},je=`#94A3B8`;Object.freeze(Object.keys(Z)),Object.freeze(new Set([`Chunk`,`GraphPreference`]));var Me=Object.freeze(new Set(`LocalBusiness.Service.PriceSpecification.OpeningHoursSpecification.Organization.Person.UserProfile.Preference.AdminUser.AccessGrant.KnowledgeDocument.DigitalDocument.CreativeWork.Question.FAQPage.DefinedTerm.Review.ImageObject.AdminConversation.PublicConversation.Task.Project.Event.Workflow.Email.EmailAccount.Agent`.split(`.`)));Object.freeze(new Set([`ToolCall`,`StepResult`,`WorkflowStep`,`WorkflowRun`])),Object.freeze(new Set([`HAS_TOOL_CALL`,`RUN_OF`,`HAS_STEP`,`HAS_RESULT`]));function Q(e){for(let t=1;t<e.length;t++)if(Object.prototype.hasOwnProperty.call(Z,e[t]))return e[t];return e[0]??null}function Ne(e){return Z[e]??`#94A3B8`}function Pe(e){let t=Q(e),n=t?Ne(t):je,r=0;for(let t=1;t<e.length;t++)Object.prototype.hasOwnProperty.call(Z,e[t])&&r++;return{displayLabel:t,colour:n,driftCandidates:r}}export{h as _,Ae as a,ae as c,T as d,w as f,v as g,x as h,Pe as i,ie as l,S as m,Ne as n,fe as o,C as p,Q as r,oe as s,Me as t,ne as u,m as v};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as e}from"./src-CWiyyVfn.js";import"./chunk-ICPOFSXX-CT1d7veI.js";import"./dist-BzAsli7o.js";import"./chunk-5PVQY5BW-jvHIkgqP.js";import"./chunk-U2HBQHQK-RoGrqrH0.js";import"./chunk-BSJP7CBP-L79XKVcb.js";import"./chunk-ZZ45TVLE-Dg59YYuG.js";import"./chunk-55IACEB6-BwZyF7vR.js";import"./chunk-EDXVE4YY-7nDxvXHS.js";import"./chunk-X2U36JSP-D89ZBg3z.js";import"./chunk-5FUZZQ4R-B1B8871D.js";import"./chunk-ENJZ2VHE-C8lJ1YYn.js";import"./chunk-336JU56O-Cey0rxmH.js";import{i as t,n,r,t as i}from"./chunk-OYMX7WX6-LTAfwxv0.js";var a={parser:n,get db(){return new i(2)},renderer:r,styles:t,init:e(e=>{e.state||={},e.state.arrowMarkerAbsolute=e.arrowMarkerAbsolute},`init`)};export{a as diagram};
|
|
File without changes
|