reasonally 0.6.0 → 0.7.0

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/README.md CHANGED
@@ -143,6 +143,24 @@ reasonally --resume # choose one
143
143
  When a conversation fills about 80% of the model's context window, earlier turns are summarized
144
144
  automatically (or now, with `/compact`).
145
145
 
146
+ ### On the web
147
+
148
+ Your conversations also show in the web chat's sidebar, under this computer, where you can follow
149
+ them live. Only summaries are sent: what you typed, the agent's replies, and one line for each step
150
+ (commands with secrets masked, addresses without their query). Command output, file contents,
151
+ tool arguments and the agent's reasoning never leave the computer. It's on unless you turn it off,
152
+ and the desktop app on the same computer shares the setting.
153
+
154
+ ```bash
155
+ reasonally sync # whether they show on the web, and the last upload
156
+ reasonally sync off # stop, and take them off the web (they stay here)
157
+ reasonally sync on # show them again
158
+ reasonally sync off --here # only for this folder
159
+ ```
160
+
161
+ Uploads happen in the background and never slow a turn down; offline, they catch up later.
162
+ Replies and approvals from the web go to the desktop app, never to a terminal.
163
+
146
164
  ### Project instructions
147
165
 
148
166
  The agent follows `AGENTS.md` and `CLAUDE.md` files from your repository's root down to the folder
@@ -210,6 +228,7 @@ Generated files live in `~/.config/reasonally/harness/`.
210
228
  ```bash
211
229
  reasonally models [search] # models you can use, with context and price
212
230
  reasonally whoami # account and balance
231
+ reasonally sync [on|off] # whether your conversations show on the web (--here: this folder)
213
232
  reasonally logout # log out and revoke this computer's key
214
233
  reasonally login --no-browser # print the approval link instead of opening it
215
234
  ```
package/dist/api.js CHANGED
@@ -31,15 +31,24 @@ async function call(url, init = {}) {
31
31
  return body;
32
32
  }
33
33
  const bearer = (apiKey) => ({ authorization: `Bearer ${apiKey}` });
34
- export function exchangeCode(appUrl,
35
- /** `client` names the kind of key ("desktop"); the CLI leaves it out. */
36
- body) {
34
+ export function exchangeCode(appUrl, body) {
37
35
  return call(`${appUrl}/api/cli/token`, {
38
36
  method: "POST",
39
37
  headers: { "content-type": "application/json" },
40
38
  body: JSON.stringify(body),
41
39
  });
42
40
  }
41
+ /**
42
+ * Exchanges a "Show your web chats" approval (`purpose: "web"`) for the chat window's sign-in.
43
+ * It makes no key: the app proves the approval is for it by presenting its own.
44
+ */
45
+ export function exchangeWebApproval(appUrl, apiKey, body) {
46
+ return call(`${appUrl}/api/cli/token`, {
47
+ method: "POST",
48
+ headers: { "content-type": "application/json", ...bearer(apiKey) },
49
+ body: JSON.stringify({ ...body, client: "desktop", purpose: "web" }),
50
+ });
51
+ }
43
52
  export function fetchAccount(appUrl, apiKey) {
44
53
  return call(`${appUrl}/api/cli/me`, {
45
54
  headers: bearer(apiKey),
package/dist/cli.js CHANGED
@@ -20,6 +20,7 @@ Usage:
20
20
  reasonally logout Log out and revoke this computer's key
21
21
  reasonally browser Let your Reasonally chats use a browser window on this computer
22
22
  (--port N, default 47614; --allow-local: allow local addresses)
23
+ reasonally sync [on|off] Whether your conversations show on the web (--here: this folder)
23
24
 
24
25
  Agents:
25
26
  ${HARNESSES.map((h) => ` ${h.id.padEnd(10)} ${h.name}`).join("\n")}
@@ -226,6 +227,10 @@ export async function main(argv) {
226
227
  const { browserCommand } = await import("./browser/command.js");
227
228
  return await browserCommand(args, log);
228
229
  }
230
+ case "sync": {
231
+ const { syncCommand } = await import("./sync/command.js");
232
+ return await syncCommand(args, log);
233
+ }
229
234
  }
230
235
  // Options without a command are the agent's: `reasonally --model x`, `reasonally --yes`.
231
236
  if (command.startsWith("-"))
package/dist/login.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { createServer } from "node:http";
3
3
  import { hostname } from "node:os";
4
- import { exchangeCode } from "./api.js";
4
+ import { exchangeCode, exchangeWebApproval } from "./api.js";
5
5
  import { createPkce } from "./pkce.js";
6
6
  /** How long to wait for the user to approve in the browser. */
7
7
  const LOGIN_TIMEOUT_MS = 5 * 60 * 1000;
@@ -15,6 +15,8 @@ export function authorizeUrl(appUrl, params) {
15
15
  });
16
16
  if (params.client)
17
17
  query.set("client", params.client);
18
+ if (params.client && params.purpose)
19
+ query.set("purpose", params.purpose);
18
20
  return `${appUrl}/cli/authorize?${query}`;
19
21
  }
20
22
  /** Interprets a request to the loopback server. Only `/callback` with our `state` counts. */
@@ -99,7 +101,20 @@ function waitForCallback(server, state, { signal, returnTo = "your terminal" } =
99
101
  });
100
102
  });
101
103
  }
102
- export async function browserLogin(appUrl, log, options = {}) {
104
+ export function browserLogin(appUrl, log, options = {}) {
105
+ return approveInBrowser(appUrl, log, options, (exchange) => exchangeCode(appUrl, exchange));
106
+ }
107
+ /**
108
+ * "Show your web chats": the desktop app, already signed in, asks the browser to approve showing
109
+ * the person's web chats, and gets back the one-time code that signs its chat window in (null when
110
+ * the platform doesn't show web chats in the app). No new key is made.
111
+ */
112
+ export async function browserWebHandoff(appUrl, apiKey, log, options = {}) {
113
+ const result = await approveInBrowser(appUrl, log, { ...options, client: "desktop", purpose: "web" }, (exchange) => exchangeWebApproval(appUrl, apiKey, exchange));
114
+ return result.web_handoff ?? null;
115
+ }
116
+ /** Opens the approval page, waits for the code on a one-shot loopback server, and exchanges it. */
117
+ async function approveInBrowser(appUrl, log, options, exchange) {
103
118
  const { open = true } = options;
104
119
  const pkce = createPkce();
105
120
  const server = createServer();
@@ -116,6 +131,7 @@ export async function browserLogin(appUrl, log, options = {}) {
116
131
  state: pkce.state,
117
132
  device: options.device ?? hostname().replace(/\.local$/, ""),
118
133
  client: options.client,
134
+ purpose: options.purpose,
119
135
  });
120
136
  options.onUrl?.(url);
121
137
  if (open) {
@@ -127,11 +143,11 @@ export async function browserLogin(appUrl, log, options = {}) {
127
143
  log(`Open this link in the browser where you're signed in, on this computer:\n\n ${url}\n`);
128
144
  }
129
145
  const code = await waitForCallback(server, pkce.state, options);
130
- return await exchangeCode(appUrl, {
146
+ return await exchange({
131
147
  code,
132
148
  code_verifier: pkce.verifier,
133
149
  redirect_uri: redirectUri,
134
- client: options.client,
150
+ ...(options.client ? { client: options.client } : {}),
135
151
  });
136
152
  }
137
153
  finally {