drafted 1.11.31 → 1.11.32

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.
Files changed (2) hide show
  1. package/mcp/server.mjs +15 -3
  2. package/package.json +1 -1
package/mcp/server.mjs CHANGED
@@ -709,8 +709,14 @@ function schedulePendingAuthPoll(delayMs = 2000) {
709
709
  // session before any operation runs.
710
710
  function getAuthHeaders() {
711
711
  const sid = getState().sessionId;
712
- if (sid) return { Cookie: `gc_session=${sid}` };
713
- return {};
712
+ const headers = {};
713
+ if (sid) headers.Cookie = `gc_session=${sid}`;
714
+ // Stable human name for this agent (DRAFTED_AGENT_NAME), so the server names this
715
+ // session's surface tab by the AGENT, not the project — lets the user tell concurrent
716
+ // agents apart even in the same project.
717
+ const agentName = (process.env.DRAFTED_AGENT_NAME || '').trim();
718
+ if (agentName) headers['X-Drafted-Agent'] = agentName;
719
+ return headers;
714
720
  }
715
721
 
716
722
  // Mint a fresh per-instance child session from the shared root login and bind it
@@ -724,9 +730,15 @@ async function cloneSession() {
724
730
  if (!bootstrapId) return false;
725
731
 
726
732
  try {
733
+ // A named agent (DRAFTED_AGENT_NAME) gets a STABLE child session: the server
734
+ // returns the same session for the same (user, agentKey) across reconnects, so a
735
+ // restarted agent reconnects its existing named session instead of churning a new
736
+ // one. Anonymous clients send no key and keep a fresh-per-process session.
737
+ const agentKey = (process.env.DRAFTED_AGENT_NAME || '').trim();
727
738
  const res = await fetch(`${getServerUrl()}/auth/session/clone`, {
728
739
  method: 'POST',
729
- headers: { Cookie: `gc_session=${bootstrapId}` },
740
+ headers: { 'Content-Type': 'application/json', Cookie: `gc_session=${bootstrapId}` },
741
+ body: JSON.stringify({ agentKey }),
730
742
  });
731
743
  if (res.ok) {
732
744
  const data = await res.json();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drafted",
3
- "version": "1.11.31",
3
+ "version": "1.11.32",
4
4
  "description": "Drafted — visual thinking surface for humans and AI agents. Renders HTML, markdown, images, and code as frames on a zoomable canvas, with MCP tools for AI agents and real-time sync for humans.",
5
5
  "type": "module",
6
6
  "files": [