drafted 1.11.14 → 1.11.15

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 +12 -2
  2. package/package.json +1 -1
package/mcp/server.mjs CHANGED
@@ -1230,7 +1230,13 @@ async function consumePendingDeviceCode() {
1230
1230
  return false;
1231
1231
  }
1232
1232
 
1233
- tool('auth', 'Sign in to Drafted. `action=get_link` returns a verification URL immediately (use for SSH/headless/tmux where a browser may not open) and starts background polling; after the user opens the link, later Drafted tool calls also auto-consume the approved login. `action=login` opens a browser when needed and explicitly waits/polls for approval. If get_link was called first, login reuses that pending code instead of opening a new browser.', {
1233
+ // Device-flow sign-in is stdio-only. Web/Cowork connectors authenticate via
1234
+ // OAuth at the transport layer (the hosted /mcp handler injects a Drafted
1235
+ // session per request), so advertising a device-flow auth tool there is
1236
+ // meaningless and disruptive — it returns spurious sign-in URLs and, on login,
1237
+ // spawns a server-side browser-open and blocks polling until timeout. Register
1238
+ // it only on stdio.
1239
+ if (!isRemote) tool('auth', 'Sign in to Drafted. `action=get_link` returns a verification URL immediately (use for SSH/headless/tmux where a browser may not open) and starts background polling; after the user opens the link, later Drafted tool calls also auto-consume the approved login. `action=login` opens a browser when needed and explicitly waits/polls for approval. If get_link was called first, login reuses that pending code instead of opening a new browser.', {
1234
1240
  action: z.enum(['get_link', 'login']).describe('Operation to perform.'),
1235
1241
  }, async ({ action }) => {
1236
1242
  try {
@@ -1242,7 +1248,11 @@ tool('auth', 'Sign in to Drafted. `action=get_link` returns a verification URL i
1242
1248
  return ok(data.verificationUrl);
1243
1249
  }
1244
1250
  if (action === 'login') {
1245
- const existing = getBootstrapSessionId();
1251
+ // Prefer the active request session (injected by runWithRequestState on
1252
+ // remote, or cloneSession on stdio) over the on-disk bootstrap session, so
1253
+ // an already-authenticated caller short-circuits to already_authenticated
1254
+ // instead of starting a needless device flow.
1255
+ const existing = getState().sessionId || getBootstrapSessionId();
1246
1256
  if (existing) {
1247
1257
  try {
1248
1258
  const res = await fetch(`${getServerUrl()}/auth/me`, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drafted",
3
- "version": "1.11.14",
3
+ "version": "1.11.15",
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": [