drafted 1.19.25 → 1.19.26
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/mcp/server.mjs +33 -0
- package/package.json +1 -1
package/mcp/server.mjs
CHANGED
|
@@ -633,6 +633,11 @@ registerAppResource(
|
|
|
633
633
|
|
|
634
634
|
const AUTH_FILE = process.env.DRAFTED_AUTH_FILE || join(homedir(), '.drafted', 'auth.json');
|
|
635
635
|
const PENDING_AUTH_FILE = process.env.DRAFTED_PENDING_AUTH_FILE || `${AUTH_FILE}.pending`;
|
|
636
|
+
// The DESKTOP app's own browser session (desktop/src-tauri/src/main.rs writes it beside
|
|
637
|
+
// auth.json). Never read for a credential here — only to answer "is the app signed in?",
|
|
638
|
+
// which is a different question from "is this MCP signed in?" and the one that decides
|
|
639
|
+
// whether an agent can reach the human at all.
|
|
640
|
+
const DESKTOP_SESSION_FILE = join(dirname(AUTH_FILE), 'desktop.json');
|
|
636
641
|
|
|
637
642
|
// Active-project persistence (stdio only): see mcp/active-project-store.mjs.
|
|
638
643
|
// Persisted so a `system restart mode=mcp` / skill-edit pass that re-spawns the
|
|
@@ -2234,6 +2239,27 @@ if (!isRemote) tool('auth', 'Sign in to Drafted.\n\n`action=get_link` ALWAYS ret
|
|
|
2234
2239
|
restoredAuthFile = true;
|
|
2235
2240
|
} catch { /* read-only home: report the truth below rather than throwing */ }
|
|
2236
2241
|
}
|
|
2242
|
+
// The DESKTOP's own browser credential is a separate file, and an agent
|
|
2243
|
+
// cannot mint one — it is the origin='browser' class that may approve
|
|
2244
|
+
// actions, which is exactly what the two-credential split protects. But
|
|
2245
|
+
// "cannot mint it" is not "cannot ask for it": opening the app's sign-in
|
|
2246
|
+
// window is this tool's documented job, and the window usually completes
|
|
2247
|
+
// with no interaction at all because the shared cookie store still holds a
|
|
2248
|
+
// valid login. Short-circuiting on the agent session skipped that entirely,
|
|
2249
|
+
// so `login` reported success while the app stayed signed out and every
|
|
2250
|
+
// agent that pinged the human reached nobody.
|
|
2251
|
+
let openedDesktopSignin = false;
|
|
2252
|
+
if (desktopAppBinary() && !existsSync(DESKTOP_SESSION_FILE)) {
|
|
2253
|
+
openedDesktopSignin = await launchDesktopSignin();
|
|
2254
|
+
if (openedDesktopSignin) {
|
|
2255
|
+
// Give the app a moment to re-capture the cookie so the caller can act
|
|
2256
|
+
// on a true answer rather than an optimistic one.
|
|
2257
|
+
for (let i = 0; i < 20 && !existsSync(DESKTOP_SESSION_FILE); i++) {
|
|
2258
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
const desktopSignedIn = !desktopAppBinary() ? null : existsSync(DESKTOP_SESSION_FILE);
|
|
2237
2263
|
return ok({
|
|
2238
2264
|
status: 'already_authenticated',
|
|
2239
2265
|
userId: me.userId,
|
|
@@ -2243,6 +2269,13 @@ if (!isRemote) tool('auth', 'Sign in to Drafted.\n\n`action=get_link` ALWAYS ret
|
|
|
2243
2269
|
restoredAuthFile: true,
|
|
2244
2270
|
note: 'This session was signed in but ~/.drafted/auth.json was missing, so other readers on this machine (the desktop app, the CLI) were not. Rewrote it from the live session.',
|
|
2245
2271
|
} : {}),
|
|
2272
|
+
...(desktopSignedIn === null ? {} : { desktopSignedIn }),
|
|
2273
|
+
...(openedDesktopSignin ? {
|
|
2274
|
+
openedDesktopSignin: true,
|
|
2275
|
+
desktopNote: desktopSignedIn
|
|
2276
|
+
? 'The desktop app was signed out; opened its sign-in window and it completed on its own from the existing browser session.'
|
|
2277
|
+
: 'The desktop app is signed out and its sign-in window is open — it needs one approval there. Until then it holds no session, so an agent asking for attention cannot reach this machine.',
|
|
2278
|
+
} : {}),
|
|
2246
2279
|
});
|
|
2247
2280
|
}
|
|
2248
2281
|
} catch { /* session invalid, proceed with login */ }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drafted",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.26",
|
|
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": [
|