@actario/cli 0.1.0 → 0.1.2

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -11,22 +11,26 @@ land in an inbox for you to confirm before any other agent can see them.
11
11
  ## Install
12
12
 
13
13
  ```
14
- npx @actario/cli init
14
+ npx @actario/cli login
15
15
  ```
16
16
 
17
17
  Or install it for real:
18
18
 
19
19
  ```
20
20
  npm install -g @actario/cli
21
- actario init
21
+ actario login
22
22
  ```
23
23
 
24
- `init` asks for your workspace API URL and a capture token, checks the token
25
- before writing anything, and registers this machine as a source.
24
+ `login` opens your browser at Actario: sign in with your own account, pick a
25
+ workspace and approve. This machine is then linked -- no token to copy. On a
26
+ machine without a browser (SSH, a container), `actario login --device` prints
27
+ a URL and a short code to approve from any device. `actario init` still takes
28
+ a pasted capture token if you prefer.
26
29
 
27
30
  ## Commands
28
31
 
29
32
  ```
33
+ actario login link this machine by signing in with the browser
30
34
  actario capture capture, redact and upload new sessions
31
35
  actario analyze analyse the captured batch here, on your own subscription
32
36
  actario status local capture state, or one upload's progress
package/dist/actario.js CHANGED
@@ -564,7 +564,7 @@ var flagBool = (a, k) => a.flags[k] === true || a.flags[k] === "true";
564
564
  var flagList = (a, k) => (flagString(a, k) ?? "").split(",").map((s) => s.trim()).filter(Boolean);
565
565
 
566
566
  // ../../apps/cli/src/version.ts
567
- var CLI_VERSION = "0.1.0";
567
+ var CLI_VERSION = "0.1.2";
568
568
 
569
569
  // ../../apps/cli/src/print.ts
570
570
  var useColour = process.stdout.isTTY && !process.env.NO_COLOR;
@@ -3811,6 +3811,24 @@ var UNMASK_MARKER_TEXT = "This directory holds an Actario export with pseudonyms
3811
3811
  import { createReadStream as createReadStream3 } from "node:fs";
3812
3812
  import { readFile as readFile3, stat as stat3 } from "node:fs/promises";
3813
3813
  import { join as join15 } from "node:path";
3814
+ var CODE_BY_STATUS = {
3815
+ 400: "invalid_request",
3816
+ 401: "unauthorized",
3817
+ 403: "forbidden",
3818
+ 404: "not_found",
3819
+ 409: "conflict",
3820
+ 429: "rate_limited"
3821
+ };
3822
+ var fallbackMessage = (status, statusText, baseUrl) => {
3823
+ if (status === 401 || status === 403) {
3824
+ return `${baseUrl} rejected this token (${status}). It may be mistyped, revoked, or minted for a different workspace. Create a new one under Settings -> Access tokens, then link again.`;
3825
+ }
3826
+ if (status === 404) {
3827
+ return `${baseUrl} has no Actario API at this path (404). Check the API URL -- it should be the workspace's base URL, nothing after the host.`;
3828
+ }
3829
+ if (status === 429) return `${baseUrl} is rate limiting this token. Wait a moment and retry.`;
3830
+ return `${status} ${statusText}`;
3831
+ };
3814
3832
  async function request(opts, path, init = {}) {
3815
3833
  const attempts = init.attempts ?? 3;
3816
3834
  let lastError = null;
@@ -3826,13 +3844,22 @@ async function request(opts, path, init = {}) {
3826
3844
  if (res instanceof Error) {
3827
3845
  lastError = res;
3828
3846
  } else if (res.ok) {
3829
- return await res.json();
3847
+ try {
3848
+ return await res.json();
3849
+ } catch {
3850
+ throw new DistillError(
3851
+ "invalid_request",
3852
+ `${opts.baseUrl} answered ${path} with something that is not JSON. Check the API URL points at an Actario workspace.`,
3853
+ void 0,
3854
+ 502
3855
+ );
3856
+ }
3830
3857
  } else if (res.status === 409 || res.status < 500) {
3831
3858
  const body = await res.json().catch(() => ({}));
3832
3859
  const err = body.error;
3833
3860
  throw new DistillError(
3834
- err?.code ?? "internal",
3835
- err?.message ?? `${res.status} ${res.statusText}`,
3861
+ err?.code ?? CODE_BY_STATUS[res.status] ?? "internal",
3862
+ err?.message ?? fallbackMessage(res.status, res.statusText, opts.baseUrl),
3836
3863
  err?.details,
3837
3864
  res.status
3838
3865
  );
@@ -4691,7 +4718,7 @@ ${dim("is safe to paste into a report as-is.")}
4691
4718
 
4692
4719
  // ../../apps/cli/src/commands/init.ts
4693
4720
  import { createInterface as createInterface2 } from "node:readline/promises";
4694
- import { join as join21 } from "node:path";
4721
+ import { join as join22 } from "node:path";
4695
4722
 
4696
4723
  // ../../apps/cli/src/core/link.ts
4697
4724
  import { hostname } from "node:os";
@@ -4749,6 +4776,335 @@ async function linkMachine(opts) {
4749
4776
  return { config, identity, source, sourceCreated, sources };
4750
4777
  }
4751
4778
 
4779
+ // ../../apps/cli/src/commands/login.ts
4780
+ import { join as join21 } from "node:path";
4781
+
4782
+ // ../../apps/cli/src/core/device-login.ts
4783
+ import { spawn } from "node:child_process";
4784
+ import { createServer } from "node:http";
4785
+ import { hostname as hostname2 } from "node:os";
4786
+ var DEFAULT_API_URL = "https://distill-web-ten.vercel.app";
4787
+ function defaultApiUrl() {
4788
+ return (readConfig().api_url ?? actarioEnv("API_URL") ?? DEFAULT_API_URL).replace(/\/+$/, "");
4789
+ }
4790
+ async function post(base, path, body) {
4791
+ let res;
4792
+ try {
4793
+ res = await fetch(new URL(path, base), { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) });
4794
+ } catch (e) {
4795
+ return { ok: false, status: 0, code: "network", message: e.message };
4796
+ }
4797
+ const json = await res.json().catch(() => null);
4798
+ if (res.ok && json) return { ok: true, data: json };
4799
+ return { ok: false, status: res.status, code: json?.error?.code ?? `http_${res.status}`, message: json?.error?.message ?? `${res.status} ${res.statusText}` };
4800
+ }
4801
+ function canOpenBrowser() {
4802
+ if (process.platform === "win32" || process.platform === "darwin") return true;
4803
+ return Boolean(process.env.DISPLAY || process.env.WAYLAND_DISPLAY);
4804
+ }
4805
+ async function openInBrowser(url) {
4806
+ let u;
4807
+ try {
4808
+ u = new URL(url);
4809
+ } catch {
4810
+ return false;
4811
+ }
4812
+ if (u.protocol !== "https:" && u.protocol !== "http:" || !u.hostname || /[\s"'`]/.test(url)) return false;
4813
+ if (!canOpenBrowser()) return false;
4814
+ const plat = process.platform;
4815
+ const [cmd, args] = plat === "win32" ? ["rundll32", ["url.dll,FileProtocolHandler", u.href]] : plat === "darwin" ? ["open", [u.href]] : ["xdg-open", [u.href]];
4816
+ return new Promise((resolve4) => {
4817
+ try {
4818
+ const child = spawn(cmd, args, { stdio: "ignore", detached: true, windowsHide: true });
4819
+ child.once("error", () => resolve4(false));
4820
+ child.once("spawn", () => {
4821
+ child.unref();
4822
+ resolve4(true);
4823
+ });
4824
+ } catch {
4825
+ resolve4(false);
4826
+ }
4827
+ });
4828
+ }
4829
+ var escapeHtml = (s) => s.replace(/[&<>"']/g, (c2) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c2]);
4830
+ function resultPage(title, body, ok2) {
4831
+ return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
4832
+ <title>Actario \xB7 ${escapeHtml(title)}</title>
4833
+ <style>
4834
+ :root{color-scheme:light dark;--bg:#fafafa;--ink:#18181b;--muted:#52525b;--line:#e4e4e7;--mark:${ok2 ? "#15803d" : "#b91c1c"}}
4835
+ @media (prefers-color-scheme:dark){:root{--bg:#0f0f10;--ink:#f4f4f5;--muted:#a1a1aa;--line:#27272a;--mark:${ok2 ? "#4ade80" : "#f87171"}}}
4836
+ body{margin:0;background:var(--bg);color:var(--ink);font:15px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif;display:grid;place-items:center;min-height:100vh;padding:16px;box-sizing:border-box}
4837
+ main{max-width:460px;border:1px solid var(--line);border-radius:12px;padding:24px 26px}
4838
+ h1{font-size:19px;margin:0 0 8px;display:flex;gap:10px;align-items:center}
4839
+ h1::before{content:"";width:10px;height:10px;border-radius:50%;background:var(--mark)}
4840
+ p{margin:0;color:var(--muted)}
4841
+ </style></head><body><main><h1>${escapeHtml(title)}</h1><p>${escapeHtml(body)}</p></main></body></html>`;
4842
+ }
4843
+ async function listenLoopback() {
4844
+ const server = createServer();
4845
+ await new Promise((resolve4, reject) => {
4846
+ server.once("error", reject);
4847
+ server.listen(0, "127.0.0.1", () => resolve4());
4848
+ });
4849
+ const addr = server.address();
4850
+ if (!addr || typeof addr === "string") throw new Error("no port");
4851
+ return { server, port: addr.port };
4852
+ }
4853
+ var MAX_INTERVAL_MS = 3e4;
4854
+ async function startDeviceLogin(opts = {}) {
4855
+ const apiUrl = (opts.apiUrl ?? defaultApiUrl()).replace(/\/+$/, "");
4856
+ if (!/^https?:\/\//.test(apiUrl)) throw new DistillError("invalid_request", "api_url must start with http:// or https://");
4857
+ const launch = opts.launch ?? openInBrowser;
4858
+ const wantBrowser = opts.openBrowser ?? !actarioEnv("NO_BROWSER");
4859
+ const canLaunch = wantBrowser && (opts.launch ? true : canOpenBrowser());
4860
+ const requestCode = async (redirect) => {
4861
+ const r = await post(apiUrl, "/api/v1/device/code", {
4862
+ client_name: opts.clientName ?? "Actario CLI",
4863
+ client_host: opts.label ?? hostname2(),
4864
+ ...redirect ? { redirect_uri: redirect } : {}
4865
+ });
4866
+ if (r.ok) return r.data;
4867
+ if (r.status === 404 || r.status === 405) {
4868
+ throw new DistillError(
4869
+ "not_found",
4870
+ `${apiUrl} does not support signing in from Claude yet (no /api/v1/device/code). Link with a token from Settings \u2192 Access tokens instead.`
4871
+ );
4872
+ }
4873
+ if (r.code === "network") throw new DistillError("internal", `Could not reach ${apiUrl}: ${r.message}`, void 0, 502);
4874
+ throw new DistillError(r.code, r.message, void 0, r.status);
4875
+ };
4876
+ let local = null;
4877
+ if (opts.loopback !== false && canLaunch) {
4878
+ try {
4879
+ local = await listenLoopback();
4880
+ } catch {
4881
+ local = null;
4882
+ }
4883
+ }
4884
+ let s;
4885
+ try {
4886
+ s = await requestCode(local ? `http://127.0.0.1:${local.port}/callback` : null);
4887
+ } catch (e) {
4888
+ local?.server.close();
4889
+ throw e;
4890
+ }
4891
+ const launched = canLaunch ? await launch(s.verification_uri_complete) : false;
4892
+ if (local && !launched) {
4893
+ local.server.close();
4894
+ local = null;
4895
+ s = await requestCode(null);
4896
+ }
4897
+ const prompt = {
4898
+ verification_uri: s.verification_uri,
4899
+ verification_uri_complete: s.verification_uri_complete,
4900
+ user_code: s.user_code,
4901
+ expires_in: s.expires_in,
4902
+ browser_opened: launched,
4903
+ loopback: local !== null
4904
+ };
4905
+ let cancelled = false;
4906
+ let approvalCode = null;
4907
+ let wake = null;
4908
+ let state = { status: "waiting" };
4909
+ const deadline = Date.now() + s.expires_in * 1e3;
4910
+ let interval = Math.max(1, s.interval) * 1e3;
4911
+ const sleep = (ms) => new Promise((resolve4) => {
4912
+ const t = setTimeout(() => {
4913
+ wake = null;
4914
+ resolve4();
4915
+ }, ms);
4916
+ wake = () => {
4917
+ clearTimeout(t);
4918
+ wake = null;
4919
+ resolve4();
4920
+ };
4921
+ });
4922
+ const poll = async () => {
4923
+ for (; ; ) {
4924
+ if (cancelled) throw new DistillError("expired_token", "Sign-in was cancelled.");
4925
+ if (Date.now() > deadline) throw new DistillError("expired_token", "The sign-in code expired before it was approved. Start again.");
4926
+ const r = await post(apiUrl, "/api/v1/device/token", {
4927
+ device_code: s.device_code,
4928
+ ...approvalCode ? { approval_code: approvalCode } : {}
4929
+ });
4930
+ if (r.ok) return r.data;
4931
+ if (r.code === "authorization_pending" || r.code === "network" || r.status >= 500) {
4932
+ await sleep(interval);
4933
+ continue;
4934
+ }
4935
+ if (r.code === "slow_down") {
4936
+ interval = Math.min(MAX_INTERVAL_MS, interval + 5e3);
4937
+ await sleep(interval);
4938
+ continue;
4939
+ }
4940
+ if (r.code === "access_denied") throw new DistillError("access_denied", "The sign-in was declined in the browser. Nothing was linked.", void 0, 403);
4941
+ throw new DistillError(r.code ?? "expired_token", r.message, void 0, r.status);
4942
+ }
4943
+ };
4944
+ const revoke = async (tok) => {
4945
+ if (!tok.token_id) return;
4946
+ await fetch(new URL(`/api/v1/tokens/${tok.token_id}`, apiUrl), {
4947
+ method: "DELETE",
4948
+ headers: { authorization: `Bearer ${tok.access_token}` }
4949
+ }).catch(() => void 0);
4950
+ };
4951
+ const done = (async () => {
4952
+ const tok = await poll();
4953
+ if (cancelled) {
4954
+ await revoke(tok);
4955
+ throw new DistillError("expired_token", "Sign-in was cancelled.");
4956
+ }
4957
+ let lastErr;
4958
+ for (let attempt = 0; attempt < 3; attempt++) {
4959
+ try {
4960
+ const linked = await linkMachine({
4961
+ apiUrl,
4962
+ token: tok.access_token,
4963
+ ...opts.label ? { label: opts.label } : {},
4964
+ ...opts.profile ? { profile: opts.profile } : {}
4965
+ });
4966
+ return { ...linked, email: tok.email, workspace_name: tok.workspace.name, api_url: apiUrl };
4967
+ } catch (e) {
4968
+ lastErr = e;
4969
+ if (e.code !== "internal") break;
4970
+ await new Promise((r) => setTimeout(r, 1e3 * (attempt + 1)));
4971
+ }
4972
+ }
4973
+ await revoke(tok);
4974
+ const m = lastErr?.message ?? String(lastErr);
4975
+ throw new DistillError(
4976
+ lastErr?.code ?? "internal",
4977
+ `Signed in, but registering this machine failed (${m}). The new key was revoked; run the sign-in again.`
4978
+ );
4979
+ })();
4980
+ done.then(
4981
+ () => {
4982
+ state = { status: "linked" };
4983
+ },
4984
+ (e) => {
4985
+ const err = e;
4986
+ state = { status: "failed", error: { code: err.code ?? "internal", message: err.message } };
4987
+ }
4988
+ );
4989
+ if (local) {
4990
+ const expectedHost = `127.0.0.1:${local.port}`;
4991
+ local.server.on("request", (req, res) => {
4992
+ const url = new URL(req.url ?? "/", "http://127.0.0.1");
4993
+ if (url.pathname !== "/callback" || req.method !== "GET" || req.headers.host !== expectedHost) {
4994
+ res.writeHead(404, { "content-type": "text/plain" }).end("Not found");
4995
+ return;
4996
+ }
4997
+ const status = url.searchParams.get("status");
4998
+ const code = url.searchParams.get("code");
4999
+ if (status === "approved" && code && /^[0-9a-f]{64}$/.test(code)) approvalCode ??= code;
5000
+ else if (status !== "denied") {
5001
+ res.writeHead(400, { "content-type": "text/plain" }).end("Bad request");
5002
+ return;
5003
+ }
5004
+ wake?.();
5005
+ const settled = Promise.race([
5006
+ done.then((r) => ({ ok: true, r }), (e) => ({ ok: false, e })),
5007
+ new Promise((resolve4) => setTimeout(() => resolve4(null), 15e3))
5008
+ ]);
5009
+ void settled.then((out) => {
5010
+ const html = out === null ? resultPage("Almost there", "Approved. Actario is finishing the link on this machine; go back to Claude, it will confirm there.", true) : out.ok ? resultPage("Linked", `This machine is linked to ${out.r.workspace_name ?? "your workspace"}${out.r.email ? ` as ${out.r.email}` : ""}. You can close this tab and go back to Claude.`, true) : resultPage(out.e.code === "access_denied" ? "Declined" : "Not linked", out.e.message, false);
5011
+ res.writeHead(200, { "content-type": "text/html; charset=utf-8", "cache-control": "no-store", "referrer-policy": "no-referrer" }).end(html);
5012
+ });
5013
+ });
5014
+ const server = local.server;
5015
+ const closeLocal = () => setTimeout(() => {
5016
+ server.close();
5017
+ server.closeAllConnections?.();
5018
+ }, 2e4).unref();
5019
+ done.then(closeLocal, closeLocal);
5020
+ server.unref();
5021
+ }
5022
+ return {
5023
+ prompt,
5024
+ done,
5025
+ state: () => state,
5026
+ cancel: () => {
5027
+ cancelled = true;
5028
+ wake?.();
5029
+ }
5030
+ };
5031
+ }
5032
+
5033
+ // ../../apps/cli/src/commands/login.ts
5034
+ async function loginCommand(args) {
5035
+ const device = flagBool(args, "device");
5036
+ const profile = flagString(args, "profile");
5037
+ process.stdout.write(heading("Sign in to Actario"));
5038
+ let login;
5039
+ try {
5040
+ login = await startDeviceLogin({
5041
+ ...flagString(args, "api-url") ? { apiUrl: flagString(args, "api-url") } : {},
5042
+ clientName: "Actario CLI",
5043
+ ...flagString(args, "label") ? { label: flagString(args, "label") } : {},
5044
+ ...profile === "medical" || profile === "general" ? { profile } : {},
5045
+ ...device || flagBool(args, "no-browser") ? { loopback: false, openBrowser: false } : {}
5046
+ });
5047
+ } catch (e) {
5048
+ process.stderr.write(`${red("Could not start the sign-in.")} ${e.message}
5049
+ `);
5050
+ return 1;
5051
+ }
5052
+ const p = login.prompt;
5053
+ if (p.browser_opened) {
5054
+ process.stdout.write(`A browser tab should have opened. If it didn't, open this on THIS machine:
5055
+
5056
+ ${bold(p.verification_uri_complete)}
5057
+
5058
+ ${dim(`If approving ends on a "can't connect" page, press Ctrl-C and run ${bold("actario login --device")} instead.`)}
5059
+ `);
5060
+ } else {
5061
+ process.stdout.write(`On any device, open
5062
+
5063
+ ${bold(p.verification_uri)}
5064
+
5065
+ and enter the code
5066
+
5067
+ ${bold(p.user_code)}
5068
+
5069
+ `);
5070
+ }
5071
+ process.stdout.write(`${dim(`Check the page shows ${p.user_code}. The code expires in ${Math.round(p.expires_in / 60)} minutes.`)}
5072
+ `);
5073
+ process.stdout.write(`${dim("Waiting for approval\u2026")}
5074
+ `);
5075
+ const onInt = () => login.cancel();
5076
+ process.once("SIGINT", onInt);
5077
+ try {
5078
+ const r = await login.done;
5079
+ process.stdout.write(
5080
+ `
5081
+ ${green("Linked")}${r.email ? ` as ${r.email}` : ""} to ${bold(r.workspace_name ?? r.identity.workspace_id ?? "your workspace")}
5082
+ source ${r.source.id}${"label" in r.source && r.source.label ? dim(` (${r.source.label}${r.sourceCreated ? ", created" : ""})`) : ""}
5083
+ saved ${dim(join21(actarioDir(), "config.json"))}
5084
+ ${dim('The key is listed under Settings \u2192 Access tokens as "Claude \xB7 <this machine>"; revoke it there.')}
5085
+ `
5086
+ );
5087
+ process.stdout.write(heading("Sources on this machine"));
5088
+ for (const s of r.sources) {
5089
+ const mark = s.found ? green("found") : yellow("not found");
5090
+ process.stdout.write(` ${s.id.padEnd(24)} ${mark} ${s.found ? dim(`~${s.approxUnits} unit(s)`) : dim(s.note ?? "")}
5091
+ `);
5092
+ }
5093
+ process.stdout.write(`
5094
+ Next: ${bold("actario capture --dry-run")} to see what would be uploaded.
5095
+ `);
5096
+ return 0;
5097
+ } catch (e) {
5098
+ const err = e;
5099
+ process.stderr.write(`
5100
+ ${red(err.code === "access_denied" ? "Declined." : "Not linked.")} ${err.message}
5101
+ `);
5102
+ return 1;
5103
+ } finally {
5104
+ process.off("SIGINT", onInt);
5105
+ }
5106
+ }
5107
+
4752
5108
  // ../../apps/cli/src/commands/init.ts
4753
5109
  async function initCommand(args) {
4754
5110
  const cfg = readConfig();
@@ -4762,10 +5118,14 @@ async function initCommand(args) {
4762
5118
  try {
4763
5119
  process.stdout.write(heading("Actario setup"));
4764
5120
  const apiUrl = flagString(args, "api-url") ?? await ask("API URL", cfg.api_url ?? "http://localhost:3000");
4765
- const token = flagString(args, "token") ?? await ask("Capture token (scope: capture)", cfg.token);
5121
+ const token = flagString(args, "token") ?? await ask("Capture token (empty = sign in with the browser instead)", cfg.token);
4766
5122
  const profile = flagString(args, "profile") ?? await ask("Redaction profile (medical|general)", cfg.redaction_profile);
5123
+ if (apiUrl && !token && interactive) {
5124
+ rl?.close();
5125
+ return loginCommand({ ...args, flags: { ...args.flags, "api-url": apiUrl, ...profile ? { profile } : {} } });
5126
+ }
4767
5127
  if (!apiUrl || !token) {
4768
- process.stderr.write(`${red("Both an API URL and a token are needed.")}
5128
+ process.stderr.write(`${red("Both an API URL and a token are needed.")} Or run ${bold("actario login")} to sign in with the browser.
4769
5129
  `);
4770
5130
  return 1;
4771
5131
  }
@@ -4804,8 +5164,8 @@ Nothing was written.
4804
5164
  `
4805
5165
  ${green("Linked")} as ${dim(r.identity.user_id ?? "user")} to workspace ${dim(r.identity.workspace_id ?? "(first membership)")}
4806
5166
  source ${r.source.id}${"label" in r.source && r.source.label ? dim(` (${r.source.label}${r.sourceCreated ? ", created" : ""})`) : ""}
4807
- saved ${dim(join21(dir, "config.json"))}
4808
- ${dim(`Pseudonym salt at ${join21(dir, "salt")} -- never uploaded, back it up if you care about cross-capture linking.`)}
5167
+ saved ${dim(join22(dir, "config.json"))}
5168
+ ${dim(`Pseudonym salt at ${join22(dir, "salt")} -- never uploaded, back it up if you care about cross-capture linking.`)}
4809
5169
  `
4810
5170
  );
4811
5171
  process.stdout.write(heading("Sources on this machine"));
@@ -4864,12 +5224,12 @@ function apiFromConfig() {
4864
5224
  }
4865
5225
  async function writeGuard() {
4866
5226
  const api = apiFromConfig();
4867
- if (!api) return fail("not_linked", "This machine is not linked to a workspace. Call `link` with an API URL and a capture token first.");
5227
+ if (!api) return fail("not_linked", "This machine is not linked to a workspace. Call `link` first (with no arguments it signs the user in through the browser).");
4868
5228
  let me;
4869
5229
  try {
4870
5230
  me = await whoami(api);
4871
5231
  } catch (e) {
4872
- if (e instanceof DistillError && e.code === "unauthorized") return fail("unauthorized", "The configured token was rejected by the server. Re-link with a fresh token.");
5232
+ if (e instanceof DistillError && e.code === "unauthorized") return fail("unauthorized", "The configured token was rejected by the server (revoked?). Call `link` again to sign in.");
4873
5233
  const msg = e instanceof Error ? e.message : String(e);
4874
5234
  return fail("internal", `Could not verify the token against ${api.baseUrl} (${msg}). Nothing was captured; retry when the API is reachable.`);
4875
5235
  }
@@ -4879,26 +5239,100 @@ async function writeGuard() {
4879
5239
  }
4880
5240
  function buildServer() {
4881
5241
  const server = new McpServer({ name: "actario-capture", version: CLI_VERSION });
5242
+ let pending = null;
5243
+ let starting = null;
5244
+ const linkedBody = (r, via) => ({
5245
+ linked: true,
5246
+ via,
5247
+ ...r.email ? { account: r.email } : {},
5248
+ workspace_id: r.identity.workspace_id,
5249
+ ...r.workspace_name ? { workspace_name: r.workspace_name } : {},
5250
+ source: { id: r.source.id, label: "label" in r.source ? r.source.label : null, created: r.sourceCreated },
5251
+ config_path: `${actarioDir()}/config.json`,
5252
+ sources_on_this_machine: r.sources,
5253
+ next: "Call `capture` (optionally with a `record` of this conversation), then `list_runs`, `read_run`, and `submit_daf`."
5254
+ });
5255
+ const awaitPending = async (seconds) => {
5256
+ if (!pending) return fail("not_found", "No sign-in is in progress. Call `link` to start one.");
5257
+ const p = pending;
5258
+ const out = await Promise.race([
5259
+ p.login.done.then((r) => ({ r }), (e) => ({ e })),
5260
+ new Promise((resolve4) => setTimeout(() => resolve4(null), Math.max(0, seconds) * 1e3))
5261
+ ]);
5262
+ if (out === null) {
5263
+ const left = Math.max(0, Math.round(p.login.prompt.expires_in - (Date.now() - p.startedAt) / 1e3));
5264
+ return ok({
5265
+ linked: false,
5266
+ status: "waiting_for_approval",
5267
+ verification_uri: p.login.prompt.verification_uri,
5268
+ verification_uri_complete: p.login.prompt.verification_uri_complete,
5269
+ user_code: p.login.prompt.user_code,
5270
+ browser_opened: p.login.prompt.browser_opened,
5271
+ expires_in_seconds: left,
5272
+ server: new URL(p.login.prompt.verification_uri).host,
5273
+ tell_the_user: p.login.prompt.browser_opened ? `A browser tab opened at the Actario sign-in page (${new URL(p.login.prompt.verification_uri).host}). Sign in, check the code is ${p.login.prompt.user_code}, pick a workspace and click Approve. (If no tab appeared, open ${p.login.prompt.verification_uri_complete}.)` : `Open ${p.login.prompt.verification_uri} on any device, sign in, and enter the code ${p.login.prompt.user_code}. Then pick a workspace and click Approve.`,
5274
+ next: 'Show the user the URL and code above, then call `link_status` to wait for their approval (it waits up to ~45 s per call; call again if still waiting). If a browser tab opened but approving there fails to come back ("can\'t connect"), call `link` with method: "code".'
5275
+ });
5276
+ }
5277
+ if (pending === p) pending = null;
5278
+ if ("e" in out) return fail(out.e.code ?? "internal", out.e.message);
5279
+ return ok(linkedBody(out.r, "browser"));
5280
+ };
4882
5281
  server.registerTool("link", {
4883
- title: "Link this machine to an Actario workspace",
4884
- description: "Validate a capture token against the API, register (or find) this machine as a source, and save the config. Call once per machine. Refuses agent tokens and tokens without the capture scope. Nothing is written if validation fails.",
5282
+ title: "Link this machine to an Actario account",
5283
+ description: "Connect this machine to the user's Actario workspace so `capture` can upload. With no token (recommended): starts a browser sign-in -- a tab opens on the user's machine where they log in to their own Actario account and approve; if no browser can open, returns a URL and a short code to show the user (they can approve from any device). With a token: validates a capture token pasted from Settings instead. Either way it registers this machine as a source and saves the config. Refuses agent tokens and tokens without the capture scope. Nothing is written until the link succeeds.",
4885
5284
  inputSchema: {
4886
- api_url: z9.string().url().describe("Actario API base URL, e.g. https://distill-web-ten.vercel.app"),
4887
- token: z9.string().min(8).describe("A personal access token with the capture scope, from the web app's Settings page"),
5285
+ api_url: z9.string().url().optional().describe(`Actario base URL. Defaults to the one already configured, else ACTARIO_API_URL, else ${DEFAULT_API_URL}`),
5286
+ token: z9.string().min(8).optional().describe("Only if the user pasted one: a personal access token with the capture scope. Omit to sign in through the browser."),
4888
5287
  label: z9.string().min(1).max(80).optional().describe("Name for this machine on the Sources page. Defaults to the hostname."),
4889
- profile: z9.enum(["general", "medical"]).optional().describe("Redaction profile. medical is one-way and excludes this source from the corpus for good.")
5288
+ profile: z9.enum(["general", "medical"]).optional().describe("Redaction profile. medical is one-way and excludes this source from the corpus for good."),
5289
+ method: z9.enum(["auto", "code"]).optional().describe("Browser sign-in only. auto (default): open a browser on this machine if there is one (it comes back through localhost), else fall back to a code. code: skip the browser; just return a URL + code for the user to approve on any device."),
5290
+ wait_seconds: z9.number().int().min(0).max(55).optional().describe("Browser sign-in only: how long to wait for approval before returning the URL and code. Default 45 if a browser opened, else 0."),
5291
+ switch_server: z9.boolean().optional().describe("Required (true) to link to a different Actario server than the one this machine is linked to now. Only set it after the user confirmed the new URL.")
4890
5292
  }
4891
5293
  }, guarded(async (a) => {
4892
- const r = await linkMachine({ apiUrl: a.api_url, token: a.token, ...a.label ? { label: a.label } : {}, ...a.profile ? { profile: a.profile } : {} });
4893
- return ok({
4894
- linked: true,
4895
- workspace_id: r.identity.workspace_id,
4896
- source: { id: r.source.id, label: "label" in r.source ? r.source.label : null, created: r.sourceCreated },
4897
- config_path: `${actarioDir()}/config.json`,
4898
- sources_on_this_machine: r.sources,
4899
- next: "Call `capture` (optionally with a `record` of this conversation), then `list_runs`, `read_run`, and `submit_daf`."
4900
- });
5294
+ const cfg = readConfig();
5295
+ const target = (a.api_url ?? defaultApiUrl()).replace(/\/+$/, "");
5296
+ if (cfg.api_url && cfg.token && cfg.api_url.replace(/\/+$/, "") !== target && !a.switch_server) {
5297
+ return fail(
5298
+ "confirm_required",
5299
+ `This machine is linked to ${cfg.api_url}. Linking to ${target} instead would send future captures there. Ask the user to confirm that URL, then call \`link\` again with switch_server: true.`
5300
+ );
5301
+ }
5302
+ if (a.token) {
5303
+ pending?.login.cancel();
5304
+ pending = null;
5305
+ const r = await linkMachine({ apiUrl: target, token: a.token, ...a.label ? { label: a.label } : {}, ...a.profile ? { profile: a.profile } : {} });
5306
+ return ok(linkedBody(r, "token"));
5307
+ }
5308
+ const key = JSON.stringify([target, a.method ?? "auto", a.label ?? null, a.profile ?? null]);
5309
+ while (starting) await starting.catch(() => void 0);
5310
+ if (!pending || pending.key !== key || pending.login.state().status !== "waiting") {
5311
+ pending?.login.cancel();
5312
+ pending = null;
5313
+ const p = startDeviceLogin({
5314
+ apiUrl: target,
5315
+ clientName: "Claude (Actario MCP)",
5316
+ ...a.label ? { label: a.label } : {},
5317
+ ...a.profile ? { profile: a.profile } : {},
5318
+ ...a.method === "code" ? { loopback: false, openBrowser: false } : {}
5319
+ });
5320
+ starting = p;
5321
+ try {
5322
+ pending = { login: await p, startedAt: Date.now(), key };
5323
+ } finally {
5324
+ starting = null;
5325
+ }
5326
+ }
5327
+ return awaitPending(a.wait_seconds ?? (pending.login.prompt.browser_opened ? 45 : 0));
4901
5328
  }));
5329
+ server.registerTool("link_status", {
5330
+ title: "Finish a browser sign-in",
5331
+ description: "After `link` returned a URL and code: wait for the user to approve in the browser, then finish linking. Returns linked:true when done, or the same URL/code if they have not approved yet (call again).",
5332
+ inputSchema: {
5333
+ wait_seconds: z9.number().int().min(0).max(55).optional().describe("How long to wait for approval in this call. Default 45.")
5334
+ }
5335
+ }, guarded(async (a) => awaitPending(a.wait_seconds ?? 45)));
4902
5336
  server.registerTool("capture", {
4903
5337
  title: "Capture sessions and upload them",
4904
5338
  description: "Run the capture pipeline on this machine: scan sources, redact, score, pack, upload, and keep the bundle locally for analysis. Pass `record` to capture THIS conversation: a distill.chat/v1 record (turns as said, no summarising, no redacting -- the pipeline redacts, with rules no flag reaches). Without `record`, scans the installed adapters. `dry_run` reports without uploading or changing state. Redaction cannot be disabled here.",
@@ -5135,7 +5569,7 @@ async function mcpCommand(_args) {
5135
5569
  }
5136
5570
 
5137
5571
  // ../../apps/cli/src/commands/reset-state.ts
5138
- import { join as join22 } from "node:path";
5572
+ import { join as join23 } from "node:path";
5139
5573
  async function resetStateCommand(args) {
5140
5574
  const sources = flagList(args, "sources");
5141
5575
  const state = readState();
@@ -5168,7 +5602,7 @@ async function resetStateCommand(args) {
5168
5602
  `
5169
5603
  ${green("Done.")} The next ${bold("actario capture")} will re-read everything from these sources.
5170
5604
  ${dim("The server deduplicates by content hash, so nothing is uploaded twice.")}
5171
- ${dim(`State file: ${join22(actarioDir(), "state.json")}`)}
5605
+ ${dim(`State file: ${join23(actarioDir(), "state.json")}`)}
5172
5606
  `
5173
5607
  );
5174
5608
  return 0;
@@ -5227,7 +5661,7 @@ async function statusCommand(args) {
5227
5661
 
5228
5662
  // ../../apps/cli/src/commands/unmask.ts
5229
5663
  import { existsSync as existsSync8, mkdirSync as mkdirSync7, readFileSync as readFileSync5, readdirSync, statSync, writeFileSync as writeFileSync7 } from "node:fs";
5230
- import { basename as basename2, dirname as dirname4, join as join23, relative, resolve as resolve2, sep } from "node:path";
5664
+ import { basename as basename2, dirname as dirname4, join as join24, relative, resolve as resolve2, sep } from "node:path";
5231
5665
  async function unmaskCommand(args) {
5232
5666
  const input = args.positional[0];
5233
5667
  if (!input) {
@@ -5242,8 +5676,8 @@ async function unmaskCommand(args) {
5242
5676
  return 1;
5243
5677
  }
5244
5678
  const home = actarioDir();
5245
- const saltPath = join23(home, "salt");
5246
- const mapPath = join23(home, "redaction_map.json.enc");
5679
+ const saltPath = join24(home, "salt");
5680
+ const mapPath = join24(home, "redaction_map.json.enc");
5247
5681
  if (!existsSync8(saltPath) || !existsSync8(mapPath)) {
5248
5682
  process.stderr.write(
5249
5683
  `${red("No redaction map on this machine.")} ${dim(`(${mapPath})`)}
@@ -5277,11 +5711,11 @@ ${dim("Pass --out to choose another.")}
5277
5711
  const members = isDir ? readDir(inputPath) : readZip(readFileSync5(inputPath)).map((m) => ({ name: m.name, data: m.data() }));
5278
5712
  const { members: out, report } = unmaskMembers(members, reverse);
5279
5713
  for (const m of out) {
5280
- const target = join23(outDir, ...m.name.split("/"));
5714
+ const target = join24(outDir, ...m.name.split("/"));
5281
5715
  mkdirSync7(dirname4(target), { recursive: true });
5282
5716
  writeFileSync7(target, m.data);
5283
5717
  }
5284
- writeFileSync7(join23(outDir, UNMASK_MARKER_NAME), UNMASK_MARKER_TEXT, { mode: 384 });
5718
+ writeFileSync7(join24(outDir, UNMASK_MARKER_NAME), UNMASK_MARKER_TEXT, { mode: 384 });
5285
5719
  const total = Object.values(report.replaced).reduce((a, b) => a + b, 0);
5286
5720
  process.stdout.write(heading(`Unmasked ${out.length} file(s) \u2192 ${outDir}`));
5287
5721
  if (total === 0) process.stdout.write(` ${dim("No pseudonyms from this machine were found.")}
@@ -5304,13 +5738,13 @@ ${dim("Pass --out to choose another.")}
5304
5738
  function defaultOut(inputPath, isDir) {
5305
5739
  const base = basename2(inputPath);
5306
5740
  const stem = !isDir && base.toLowerCase().endsWith(".zip") ? base.slice(0, -4) : base;
5307
- return join23(dirname4(inputPath), `${stem}.unmasked`);
5741
+ return join24(dirname4(inputPath), `${stem}.unmasked`);
5308
5742
  }
5309
5743
  function readDir(root) {
5310
5744
  const out = [];
5311
5745
  const walk = (dir) => {
5312
5746
  for (const name of readdirSync(dir)) {
5313
- const p = join23(dir, name);
5747
+ const p = join24(dir, name);
5314
5748
  if (statSync(p).isDirectory()) walk(p);
5315
5749
  else out.push({ name: relative(root, p).split(sep).join("/"), data: readFileSync5(p) });
5316
5750
  }
@@ -5327,7 +5761,8 @@ var USAGE = `${bold("actario")} ${dim(`v${CLI_VERSION}`)}
5327
5761
  ${dim("(separate from capture on purpose: a model failure never costs a capture)")}
5328
5762
  actario status [upload_id] local capture state, or one upload's progress
5329
5763
  actario doctor [--schema] diagnose sources and report format changes
5330
- actario init [options] link this machine to a workspace
5764
+ actario login [options] link this machine by signing in with the browser
5765
+ actario init [options] link this machine with a pasted token
5331
5766
  actario reset-state forget the high-water mark and re-read everything
5332
5767
  ${dim("(needed after resetting a development database)")}
5333
5768
  actario unmask <zip|dir> reverse pseudonyms in a downloaded export, locally
@@ -5363,6 +5798,11 @@ ${bold("init options")}
5363
5798
  --api-url URL --token TOKEN --profile medical|general --label NAME
5364
5799
  ${dim("the token is validated first; this machine is registered as a source (--source-id to reuse one)")}
5365
5800
 
5801
+ ${bold("login options")}
5802
+ --device no browser: print a URL + code to approve on any device
5803
+ --no-browser same as --device
5804
+ --api-url URL --label NAME --profile medical|general
5805
+
5366
5806
  ${bold("unmask options")}
5367
5807
  --out DIR write here instead of <name>.unmasked/ next to the input
5368
5808
 
@@ -5393,6 +5833,7 @@ async function main(argv) {
5393
5833
  status: () => statusCommand(args),
5394
5834
  doctor: () => doctorCommand(args),
5395
5835
  init: () => initCommand(args),
5836
+ login: () => loginCommand(args),
5396
5837
  "reset-state": () => resetStateCommand(args),
5397
5838
  unmask: () => unmaskCommand(args),
5398
5839
  mcp: () => mcpCommand(args)
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@actario/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Capture, redact and distil your AI coding sessions into decisions, facts and open questions. Runs on your machine; redaction happens before anything is uploaded.",
5
- "license": "UNLICENSED",
5
+ "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "bin": {
8
8
  "actario": "bin/actario.js"
@@ -10,6 +10,7 @@
10
10
  "files": [
11
11
  "bin",
12
12
  "dist",
13
+ "LICENSE",
13
14
  "README.md"
14
15
  ],
15
16
  "engines": {
@@ -34,5 +35,6 @@
34
35
  "capture",
35
36
  "redaction",
36
37
  "mcp"
37
- ]
38
+ ],
39
+ "homepage": "https://github.com/actario/actario-plugin"
38
40
  }