@rubytech/create-maxy 1.0.677 → 1.0.678

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.
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-CCUSwZB_.js","assets/preload-helper-qlgyTAkD.js","assets/dist-CrzV1W3-.js","assets/chunk-DD-I1_y5.js","assets/chunk-U2HBQHQK-BZnA7c4T.js","assets/src-Bo15iQ7w.js","assets/chunk-5PVQY5BW-RhIfPCRB.js","assets/chunk-ICPOFSXX-Di63NBur.js","assets/_baseFor-Dn4GSmI6.js","assets/isEmpty-h-wRi_o9.js","assets/chunk-336JU56O-BpATJiGl.js","assets/chunk-5FUZZQ4R-BoTfWHuW.js","assets/chunk-X2U36JSP-DpQ2OA_c.js","assets/chunk-ZZ45TVLE-DBSm41oP.js","assets/rough.esm-NLRoWnq-.js","assets/chunk-ENJZ2VHE-CNHjq5xK.js","assets/line-DlKKhwkO.js","assets/path-7vUsG-o2.js","assets/array-DJN9YAVf.js","assets/chunk-BSJP7CBP-CTsYuARh.js","assets/chunk-426QAEUC-Wz6Bpsil.js","assets/chunk-XPW4576I-BccP1mlQ.js"])))=>i.map(i=>d[i]);
2
- import{o as e,r as t,t as n}from"./chunk-DD-I1_y5.js";import{n as r,o as i,r as a,t as o}from"./jsx-runtime-C_VUlXvu.js";import{t as s}from"./preload-helper-qlgyTAkD.js";var c=a(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),l=a(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),u=a(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),d=a(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),f=a(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),p=a(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),m=a(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),h=a(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),g=a(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),_=a(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),v=a(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),y=a(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),b=e(i(),1);async function x(e){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function S(){let[e,t]=(0,b.useState)(!1),[n,r]=(0,b.useState)(new Set),[i,a]=(0,b.useState)(!1),o=(0,b.useRef)(null);(0,b.useEffect)(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]);let s=(0,b.useCallback)(()=>{t(!0),r(new Set)},[]),c=(0,b.useCallback)(()=>{t(!1),r(new Set)},[]),l=(0,b.useCallback)(e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),u=(0,b.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null)},[]),d=(0,b.useCallback)(e=>({onPointerDown:()=>{o.current=setTimeout(()=>{t(!0),r(new Set([e])),o.current=null},500)},onPointerUp:u,onPointerLeave:u,onPointerCancel:u}),[u]),f=(0,b.useCallback)(e=>{a(e?`copied`:`failed`),setTimeout(()=>a(!1),1500)},[]);return{selectionMode:e,selectedItems:n,copyToast:i,longPressProps:d,enterSelection:s,exitSelection:c,toggleSelectItem:l,copySelected:(0,b.useCallback)(async(e,t)=>{let r=[...n].sort(t).map(t=>e(t)).filter(Boolean);r.length>0&&f(await x(r.join(`
2
+ import{o as e,r as t,t as n}from"./chunk-DD-I1_y5.js";import{n as r,o as i,r as a,t as o}from"./jsx-runtime-BVKWELH6.js";import{t as s}from"./preload-helper-qlgyTAkD.js";var c=a(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),l=a(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),u=a(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),d=a(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),f=a(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),p=a(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),m=a(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),h=a(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),g=a(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),_=a(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),v=a(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),y=a(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),b=e(i(),1);async function x(e){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function S(){let[e,t]=(0,b.useState)(!1),[n,r]=(0,b.useState)(new Set),[i,a]=(0,b.useState)(!1),o=(0,b.useRef)(null);(0,b.useEffect)(()=>()=>{o.current!==null&&clearTimeout(o.current)},[]);let s=(0,b.useCallback)(()=>{t(!0),r(new Set)},[]),c=(0,b.useCallback)(()=>{t(!1),r(new Set)},[]),l=(0,b.useCallback)(e=>{r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),u=(0,b.useCallback)(()=>{o.current!==null&&(clearTimeout(o.current),o.current=null)},[]),d=(0,b.useCallback)(e=>({onPointerDown:()=>{o.current=setTimeout(()=>{t(!0),r(new Set([e])),o.current=null},500)},onPointerUp:u,onPointerLeave:u,onPointerCancel:u}),[u]),f=(0,b.useCallback)(e=>{a(e?`copied`:`failed`),setTimeout(()=>a(!1),1500)},[]);return{selectionMode:e,selectedItems:n,copyToast:i,longPressProps:d,enterSelection:s,exitSelection:c,toggleSelectItem:l,copySelected:(0,b.useCallback)(async(e,t)=>{let r=[...n].sort(t).map(t=>e(t)).filter(Boolean);r.length>0&&f(await x(r.join(`
3
3
 
4
4
  ---
5
5
 
@@ -1 +1 @@
1
- import{r as e}from"./jsx-runtime-C_VUlXvu.js";var t=e(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),n=e(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);export{t as n,n as t};
1
+ import{r as e}from"./jsx-runtime-BVKWELH6.js";var t=e(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),n=e(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);export{t as n,n as t};
@@ -5,13 +5,13 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Data — Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/data-DVlvxbTt.js"></script>
8
+ <script type="module" crossorigin src="/assets/data-DUSyrydY.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
10
- <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-C_VUlXvu.js">
11
- <link rel="modulepreload" crossorigin href="/assets/share-2-RSIR3MmX.js">
12
- <link rel="modulepreload" crossorigin href="/assets/file-OY_hX2wu.js">
13
- <link rel="modulepreload" crossorigin href="/assets/house-CgENfOCP.js">
14
- <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-Bu4vXoe7.css">
10
+ <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-BVKWELH6.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/share-2-DBcb9j6E.js">
12
+ <link rel="modulepreload" crossorigin href="/assets/file-CDJ6dUV3.js">
13
+ <link rel="modulepreload" crossorigin href="/assets/house-CNP_bwvT.js">
14
+ <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-BFFQvkdQ.css">
15
15
  </head>
16
16
  <body>
17
17
  <div id="root"></div>
@@ -5,13 +5,13 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Graph — Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/graph-BDaM4Qer.js"></script>
8
+ <script type="module" crossorigin src="/assets/graph-CWcYp5bE.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
10
- <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-C_VUlXvu.js">
11
- <link rel="modulepreload" crossorigin href="/assets/share-2-RSIR3MmX.js">
12
- <link rel="modulepreload" crossorigin href="/assets/house-CgENfOCP.js">
13
- <link rel="modulepreload" crossorigin href="/assets/x-DKZ5NR3n.js">
14
- <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-Bu4vXoe7.css">
10
+ <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-BVKWELH6.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/share-2-DBcb9j6E.js">
12
+ <link rel="modulepreload" crossorigin href="/assets/house-CNP_bwvT.js">
13
+ <link rel="modulepreload" crossorigin href="/assets/x-CTVJaC_u.js">
14
+ <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-BFFQvkdQ.css">
15
15
  </head>
16
16
  <body>
17
17
  <div id="root"></div>
@@ -5,15 +5,15 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/admin-DQmUdTBa.js"></script>
8
+ <script type="module" crossorigin src="/assets/admin-BBL1no_g.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
10
- <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-C_VUlXvu.js">
10
+ <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-BVKWELH6.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-qlgyTAkD.js">
12
- <link rel="modulepreload" crossorigin href="/assets/useVoiceRecorder-B0FI_hts.js">
13
- <link rel="modulepreload" crossorigin href="/assets/share-2-RSIR3MmX.js">
14
- <link rel="modulepreload" crossorigin href="/assets/file-OY_hX2wu.js">
15
- <link rel="modulepreload" crossorigin href="/assets/x-DKZ5NR3n.js">
16
- <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-Bu4vXoe7.css">
12
+ <link rel="modulepreload" crossorigin href="/assets/useVoiceRecorder-CtSgpc95.js">
13
+ <link rel="modulepreload" crossorigin href="/assets/share-2-DBcb9j6E.js">
14
+ <link rel="modulepreload" crossorigin href="/assets/file-CDJ6dUV3.js">
15
+ <link rel="modulepreload" crossorigin href="/assets/x-CTVJaC_u.js">
16
+ <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-BFFQvkdQ.css">
17
17
  <link rel="stylesheet" href="/brand-defaults.css">
18
18
  </head>
19
19
  <body>
@@ -5,12 +5,12 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/public-Clp4VPwo.js"></script>
8
+ <script type="module" crossorigin src="/assets/public-sHoAccvb.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-DD-I1_y5.js">
10
- <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-C_VUlXvu.js">
10
+ <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-BVKWELH6.js">
11
11
  <link rel="modulepreload" crossorigin href="/assets/preload-helper-qlgyTAkD.js">
12
- <link rel="modulepreload" crossorigin href="/assets/useVoiceRecorder-B0FI_hts.js">
13
- <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-Bu4vXoe7.css">
12
+ <link rel="modulepreload" crossorigin href="/assets/useVoiceRecorder-CtSgpc95.js">
13
+ <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-BFFQvkdQ.css">
14
14
  <link rel="stylesheet" href="/brand-defaults.css">
15
15
  </head>
16
16
  <body>
@@ -7168,8 +7168,75 @@ function clearSessionHistory(sessionKey) {
7168
7168
  session.stalledSubagents = void 0;
7169
7169
  session.pendingTrimmedMessages = void 0;
7170
7170
  session.pendingCommitmentOffers = void 0;
7171
+ session.pendingTurns = void 0;
7171
7172
  return previousConversationId;
7172
7173
  }
7174
+ function bufferPendingTurn(sessionKey, turn) {
7175
+ const session = sessionStore.get(sessionKey);
7176
+ if (!session) {
7177
+ console.error(`[conversation-gate] bufferPendingTurn: session not found sessionKey=${sessionKey.slice(0, 8)}\u2026`);
7178
+ return;
7179
+ }
7180
+ if (!session.pendingTurns) session.pendingTurns = [];
7181
+ session.pendingTurns.push(turn);
7182
+ console.log(`[conversation-gate] ${(/* @__PURE__ */ new Date()).toISOString()} buffered sessionKey=${sessionKey.slice(0, 8)} role=${turn.role} turnCount=${session.pendingTurns.filter((t) => t.role === "user").length}`);
7183
+ }
7184
+ function getPendingTurnCount(sessionKey) {
7185
+ const buf = sessionStore.get(sessionKey)?.pendingTurns;
7186
+ if (!buf) return 0;
7187
+ let n = 0;
7188
+ for (const t of buf) if (t.role === "user") n++;
7189
+ return n;
7190
+ }
7191
+ function drainPendingTurns(sessionKey) {
7192
+ const session = sessionStore.get(sessionKey);
7193
+ if (!session?.pendingTurns || session.pendingTurns.length === 0) return void 0;
7194
+ const drained = session.pendingTurns;
7195
+ session.pendingTurns = void 0;
7196
+ return drained;
7197
+ }
7198
+ async function maybeFlushConversationBuffer(sessionKey, agentType, accountId) {
7199
+ const session = sessionStore.get(sessionKey);
7200
+ if (!session) return null;
7201
+ if (session.conversationId) return session.conversationId;
7202
+ if (getPendingTurnCount(sessionKey) < 2) return null;
7203
+ if (session.flushInFlight) return session.flushInFlight;
7204
+ const attempt = (async () => {
7205
+ let conversationId = null;
7206
+ if (agentType === "admin") {
7207
+ const userId = session.userId;
7208
+ if (!userId) {
7209
+ console.error(`[conversation-gate] flush aborted: admin session missing userId sessionKey=${sessionKey.slice(0, 8)}\u2026`);
7210
+ return null;
7211
+ }
7212
+ conversationId = await createNewAdminConversation(userId, accountId, sessionKey);
7213
+ } else {
7214
+ conversationId = await ensureConversation(accountId, "public", sessionKey, void 0, void 0, void 0);
7215
+ }
7216
+ if (!conversationId) return null;
7217
+ session.conversationId = conversationId;
7218
+ const buffered = drainPendingTurns(sessionKey) ?? [];
7219
+ for (const turn of buffered) {
7220
+ persistMessage(conversationId, turn.role, turn.content, accountId, turn.tokens, turn.timestamp, turn.sender).catch((err) => {
7221
+ console.error(`[conversation-gate] replay persistMessage failed role=${turn.role}: ${err instanceof Error ? err.message : String(err)}`);
7222
+ });
7223
+ }
7224
+ console.log(`[conversation-gate] ${(/* @__PURE__ */ new Date()).toISOString()} flushed sessionKey=${sessionKey.slice(0, 8)} conversationId=${conversationId.slice(0, 8)} bufferedMessages=${buffered.length} agentType=${agentType}`);
7225
+ return conversationId;
7226
+ })();
7227
+ session.flushInFlight = attempt;
7228
+ try {
7229
+ return await attempt;
7230
+ } finally {
7231
+ if (session.flushInFlight === attempt) session.flushInFlight = void 0;
7232
+ }
7233
+ }
7234
+ function isDmChannelSessionKey(sessionKey) {
7235
+ return sessionKey.startsWith("whatsapp:") || sessionKey.startsWith("telegram:");
7236
+ }
7237
+ function preflushStreamLogKey(sessionKey) {
7238
+ return `preflush-${sessionKey.slice(0, 12)}`;
7239
+ }
7173
7240
  function getAgentNameForSession(sessionKey) {
7174
7241
  return sessionStore.get(sessionKey)?.agentName;
7175
7242
  }
@@ -9062,20 +9129,24 @@ async function* invokeAdminAgent(message, systemPrompt, accountDir, accountId, a
9062
9129
  const userTimestamp = clientTimestamp ?? (/* @__PURE__ */ new Date()).toISOString();
9063
9130
  const resumeSessionId = sessionKey ? getAgentSessionId(sessionKey) : void 0;
9064
9131
  const spawnConvId = sessionKey ? getConversationIdForSession(sessionKey) : void 0;
9065
- if (!spawnConvId) {
9066
- throw new Error(`invokeAdminAgent: conversationId missing for sessionKey=${sessionKey?.slice(0, 8) ?? "none"} \u2014 ensureConversation must run before invoking the agent`);
9132
+ if (!spawnConvId && sessionKey && getPendingTurnCount(sessionKey) >= 2) {
9133
+ throw new Error(`invokeAdminAgent: conversationId missing post-flush for sessionKey=${sessionKey.slice(0, 8)} \u2014 maybeFlushConversationBuffer must bind it before invoking the agent`);
9134
+ }
9135
+ const spawnLogKey = spawnConvId ?? (sessionKey ? preflushStreamLogKey(sessionKey) : void 0);
9136
+ if (!spawnLogKey) {
9137
+ throw new Error(`invokeAdminAgent: sessionKey required \u2014 cannot resolve log stream without one`);
9067
9138
  }
9068
9139
  const cdpOk = await ensureCdp();
9069
9140
  if (!cdpOk) {
9070
- const cdpLog = agentLogStream("claude-agent-stream", accountDir, spawnConvId);
9141
+ const cdpLog = agentLogStream("claude-agent-stream", accountDir, spawnLogKey);
9071
9142
  cdpLog.write(`[${isoTs()}] [warn] ensureCdp failed \u2014 browser-specialist degraded
9072
9143
  `);
9073
9144
  cdpLog.end();
9074
9145
  }
9075
9146
  const ccUserId = sessionKey ? getUserIdForSession(sessionKey) : void 0;
9076
- const mcpConfig = JSON.stringify({ mcpServers: getMcpServers(accountId, spawnConvId, ccUserId, enabledPlugins) });
9147
+ const mcpConfig = JSON.stringify({ mcpServers: getMcpServers(accountId, spawnLogKey, ccUserId, enabledPlugins) });
9077
9148
  const specialistsDir = resolve5(accountDir, "specialists");
9078
- if (!existsSync5(specialistsDir)) agentLogStream("claude-agent-stream", accountDir, spawnConvId).write(`[${isoTs()}] [warn] specialists plugin dir missing: ${specialistsDir}
9149
+ if (!existsSync5(specialistsDir)) agentLogStream("claude-agent-stream", accountDir, spawnLogKey).write(`[${isoTs()}] [warn] specialists plugin dir missing: ${specialistsDir}
9079
9150
  `);
9080
9151
  const args = [
9081
9152
  "--print",
@@ -9106,19 +9177,19 @@ async function* invokeAdminAgent(message, systemPrompt, accountDir, accountId, a
9106
9177
  cwd: accountDir,
9107
9178
  stdio: ["ignore", "pipe", "pipe"],
9108
9179
  // Task 556: STREAM_LOG_PATH inherited by Bash-tool subprocesses.
9109
- env: buildSpawnEnv(accountId, accountDir, spawnConvId)
9180
+ env: buildSpawnEnv(accountId, accountDir, spawnLogKey)
9110
9181
  });
9111
- const stderrLog = agentLogStream("claude-agent-stderr", accountDir, spawnConvId);
9182
+ const stderrLog = agentLogStream("claude-agent-stderr", accountDir, spawnLogKey);
9112
9183
  stderrLog.on("error", () => {
9113
9184
  });
9114
9185
  proc.stderr?.pipe(stderrLog);
9115
- const streamLog = agentLogStream("claude-agent-stream", accountDir, spawnConvId);
9186
+ const streamLog = agentLogStream("claude-agent-stream", accountDir, spawnLogKey);
9116
9187
  streamLog.on("error", () => {
9117
9188
  });
9118
9189
  teeProcStderrToStreamLog(proc, streamLog);
9119
9190
  streamLog.write(`[${isoTs()}] [subproc-debug-unavailable] reason=bundled-bun-binary-ignores-node-debug pid=${proc.pid} cli=claude
9120
9191
  `);
9121
- streamLog.write(`[${isoTs()}] [spawn-env] STREAM_LOG_PATH=set pid=${proc.pid} conversationId=${spawnConvId} site=admin
9192
+ streamLog.write(`[${isoTs()}] [spawn-env] STREAM_LOG_PATH=set pid=${proc.pid} conversationId=${spawnConvId ?? "preflush"} logKey=${spawnLogKey} site=admin
9122
9193
  `);
9123
9194
  if (sessionKey) {
9124
9195
  const prev = activeProcesses.get(sessionKey);
@@ -9128,7 +9199,7 @@ async function* invokeAdminAgent(message, systemPrompt, accountDir, accountId, a
9128
9199
  }
9129
9200
  activeProcesses.set(sessionKey, { pid: proc.pid, spawnedAt: Date.now() });
9130
9201
  }
9131
- streamLog.write(`[${isoTs()}] [spawn] pid=${proc.pid} resume=${resumeSessionId ?? "none"} sessionKey=${sessionKey ?? "none"} conversationId=${spawnConvId} pluginDir=${specialistsDir}
9202
+ streamLog.write(`[${isoTs()}] [spawn] pid=${proc.pid} resume=${resumeSessionId ?? "none"} sessionKey=${sessionKey ?? "none"} conversationId=${spawnConvId ?? "preflush"} logKey=${spawnLogKey} pluginDir=${specialistsDir}
9132
9203
  `);
9133
9204
  streamLog.write(`[${isoTs()}] [stdin] len=${fullMessage.length} preview=${JSON.stringify(fullMessage.slice(0, 80))}
9134
9205
  `);
@@ -9200,7 +9271,7 @@ async function* invokeAdminAgent(message, systemPrompt, accountDir, accountId, a
9200
9271
  }
9201
9272
  if (event.type === "usage" && sessionKey && currentAgentSessionId) {
9202
9273
  const peakReqPct = event.peak_request_pct ?? 0;
9203
- if (peakReqPct >= COMPACTION_THRESHOLD) {
9274
+ if (peakReqPct >= COMPACTION_THRESHOLD && spawnConvId) {
9204
9275
  const compactionIter = runCompactionTurn(accountDir, accountId, systemPrompt, currentAgentSessionId, adminModel, spawnConvId, enabledPlugins);
9205
9276
  let step = await compactionIter.next();
9206
9277
  while (!step.done) {
@@ -9310,9 +9381,9 @@ async function* invokeAdminAgent(message, systemPrompt, accountDir, accountId, a
9310
9381
  } else {
9311
9382
  gotDone = true;
9312
9383
  if (!sessionWasReset) {
9384
+ const assistantTimestamp = (/* @__PURE__ */ new Date()).toISOString();
9313
9385
  const convId = sessionKey ? sessionStore.get(sessionKey)?.conversationId : void 0;
9314
9386
  if (convId) {
9315
- const assistantTimestamp = (/* @__PURE__ */ new Date()).toISOString();
9316
9387
  persistMessage(convId, "user", fullMessage, accountId, void 0, userTimestamp).catch(() => {
9317
9388
  });
9318
9389
  autoLabelSession(convId, fullMessage).catch(() => {
@@ -9320,7 +9391,14 @@ async function* invokeAdminAgent(message, systemPrompt, accountDir, accountId, a
9320
9391
  if (responseText) persistMessage(convId, "assistant", responseText, accountId, capturedTokens, assistantTimestamp).catch(() => {
9321
9392
  });
9322
9393
  } else if (sessionKey) {
9323
- console.warn(`[persist] skipped: no conversationId for sessionKey=${sessionKey.slice(0, 12)}\u2026 (session registered=${sessionStore.has(sessionKey)})`);
9394
+ bufferPendingTurn(sessionKey, { role: "user", content: fullMessage, timestamp: userTimestamp });
9395
+ if (responseText) bufferPendingTurn(sessionKey, { role: "assistant", content: responseText, timestamp: assistantTimestamp, tokens: capturedTokens });
9396
+ const flushedId = await maybeFlushConversationBuffer(sessionKey, "admin", accountId);
9397
+ if (flushedId) {
9398
+ autoLabelSession(flushedId, fullMessage).catch(() => {
9399
+ });
9400
+ yield { type: "conversation_attributed", conversationId: flushedId };
9401
+ }
9324
9402
  }
9325
9403
  if (sessionKey) {
9326
9404
  const commitSession = sessionStore.get(sessionKey);
@@ -9383,9 +9461,10 @@ ${summary}`;
9383
9461
  async function* invokeManagedAdminAgent(message, systemPrompt, accountDir, accountId, adminModel, sessionKey, maxTurns = 20, attachments = [], retryCount = 0, enabledPlugins, clientTimestamp, adherenceConstraints, agentName) {
9384
9462
  const userTimestamp = clientTimestamp ?? (/* @__PURE__ */ new Date()).toISOString();
9385
9463
  const managedConvId = getConversationIdForSession(sessionKey);
9386
- if (!managedConvId) {
9387
- throw new Error(`invokeManagedAdminAgent: conversationId missing for sessionKey=${sessionKey.slice(0, 8)} \u2014 ensureConversation must run first`);
9464
+ if (!managedConvId && getPendingTurnCount(sessionKey) >= 2) {
9465
+ throw new Error(`invokeManagedAdminAgent: conversationId missing post-flush for sessionKey=${sessionKey.slice(0, 8)} \u2014 maybeFlushConversationBuffer must bind it first`);
9388
9466
  }
9467
+ const managedLogKey = managedConvId ?? preflushStreamLogKey(sessionKey);
9389
9468
  const pendingTrimmed = consumePendingTrimmedMessages(sessionKey);
9390
9469
  if (pendingTrimmed && pendingTrimmed.length > 0) {
9391
9470
  const ok = await compactTrimmedMessages(accountId, pendingTrimmed);
@@ -9393,7 +9472,7 @@ async function* invokeManagedAdminAgent(message, systemPrompt, accountDir, accou
9393
9472
  storePendingTrimmedMessages(sessionKey, pendingTrimmed);
9394
9473
  }
9395
9474
  }
9396
- const streamLog = agentLogStream("claude-agent-stream", accountDir, managedConvId);
9475
+ const streamLog = agentLogStream("claude-agent-stream", accountDir, managedLogKey);
9397
9476
  streamLog.on("error", () => {
9398
9477
  });
9399
9478
  const systemPromptTokens = estimateTokens(systemPrompt);
@@ -9424,7 +9503,7 @@ async function* invokeManagedAdminAgent(message, systemPrompt, accountDir, accou
9424
9503
  if (!cdpOk) streamLog.write(`[${isoTs()}] [warn] ensureCdp failed \u2014 browser-specialist degraded
9425
9504
  `);
9426
9505
  const managedUserId = getUserIdForSession(sessionKey);
9427
- const mcpConfig = JSON.stringify({ mcpServers: getMcpServers(accountId, managedConvId, managedUserId, enabledPlugins) });
9506
+ const mcpConfig = JSON.stringify({ mcpServers: getMcpServers(accountId, managedLogKey, managedUserId, enabledPlugins) });
9428
9507
  const specialistsDir = resolve5(accountDir, "specialists");
9429
9508
  if (!existsSync5(specialistsDir)) streamLog.write(`[${isoTs()}] [warn] specialists plugin dir missing: ${specialistsDir}
9430
9509
  `);
@@ -9455,16 +9534,16 @@ async function* invokeManagedAdminAgent(message, systemPrompt, accountDir, accou
9455
9534
  cwd: accountDir,
9456
9535
  stdio: ["ignore", "pipe", "pipe"],
9457
9536
  // Task 556: STREAM_LOG_PATH inherited by Bash-tool subprocesses.
9458
- env: buildSpawnEnv(accountId, accountDir, managedConvId)
9537
+ env: buildSpawnEnv(accountId, accountDir, managedLogKey)
9459
9538
  });
9460
- const stderrLog = agentLogStream("claude-agent-stderr", accountDir, managedConvId);
9539
+ const stderrLog = agentLogStream("claude-agent-stderr", accountDir, managedLogKey);
9461
9540
  stderrLog.on("error", () => {
9462
9541
  });
9463
9542
  proc.stderr?.pipe(stderrLog);
9464
9543
  teeProcStderrToStreamLog(proc, streamLog);
9465
9544
  streamLog.write(`[${isoTs()}] [subproc-debug-unavailable] reason=bundled-bun-binary-ignores-node-debug pid=${proc.pid} cli=claude
9466
9545
  `);
9467
- streamLog.write(`[${isoTs()}] [spawn-env] STREAM_LOG_PATH=set pid=${proc.pid} conversationId=${managedConvId} site=managed
9546
+ streamLog.write(`[${isoTs()}] [spawn-env] STREAM_LOG_PATH=set pid=${proc.pid} conversationId=${managedConvId ?? "preflush"} logKey=${managedLogKey} site=managed
9468
9547
  `);
9469
9548
  if (sessionKey) {
9470
9549
  const prev = activeProcesses.get(sessionKey);
@@ -9474,13 +9553,13 @@ async function* invokeManagedAdminAgent(message, systemPrompt, accountDir, accou
9474
9553
  }
9475
9554
  activeProcesses.set(sessionKey, { pid: proc.pid, spawnedAt: Date.now() });
9476
9555
  }
9477
- streamLog.write(`[${isoTs()}] [managed-spawn] pid=${proc.pid} sessionKey=${sessionKey} conversationId=${managedConvId} historyMessages=${history.length} pluginDir=${specialistsDir}
9556
+ streamLog.write(`[${isoTs()}] [managed-spawn] pid=${proc.pid} sessionKey=${sessionKey} conversationId=${managedConvId ?? "preflush"} logKey=${managedLogKey} historyMessages=${history.length} pluginDir=${specialistsDir}
9478
9557
  `);
9479
9558
  streamLog.write(`[${isoTs()}] [stdin] len=${fullMessage.length} preview=${JSON.stringify(fullMessage.slice(0, 80))}
9480
9559
  `);
9481
9560
  proc.on("exit", (code, signal) => {
9482
- console.log(`[process-exit] pid=${proc.pid} code=${code} signal=${signal} sessionKey=${sessionKey ?? "none"} conversationId=${managedConvId}`);
9483
- if (!streamLog.destroyed && !streamLog.writableEnded) streamLog.write(`[${isoTs()}] [process-exit] pid=${proc.pid} code=${code} signal=${signal} conversationId=${managedConvId}
9561
+ console.log(`[process-exit] pid=${proc.pid} code=${code} signal=${signal} sessionKey=${sessionKey ?? "none"} conversationId=${managedConvId ?? "preflush"}`);
9562
+ if (!streamLog.destroyed && !streamLog.writableEnded) streamLog.write(`[${isoTs()}] [process-exit] pid=${proc.pid} code=${code} signal=${signal} conversationId=${managedConvId ?? "preflush"}
9484
9563
  `);
9485
9564
  if (sessionKey) activeProcesses.delete(sessionKey);
9486
9565
  });
@@ -9630,17 +9709,24 @@ async function* invokeManagedAdminAgent(message, systemPrompt, accountDir, accou
9630
9709
  `);
9631
9710
  const successSession = sessionStore.get(sessionKey);
9632
9711
  if (successSession) successSession.lastPeakContextPct = peakContextPct;
9712
+ const assistantTimestamp = (/* @__PURE__ */ new Date()).toISOString();
9633
9713
  const convId = sessionStore.get(sessionKey)?.conversationId;
9634
9714
  if (convId) {
9635
- const assistantTimestamp = (/* @__PURE__ */ new Date()).toISOString();
9636
9715
  persistMessage(convId, "user", fullMessage, accountId, void 0, userTimestamp).catch(() => {
9637
9716
  });
9638
9717
  autoLabelSession(convId, fullMessage).catch(() => {
9639
9718
  });
9640
9719
  if (responseText) persistMessage(convId, "assistant", responseText, accountId, capturedTokens, assistantTimestamp).catch(() => {
9641
9720
  });
9642
- } else if (sessionKey) {
9643
- console.warn(`[persist] skipped: no conversationId for sessionKey=${sessionKey.slice(0, 12)}\u2026 (session registered=${sessionStore.has(sessionKey)})`);
9721
+ } else {
9722
+ bufferPendingTurn(sessionKey, { role: "user", content: fullMessage, timestamp: userTimestamp });
9723
+ if (responseText) bufferPendingTurn(sessionKey, { role: "assistant", content: responseText, timestamp: assistantTimestamp, tokens: capturedTokens });
9724
+ const flushedId = await maybeFlushConversationBuffer(sessionKey, "admin", accountId);
9725
+ if (flushedId) {
9726
+ autoLabelSession(flushedId, fullMessage).catch(() => {
9727
+ });
9728
+ yield { type: "conversation_attributed", conversationId: flushedId };
9729
+ }
9644
9730
  }
9645
9731
  const commitSession = sessionStore.get(sessionKey);
9646
9732
  if (commitSession?.pendingCommitmentOffers && commitSession.pendingCommitmentOffers.length > 0) {
@@ -9712,10 +9798,14 @@ async function* invokePublicAgent(message, systemPrompt, accountId, accountDir,
9712
9798
  return;
9713
9799
  }
9714
9800
  const publicConvId = sessionKey ? getConversationIdForSession(sessionKey) : void 0;
9715
- if (!publicConvId) {
9716
- throw new Error(`invokePublicAgent: conversationId missing for sessionKey=${sessionKey?.slice(0, 8) ?? "none"} \u2014 ensureConversation must run first`);
9801
+ if (!publicConvId && sessionKey && getPendingTurnCount(sessionKey) >= 2) {
9802
+ throw new Error(`invokePublicAgent: conversationId missing post-flush for sessionKey=${sessionKey.slice(0, 8)} \u2014 maybeFlushConversationBuffer must bind it first`);
9803
+ }
9804
+ const publicLogKey = publicConvId ?? (sessionKey ? preflushStreamLogKey(sessionKey) : void 0);
9805
+ if (!publicLogKey) {
9806
+ throw new Error(`invokePublicAgent: sessionKey required \u2014 cannot resolve log stream without one`);
9717
9807
  }
9718
- const streamLog = agentLogStream("public-agent-stream", accountDir, publicConvId);
9808
+ const streamLog = agentLogStream("public-agent-stream", accountDir, publicLogKey);
9719
9809
  streamLog.write(`[${isoTs()}] [public-user-message] ${JSON.stringify(message)}
9720
9810
  `);
9721
9811
  if (sessionKey) {
@@ -9952,10 +10042,10 @@ User messages are prefixed with the sender's name in brackets. Address participa
9952
10042
  `);
9953
10043
  }
9954
10044
  const conversationId = sessionKey ? sessionStore.get(sessionKey)?.conversationId : void 0;
10045
+ const assistantTimestamp = (/* @__PURE__ */ new Date()).toISOString();
10046
+ const sess = sessionKey ? sessionStore.get(sessionKey) : void 0;
10047
+ const sender = sess?.groupSlug && sess.visitorId && sess.senderDisplayName ? { visitorId: sess.visitorId, displayName: sess.senderDisplayName } : void 0;
9955
10048
  if (conversationId) {
9956
- const assistantTimestamp = (/* @__PURE__ */ new Date()).toISOString();
9957
- const sess = sessionKey ? sessionStore.get(sessionKey) : void 0;
9958
- const sender = sess?.groupSlug && sess.visitorId && sess.senderDisplayName ? { visitorId: sess.visitorId, displayName: sess.senderDisplayName } : void 0;
9959
10049
  persistMessage(conversationId, "user", message, accountId, void 0, userTimestamp, sender).catch(() => {
9960
10050
  });
9961
10051
  autoLabelSession(conversationId, message).catch(() => {
@@ -9963,7 +10053,14 @@ User messages are prefixed with the sender's name in brackets. Address participa
9963
10053
  if (fullText) persistMessage(conversationId, "assistant", fullText, accountId, void 0, assistantTimestamp).catch(() => {
9964
10054
  });
9965
10055
  } else if (sessionKey) {
9966
- console.warn(`[persist] skipped: no conversationId for sessionKey=${sessionKey.slice(0, 12)}\u2026 (session registered=${sessionStore.has(sessionKey)})`);
10056
+ bufferPendingTurn(sessionKey, { role: "user", content: message, timestamp: userTimestamp, sender });
10057
+ if (fullText) bufferPendingTurn(sessionKey, { role: "assistant", content: fullText, timestamp: assistantTimestamp });
10058
+ const flushedId = await maybeFlushConversationBuffer(sessionKey, "public", accountId);
10059
+ if (flushedId) {
10060
+ autoLabelSession(flushedId, message).catch(() => {
10061
+ });
10062
+ yield { type: "conversation_attributed", conversationId: flushedId };
10063
+ }
9967
10064
  }
9968
10065
  streamLog.end();
9969
10066
  }
@@ -10260,7 +10357,7 @@ Current session key: ${sessionKey}` : systemPromptBase;
10260
10357
 
10261
10358
  ${gwParts.join("\n")}`;
10262
10359
  }
10263
- if (sessionKey) {
10360
+ if (sessionKey && isDmChannelSessionKey(sessionKey)) {
10264
10361
  try {
10265
10362
  await ensureConversation(accountId, agentType, sessionKey, void 0, void 0, sessionUserId);
10266
10363
  } catch (err) {
@@ -14665,8 +14762,6 @@ app2.post("/", async (c) => {
14665
14762
  const newVisitorId = visitorId ?? crypto.randomUUID();
14666
14763
  const sessionKey = crypto.randomUUID();
14667
14764
  registerSession(sessionKey, "public", accountId, agentSlug);
14668
- ensureConversation(accountId, "public", sessionKey, newVisitorId, agentSlug).catch(() => {
14669
- });
14670
14765
  const hasImage = agentConfig?.image ? "yes" : "no";
14671
14766
  console.log(`[session] new-session visitor=${newVisitorId.slice(0, 8)}\u2026 session=${sessionKey.slice(0, 8)}\u2026 agent=${agentSlug} image=${hasImage} showAgentName=${agentConfig?.showAgentName ?? false}`);
14672
14767
  return withVisitorCookie(
@@ -17498,11 +17593,7 @@ async function createAdminSession(accountId, thinkingView, userId, userName) {
17498
17593
  businessName = branding?.name || void 0;
17499
17594
  } catch {
17500
17595
  }
17501
- let conversationId = null;
17502
- if (userId) {
17503
- conversationId = await createNewAdminConversation(userId, accountId, sessionKey);
17504
- }
17505
- console.log(`[session] ${(/* @__PURE__ */ new Date()).toISOString()} admin session created: userId=${userId ?? "\u2013"} userName=${userName ?? "\u2013"} accountId=${accountId} conversationId=${conversationId?.slice(0, 8) ?? "\u2013"} sessionKey=${sessionKey.slice(0, 8)}`);
17596
+ console.log(`[session] ${(/* @__PURE__ */ new Date()).toISOString()} admin session created: userId=${userId ?? "\u2013"} userName=${userName ?? "\u2013"} accountId=${accountId} conversationId=deferred sessionKey=${sessionKey.slice(0, 8)}`);
17506
17597
  return {
17507
17598
  session_key: sessionKey,
17508
17599
  agent_id: "admin",
@@ -17511,7 +17602,7 @@ async function createAdminSession(accountId, thinkingView, userId, userName) {
17511
17602
  thinkingView: effectiveThinkingView,
17512
17603
  onboardingComplete,
17513
17604
  businessName,
17514
- conversationId
17605
+ conversationId: null
17515
17606
  };
17516
17607
  }
17517
17608
  var app10 = new Hono2();
@@ -18571,16 +18662,10 @@ app19.post("/new", requireAdminSession, async (c) => {
18571
18662
  const newSessionKey = crypto3.randomUUID();
18572
18663
  const userName = getUserNameForSession(oldSessionKey);
18573
18664
  registerSession(newSessionKey, "admin", accountId, void 0, userId, userName);
18574
- const conversationId = await createNewAdminConversation(userId, accountId, newSessionKey);
18575
- if (!conversationId) {
18576
- unregisterSession(newSessionKey);
18577
- console.error(`[session] ${(/* @__PURE__ */ new Date()).toISOString()} new-conversation-failed: userId=${userId} accountId=${accountId.slice(0, 8)}\u2026 oldSessionKey=${oldSessionKey.slice(0, 8)}\u2026 newSessionKey=${newSessionKey.slice(0, 8)}\u2026`);
18578
- return c.json({ error: "Failed to create conversation" }, 500);
18579
- }
18580
18665
  const previousConversationId = clearSessionHistory(oldSessionKey);
18581
18666
  unregisterSession(oldSessionKey);
18582
- console.log(`[session] ${(/* @__PURE__ */ new Date()).toISOString()} session reset for new conversation: oldSessionKey=${oldSessionKey.slice(0, 8)}\u2026 newSessionKey=${newSessionKey.slice(0, 8)}\u2026 previousConversationId=${previousConversationId?.slice(0, 8) ?? "none"}\u2026 newConversationId=${conversationId.slice(0, 8)}\u2026`);
18583
- return c.json({ session_key: newSessionKey, conversationId });
18667
+ console.log(`[session] ${(/* @__PURE__ */ new Date()).toISOString()} session reset for new conversation: oldSessionKey=${oldSessionKey.slice(0, 8)}\u2026 newSessionKey=${newSessionKey.slice(0, 8)}\u2026 previousConversationId=${previousConversationId?.slice(0, 8) ?? "none"}\u2026 newConversationId=deferred`);
18668
+ return c.json({ session_key: newSessionKey, conversationId: null });
18584
18669
  });
18585
18670
  app19.delete("/:id", requireAdminSession, async (c) => {
18586
18671
  const conversationId = c.req.param("id");
@@ -19940,24 +20025,35 @@ var GRAPH_LABEL_COLOURS = {
19940
20025
  Review: "#059669",
19941
20026
  ImageObject: "#6EE7B7",
19942
20027
  // Conversational
20028
+ //
20029
+ // Task 649 palette — the four sublabelled conversation/message labels
20030
+ // (AdminConversation, PublicConversation, UserMessage, AssistantMessage)
20031
+ // are assigned four pairwise-distinguishable hues: indigo / purple /
20032
+ // orange / yellow. The Task 633 violet-shade split (darker for admin,
20033
+ // lighter for public) was indistinguishable on canvas and in the legend;
20034
+ // hue-shift replaces lightness-shift.
20035
+ //
20036
+ // Constraints honoured:
20037
+ // - Pairwise distinct among the four in-family labels.
20038
+ // - UserMessage=#F97316 reserved (Person/Preference orange cue) —
20039
+ // the other three are non-orange.
20040
+ // - No collision with Task/Project/Event pinks (#DB2777/#BE185D/#EC4899),
20041
+ // Knowledge greens, Workflow cyans, LocalBusiness blues.
20042
+ // - Conversation base (#7C3AED) kept as pre-backfill fallback for
20043
+ // nodes that pre-date the AdminConversation/PublicConversation split.
20044
+ // - Message base reassigned away from old #A78BFA to avoid near-
20045
+ // collision with the new PublicConversation=#A855F7; slate signals
20046
+ // "legacy/system/tool" — nodes carrying only :Message without a
20047
+ // role-sublabel.
20048
+ // - Out of family (intentionally not touched): OnboardingState=#8B5CF6
20049
+ // sits in the violet neighbourhood; palette reassignment outside
20050
+ // the conversation/message family is out of scope for Task 649.
19943
20051
  Conversation: "#7C3AED",
19944
- // Task 633 — admin vs public disambiguation on /graph. Darker violet for
19945
- // admin conversations (the operator-facing side), lighter for public
19946
- // (customer-facing) so the operator can read chat topology by colour
19947
- // alone. Both within the Conversation family — the hue shift is subtle
19948
- // enough to stay legible on adjacent nodes yet distinct enough to be
19949
- // unmistakable in the popover legend.
19950
- AdminConversation: "#5B21B6",
19951
- PublicConversation: "#A78BFA",
19952
- Message: "#A78BFA",
19953
- // Task 633 — user vs assistant disambiguation on /graph. UserMessage
19954
- // picks up the Person/Preference orange family cue (the user is a
19955
- // person); AssistantMessage stays violet-adjacent to reinforce the
19956
- // AdminConversation cue (both are admin-side). system/tool Messages
19957
- // (not written by the persist path today; reserved shape) stay on the
19958
- // base `:Message` colour.
20052
+ AdminConversation: "#4338CA",
20053
+ PublicConversation: "#A855F7",
20054
+ Message: "#64748B",
19959
20055
  UserMessage: "#F97316",
19960
- AssistantMessage: "#8B5CF6",
20056
+ AssistantMessage: "#FACC15",
19961
20057
  ToolCall: "#C4B5FD",
19962
20058
  // Tasks / projects / events
19963
20059
  Task: "#DB2777",