openalmanac 0.2.31 → 0.2.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.
- package/dist/auth.js +2 -2
- package/dist/login-core.js +3 -3
- package/dist/login.js +1 -1
- package/dist/server.js +1 -1
- package/dist/tools/auth.js +2 -2
- package/dist/tools/research.js +16 -0
- package/package.json +1 -1
package/dist/auth.js
CHANGED
|
@@ -42,13 +42,13 @@ export async function getAuthStatus() {
|
|
|
42
42
|
if (!key)
|
|
43
43
|
return { loggedIn: false };
|
|
44
44
|
try {
|
|
45
|
-
const resp = await fetch(`${API_BASE}/api/
|
|
45
|
+
const resp = await fetch(`${API_BASE}/api/users/me`, {
|
|
46
46
|
headers: { Authorization: `Bearer ${key}` },
|
|
47
47
|
signal: AbortSignal.timeout(10_000),
|
|
48
48
|
});
|
|
49
49
|
if (resp.ok) {
|
|
50
50
|
const data = (await resp.json());
|
|
51
|
-
return { loggedIn: true, name: data.
|
|
51
|
+
return { loggedIn: true, name: data.display_name ?? data.username ?? "unknown" };
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
catch {
|
package/dist/login-core.js
CHANGED
|
@@ -7,7 +7,7 @@ function callbackPage(success) {
|
|
|
7
7
|
// These values are hardcoded — never interpolate user input here.
|
|
8
8
|
const title = success ? "You\u2019re connected" : "Something went wrong";
|
|
9
9
|
const messageLine1 = success
|
|
10
|
-
? "Your
|
|
10
|
+
? "Your account is connected and a personal API key is ready to go."
|
|
11
11
|
: "Invalid token. Please return to your terminal and try again.";
|
|
12
12
|
const messageLine2 = success
|
|
13
13
|
? "You can close this tab and return to your terminal."
|
|
@@ -160,13 +160,13 @@ export async function performLogin(options) {
|
|
|
160
160
|
const existingKey = getApiKey();
|
|
161
161
|
if (existingKey) {
|
|
162
162
|
try {
|
|
163
|
-
const resp = await fetch(`${API_BASE}/api/
|
|
163
|
+
const resp = await fetch(`${API_BASE}/api/users/me`, {
|
|
164
164
|
headers: { Authorization: `Bearer ${existingKey}` },
|
|
165
165
|
signal: AbortSignal.timeout(10_000),
|
|
166
166
|
});
|
|
167
167
|
if (resp.ok) {
|
|
168
168
|
const data = (await resp.json());
|
|
169
|
-
return { status: "already_logged_in", name: data.
|
|
169
|
+
return { status: "already_logged_in", name: data.display_name ?? data.username ?? "unknown" };
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
catch {
|
package/dist/login.js
CHANGED
|
@@ -6,7 +6,7 @@ export async function runLogin() {
|
|
|
6
6
|
console.log(`Already logged in as ${result.name}.`);
|
|
7
7
|
}
|
|
8
8
|
else {
|
|
9
|
-
console.log("Logged in.
|
|
9
|
+
console.log("Logged in. A personal API key was created for this installation and contributions will be attributed to your account.");
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
export async function runLogout() {
|
package/dist/server.js
CHANGED
|
@@ -124,7 +124,7 @@ export function createServer() {
|
|
|
124
124
|
"",
|
|
125
125
|
"## Technical workflow",
|
|
126
126
|
"",
|
|
127
|
-
"Reading and searching articles is open. Writing requires an API key (from login). Login
|
|
127
|
+
"Reading and searching articles is open. Writing requires an API key (from login). Login creates a personal API key linked to your user account, so contributions are attributed to you.",
|
|
128
128
|
"",
|
|
129
129
|
"Core flow: login (once) → search_articles (check if exists) → search_web + read_webpage (research) → new (scaffold) or download (existing) → edit ~/.openalmanac/articles/{slug}.md → publish (validate & publish).",
|
|
130
130
|
"",
|
package/dist/tools/auth.js
CHANGED
|
@@ -3,7 +3,7 @@ import { performLogin } from "../login-core.js";
|
|
|
3
3
|
export function registerAuthTools(server) {
|
|
4
4
|
server.addTool({
|
|
5
5
|
name: "login",
|
|
6
|
-
description: "Log in via browser to
|
|
6
|
+
description: "Log in via browser to connect your account and get a personal API key. This is the required " +
|
|
7
7
|
"first step before creating or updating articles. Only needs to be called once.\n\n" +
|
|
8
8
|
"If you already have a valid API key, this returns immediately without opening a browser.",
|
|
9
9
|
async execute() {
|
|
@@ -11,7 +11,7 @@ export function registerAuthTools(server) {
|
|
|
11
11
|
if (result.status === "already_logged_in") {
|
|
12
12
|
return `Already logged in as ${result.name}.`;
|
|
13
13
|
}
|
|
14
|
-
return "Logged in.
|
|
14
|
+
return "Logged in. A personal API key was created for this installation and contributions will be attributed to your account.";
|
|
15
15
|
},
|
|
16
16
|
});
|
|
17
17
|
server.addTool({
|
package/dist/tools/research.js
CHANGED
|
@@ -112,4 +112,20 @@ export function registerResearchTools(server) {
|
|
|
112
112
|
return { content };
|
|
113
113
|
},
|
|
114
114
|
});
|
|
115
|
+
server.addTool({
|
|
116
|
+
name: "register_sources",
|
|
117
|
+
description: "Register sources you plan to cite in your response. Call this BEFORE writing your response text. " +
|
|
118
|
+
"Each source becomes a clickable citation bubble when you use [@key] markers in your text. " +
|
|
119
|
+
"Collect sources from your read_webpage calls and any subagent results, then register them all in one call.",
|
|
120
|
+
parameters: z.object({
|
|
121
|
+
sources: z.array(z.object({
|
|
122
|
+
key: z.string().describe("Citation key — kebab-case, BibTeX-style: {domain}-{title-words} (e.g. 'nytimes-climate-report')"),
|
|
123
|
+
url: z.string().describe("Source URL"),
|
|
124
|
+
title: z.string().describe("Source title — include publication name after em dash (e.g. 'Climate Report — The New York Times')"),
|
|
125
|
+
})).min(1).describe("Sources to register for citation"),
|
|
126
|
+
}),
|
|
127
|
+
async execute({ sources }) {
|
|
128
|
+
return `Registered ${sources.length} source${sources.length === 1 ? "" : "s"}. Use [@key] markers in your response to cite them.`;
|
|
129
|
+
},
|
|
130
|
+
});
|
|
115
131
|
}
|