reasonally 0.6.0 → 0.8.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
@@ -138,11 +138,30 @@ Every conversation is saved as it happens, in `~/.config/reasonally/sessions/`.
138
138
  ```bash
139
139
  reasonally --continue # pick up the last conversation in this folder
140
140
  reasonally --resume # choose one
141
+ reasonally --resume <id> # reopen that one (the desktop app's Continue in terminal copies this)
141
142
  ```
142
143
 
143
144
  When a conversation fills about 80% of the model's context window, earlier turns are summarized
144
145
  automatically (or now, with `/compact`).
145
146
 
147
+ ### On the web
148
+
149
+ Your conversations also show in the web chat's sidebar, under this computer, where you can follow
150
+ them live. Only summaries are sent: what you typed, the agent's replies, and one line for each step
151
+ (commands with secrets masked, addresses without their query). Command output, file contents,
152
+ tool arguments and the agent's reasoning never leave the computer. It's on unless you turn it off,
153
+ and the desktop app on the same computer shares the setting.
154
+
155
+ ```bash
156
+ reasonally sync # whether they show on the web, and the last upload
157
+ reasonally sync off # stop, and take them off the web (they stay here)
158
+ reasonally sync on # show them again
159
+ reasonally sync off --here # only for this folder
160
+ ```
161
+
162
+ Uploads happen in the background and never slow a turn down; offline, they catch up later.
163
+ Replies and approvals from the web go to the desktop app, never to a terminal.
164
+
146
165
  ### Project instructions
147
166
 
148
167
  The agent follows `AGENTS.md` and `CLAUDE.md` files from your repository's root down to the folder
@@ -210,6 +229,7 @@ Generated files live in `~/.config/reasonally/harness/`.
210
229
  ```bash
211
230
  reasonally models [search] # models you can use, with context and price
212
231
  reasonally whoami # account and balance
232
+ reasonally sync [on|off] # whether your conversations show on the web (--here: this folder)
213
233
  reasonally logout # log out and revoke this computer's key
214
234
  reasonally login --no-browser # print the approval link instead of opening it
215
235
  ```
@@ -462,6 +462,7 @@ export async function listSessions(dir) {
462
462
  model: s.model,
463
463
  costMicros: s.costMicros,
464
464
  updatedAt: s.updatedAt,
465
+ createdAt: new Date(s.meta.createdAt),
465
466
  }))
466
467
  .sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime() || b.id.localeCompare(a.id));
467
468
  }
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
@@ -12,7 +12,7 @@ const HELP = `Run the coding agents you already use on Reasonally models.
12
12
 
13
13
  Usage:
14
14
  reasonally Start Reasonally's coding agent in this folder
15
- (--model <id>, --plan, --yes, --continue, --resume, --no-web)
15
+ (--model <id>, --plan, --yes, --continue, --resume [id], --no-web)
16
16
  reasonally login Log in through your browser (--no-browser: print the link)
17
17
  reasonally <agent> [--model <id>] [agent args…]
18
18
  reasonally models [search] List models you can use
@@ -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 {