@aragon-agent/cli 0.6.71 → 0.6.73

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/CHANGELOG.md CHANGED
@@ -44,6 +44,14 @@ were written.
44
44
 
45
45
  ### Fixed
46
46
 
47
+ - **`Ctrl+Y` can no longer approve a tool, delete a prompt page or sign the waiver.**
48
+ Ink reports every C0 byte `0x01`-`0x1a` as its letter plus `key.ctrl`, so `Ctrl+Y` reaches a handler as
49
+ `input === 'y'` with `ctrl` set - and three handlers read a bare `y`: the tool-approval dialog
50
+ (`y approve`), the prompt library's delete page and the red-team disclaimer (`y` = sign). One keystroke on
51
+ a chord nobody associates with consent could therefore approve a mutating tool. All three now require an
52
+ unmodified `y` (`!key.ctrl && !key.meta`, with `Esc` explicitly exempt because a lone `Esc` arrives with
53
+ `meta` set as well), and `Ctrl+X` - measured free across the whole package - is the account panel's key
54
+ instead of the `Y` the first draft picked.
47
55
  - **Changing the round budget on the desktop no longer answers with a refusal.** At `auto`, `Ctrl+Up`
48
56
  (and the chip's `+`) left the value alone and printed an edge judgement, so the one gesture a user
49
57
  tries - "give me my own number" - looked broken. `auto` now has a real number neighbour in BOTH
@@ -135,6 +143,27 @@ were written.
135
143
 
136
144
  ### Added
137
145
 
146
+ - **The TUI says who you are signed in as, and `Ctrl+X` opens an account panel.**
147
+ After `/login`, the header carries `● <username>` immediately left of `^G more` - green while the
148
+ credential is usable, amber inside the last three days, hollow red `○` once it has expired, and `*` / `o`
149
+ on a terminal without Unicode, so the shape carries the state where the colour cannot. Nothing is drawn
150
+ while signed out, and that frame is byte-identical to the one before this change: a user who never signed
151
+ in loses no cell. The block caps the name at 12 cells and drops itself entirely on a terminal too narrow to
152
+ pay for it, so `provider:model` and `^G more` survive (at 80 columns the 7 cells come out of the task
153
+ summary: 19 → 12 cells, the model name keeps all 36).
154
+ `Ctrl+X` / `Alt+X` / `/account` open a panel that shows the username, email, user id, scopes, the token
155
+ prefix (`(prefix only)` - the panel's input type has no field for the plaintext), the issued and expiry
156
+ dates, the credential path and the server, and offers `Enter` (sign in or renew, through the same device
157
+ flow as `/login`), `x` (sign out - twice: the first press arms, `Esc` or any other key disarms) and `r`
158
+ (re-read the file after a sign-in done in another terminal). The panel opens while signed out too and says
159
+ what Enter would do. The identity is propped into the TUI (`tui` may not read the CLI's credential), the
160
+ snapshot is re-read on exactly five low-frequency events (mount, a finished sign-in, a sign-out, `r`, and a
161
+ one-minute look for another terminal), and every frame after that derives the state from `expiresAt` with a
162
+ pure function - so a credential that runs out mid-session changes colour without a restart and without a
163
+ synchronous read per streamed token. `Ctrl+G` lists the new key (and `/help` with it), and the `/account`
164
+ row is byte-identical in the registry, the command catalog and the guide. `Ctrl+Y` was the first choice and
165
+ is deliberately unused: on a terminal it arrives as a plain `y`, which three surfaces in this app treat as
166
+ a decision (see the `Ctrl+Y` fix below).
138
167
  - **Agent memory writes are autonomous by default: one approval for a bulk change, a journal and undo for
139
168
  everything else.** `memory.agentWrites` now defaults to `auto`, so a small change is applied on the
140
169
  model's own hand instead of waiting behind a preview card. Three things make that safe rather than
package/README.md CHANGED
@@ -997,6 +997,7 @@ completes, `Up` / `Down` moves the selection, `Esc` closes it.
997
997
  | `Ctrl+N` | The same toggle, over a channel no Windows console can swallow. Use it if `Shift+Tab` does nothing. Written `Ctrl+N` everywhere, never `^N` - `^N` is the header's line-offset chip |
998
998
  | `Ctrl+P` | **Quick prompt library**: the manager - create, edit, delete, favourite and reorder your own prompts. See [Quick prompt library](#quick-prompt-library) |
999
999
  | `Ctrl+M` / `Alt+M` | **Memory manager**: save, edit, search and mount the notes AragonAgent remembers across sessions. `Ctrl+M` is the same byte as `Enter` on a terminal without keyboard enhancement (Windows Terminal, kitty, iTerm2 and WezTerm have it), where it still submits the draft exactly as before - use `Alt+M` or `/memory` there. `t` in the manager opens the activity page (what changed recently, one line each) and `u` on a row undoes that batch after a `y` - the same `/memory activity` / `/memory undo`. See [Memory](#memory) |
1000
+ | `Ctrl+X` / `Alt+X` | **Account panel**: who you are signed in as, the credential's expiry, and the three things you can do about it - `Enter` signs in or renews, `x` signs out (twice: the first press only arms it), `r` re-reads the file after a sign-in done in another terminal. `Alt+X` works where the terminal swallows `Ctrl+X`; `/account` always works. While you are signed in, the header shows the same identity as `● ada` immediately left of `^G more` (green = usable, amber = three days or fewer left, hollow red `○` = expired), and signed out it shows nothing at all. See [Signed-in identity and the account panel](#signed-in-identity-and-the-account-panel). `Ctrl+Y` is deliberately NOT this key: on a terminal `Ctrl+Y` arrives as a plain `y`, and three surfaces in this app read a plain `y` |
1000
1001
  | `Ctrl+B` | **Agents board**: the details of a running dispatch. Left column lists every child (not just the five the roster fits), the right-hand sections show the selected child's state, turns, tools, tokens, files, mail, supervisor actions, retries, compaction, its current activity, its final answer or error, and the last 24 events. `Up` / `Down` change the child, `PgUp` / `PgDn` and the wheel page, `Esc` closes. The board survives the end of the dispatch - it freezes the last live snapshot and marks it `dispatch ended` - and opens after the fact from the session's own team card, where everything except the live-only sections (current activity, mail count, timeline) is still readable. Pressing `Ctrl+B` again, or `/agents`, opens and closes it |
1001
1002
  | `Ctrl+I` | **Build the project index** (bundled `project-indexer` skill). Asks for confirmation, then writes `.claude-index/` and matching `CLAUDE.md` / `AGENTS.md`, including rules for results in `runs/` and temporary-file checks. On terminals without keyboard enhancement `Ctrl+I` is the Tab byte and completes input instead |
1002
1003
  | `Ctrl+K` | **Agent kits**: pick a model preset — main / subagent / fast profile in one choice — for **this session only**. Nothing is written to the config file. `Current setup` (the first row) releases the preset and returns to the file's bindings. See [Agent kits](#agent-kits) |
@@ -1110,6 +1111,25 @@ is what it used to do. Inline mode is unaffected either way.
1110
1111
  | `aragon config set taskSummary.enabled false` | 关掉摘要与那次模型调用 |
1111
1112
  | `aragon config set taskSummary.fallback false` | 失败时显示空,而不是用户原话前缀 |
1112
1113
 
1114
+ ## Signed-in identity and the account panel
1115
+
1116
+ 一旦你用 `/login` 通过 OAuth 登录,头部就会常驻你的身份:`^G more` 左边出现一个绿点
1117
+ 加用户名(`● ada ^G more`),多长都不挤掉 `provider:model` —— 名字超过 12 格会被
1118
+ 省略号截断,终端太窄时整块先让位。没登录就**一格都不占**,帧与没这个功能时逐字节相同。
1119
+
1120
+ - **三个状态,形状先于颜色**:可用是实心 `●`(绿)、剩 3 天以内变琥珀、过期变空心
1121
+ `○`(红)。`colorLevel: 0` 或纯 ASCII 终端上是 `*` / `o`,形状本身就是信号。
1122
+ 运行中到期不需要重启:每一帧都用 `expiresAt` 重算一次,不读盘。
1123
+ - **`Ctrl+X` / `Alt+X` / `/account` 三路打开面板**。面板上半是事实(用户名、邮箱、用户
1124
+ id、scopes、token 前缀、签发与到期时间、凭证文件路径、服务器),下半是动作:`Enter`
1125
+ 登录/续期(走设备码流程,和 `/login` 同一个面板)、`x` 登出、`r` 重读凭证、`Esc`
1126
+ 关闭。登出要按两次:第一下只是把确认「上膛」,再按别的键就撤销。
1127
+ - **邮件只出现在面板里,不上头部**:头部在每一张截图、每一次共享屏幕里,够用就好。
1128
+ - **永远不显示明文 token**:结构上就拿不到,只有 `aragon_pat_ab12cd34... (prefix only)`。
1129
+ - **未登录也能打开**,并且会说清 `Enter` 能做什么 —— 一个按了没反应的面板等于坏功能。
1130
+ - 凭证文件是 `<ARAGON_HOME>/account.json`;另一个终端里 `/login` 或 `/logout` 之后,
1131
+ 这里一分钟内会跟上,`r` 是立刻跟上。
1132
+
1113
1133
  ## Quick prompt library
1114
1134
 
1115
1135
  `↑` history remembers what you said. It does not remember what you say *every*
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Every URL and protocol constant the CLI's account layer needs, in one place.
3
+ *
4
+ * WHY A MODULE AND NOT LITERALS AT THE CALL SITES: the base URL is user-selectable
5
+ * (`ARAGON_WEB_URL`), and the device-flow constants are a contract with `apps/web`
6
+ * (C1 / C2). Two copies of `/api/device/token` is exactly the shape that lets a
7
+ * rename land in one of them and not the other, and the failure is a login that
8
+ * polls a 404 forever.
9
+ *
10
+ * THE BASE URL IS NEVER DERIVED FROM THE RESPONSE: the server tells us where to
11
+ * send the user (`verification_uri_complete`), but `baseUrl` stays what the user
12
+ * chose, and it is what gets written into `account.json` (C3), so `aragon whoami`
13
+ * can say which site issued the credential.
14
+ *
15
+ * ASCII ONLY - `src/account/**` renders text a user reads.
16
+ */
17
+ /** Where the device flow talks when nobody says otherwise (spec section 1). */
18
+ export declare const DEFAULT_WEB_BASE_URL = "https://aragonagent.com";
19
+ /** RFC 8628 section 3.1: the client identifier the web side has allow-listed (C1). */
20
+ export declare const DEVICE_CLIENT_ID = "aragon-cli";
21
+ /** The only scope a device grant may request (C1). */
22
+ export declare const DEVICE_SCOPE = "account:read";
23
+ /** RFC 8628 section 3.4 grant type, verbatim: the server compares it byte for byte. */
24
+ export declare const DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
25
+ export declare const DEVICE_CODE_PATH = "/api/device/code";
26
+ export declare const DEVICE_TOKEN_PATH = "/api/device/token";
27
+ export declare const ACCOUNT_ME_PATH = "/api/v1/me";
28
+ /**
29
+ * Polling bounds.
30
+ *
31
+ * `MAX_POLL_INTERVAL_SECONDS` is the SAME 60 the web side caps its own interval
32
+ * at (`DEVICE_INTERVAL_MAX_SECONDS`), and it is not negotiable from this side: a
33
+ * client that waits less than the server asked gets `slow_down` forever, and a
34
+ * client that waits more than 60 s keeps a terminal idle for no reason.
35
+ */
36
+ export declare const MIN_POLL_INTERVAL_SECONDS = 1;
37
+ export declare const MAX_POLL_INTERVAL_SECONDS = 60;
38
+ export declare const SLOW_DOWN_STEP_SECONDS = 5;
39
+ export declare const DEFAULT_POLL_INTERVAL_SECONDS = 5;
40
+ /**
41
+ * `https://host[:port][/path]` without a trailing slash, or `null` when `raw` is
42
+ * not an absolute http(s) URL.
43
+ *
44
+ * A TRAILING SLASH IS THE BUG THIS EXISTS FOR: `${base}/api/device/code` with a
45
+ * base of `https://x/` is `https://x//api/device/code`, which some servers 404
46
+ * and others rewrite, and neither failure says why. Query and fragment are
47
+ * dropped rather than rejected - they cannot be part of a base URL and a user
48
+ * who pasted one meant the origin.
49
+ */
50
+ export declare function normaliseBaseUrl(raw: string | null | undefined): string | null;
51
+ /**
52
+ * `ARAGON_WEB_URL` -> the default. Never throws, never returns `''`.
53
+ *
54
+ * AN ILLEGAL VALUE FALLS BACK RATHER THAN FAILING: the alternative is a login
55
+ * command that refuses to start because of a typo in a shell profile, and the
56
+ * user has no way to tell that from "sign-in is down". The fallback is the
57
+ * public site, which is what an unset variable means anyway.
58
+ */
59
+ export declare function resolveWebBaseUrl(env?: NodeJS.ProcessEnv): string;
60
+ /** `https://host/api/device/code`; `baseUrl` is expected to be normalised. */
61
+ export declare function apiUrl(baseUrl: string, path: string): string;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Every URL and protocol constant the CLI's account layer needs, in one place.
3
+ *
4
+ * WHY A MODULE AND NOT LITERALS AT THE CALL SITES: the base URL is user-selectable
5
+ * (`ARAGON_WEB_URL`), and the device-flow constants are a contract with `apps/web`
6
+ * (C1 / C2). Two copies of `/api/device/token` is exactly the shape that lets a
7
+ * rename land in one of them and not the other, and the failure is a login that
8
+ * polls a 404 forever.
9
+ *
10
+ * THE BASE URL IS NEVER DERIVED FROM THE RESPONSE: the server tells us where to
11
+ * send the user (`verification_uri_complete`), but `baseUrl` stays what the user
12
+ * chose, and it is what gets written into `account.json` (C3), so `aragon whoami`
13
+ * can say which site issued the credential.
14
+ *
15
+ * ASCII ONLY - `src/account/**` renders text a user reads.
16
+ */
17
+ import process from 'node:process';
18
+ /** Where the device flow talks when nobody says otherwise (spec section 1). */
19
+ export const DEFAULT_WEB_BASE_URL = 'https://aragonagent.com';
20
+ /** RFC 8628 section 3.1: the client identifier the web side has allow-listed (C1). */
21
+ export const DEVICE_CLIENT_ID = 'aragon-cli';
22
+ /** The only scope a device grant may request (C1). */
23
+ export const DEVICE_SCOPE = 'account:read';
24
+ /** RFC 8628 section 3.4 grant type, verbatim: the server compares it byte for byte. */
25
+ export const DEVICE_GRANT_TYPE = 'urn:ietf:params:oauth:grant-type:device_code';
26
+ export const DEVICE_CODE_PATH = '/api/device/code';
27
+ export const DEVICE_TOKEN_PATH = '/api/device/token';
28
+ export const ACCOUNT_ME_PATH = '/api/v1/me';
29
+ /**
30
+ * Polling bounds.
31
+ *
32
+ * `MAX_POLL_INTERVAL_SECONDS` is the SAME 60 the web side caps its own interval
33
+ * at (`DEVICE_INTERVAL_MAX_SECONDS`), and it is not negotiable from this side: a
34
+ * client that waits less than the server asked gets `slow_down` forever, and a
35
+ * client that waits more than 60 s keeps a terminal idle for no reason.
36
+ */
37
+ export const MIN_POLL_INTERVAL_SECONDS = 1;
38
+ export const MAX_POLL_INTERVAL_SECONDS = 60;
39
+ export const SLOW_DOWN_STEP_SECONDS = 5;
40
+ export const DEFAULT_POLL_INTERVAL_SECONDS = 5;
41
+ /**
42
+ * `https://host[:port][/path]` without a trailing slash, or `null` when `raw` is
43
+ * not an absolute http(s) URL.
44
+ *
45
+ * A TRAILING SLASH IS THE BUG THIS EXISTS FOR: `${base}/api/device/code` with a
46
+ * base of `https://x/` is `https://x//api/device/code`, which some servers 404
47
+ * and others rewrite, and neither failure says why. Query and fragment are
48
+ * dropped rather than rejected - they cannot be part of a base URL and a user
49
+ * who pasted one meant the origin.
50
+ */
51
+ export function normaliseBaseUrl(raw) {
52
+ const text = raw?.trim();
53
+ if (!text)
54
+ return null;
55
+ let url;
56
+ try {
57
+ url = new URL(text);
58
+ }
59
+ catch {
60
+ return null;
61
+ }
62
+ if (url.protocol !== 'https:' && url.protocol !== 'http:')
63
+ return null;
64
+ if (url.hostname.length === 0)
65
+ return null;
66
+ const path = url.pathname.replace(/\/+$/, '');
67
+ return `${url.protocol}//${url.host}${path}`;
68
+ }
69
+ /**
70
+ * `ARAGON_WEB_URL` -> the default. Never throws, never returns `''`.
71
+ *
72
+ * AN ILLEGAL VALUE FALLS BACK RATHER THAN FAILING: the alternative is a login
73
+ * command that refuses to start because of a typo in a shell profile, and the
74
+ * user has no way to tell that from "sign-in is down". The fallback is the
75
+ * public site, which is what an unset variable means anyway.
76
+ */
77
+ export function resolveWebBaseUrl(env = process.env) {
78
+ return normaliseBaseUrl(env.ARAGON_WEB_URL) ?? DEFAULT_WEB_BASE_URL;
79
+ }
80
+ /** `https://host/api/device/code`; `baseUrl` is expected to be normalised. */
81
+ export function apiUrl(baseUrl, path) {
82
+ return `${baseUrl.replace(/\/+$/, '')}${path}`;
83
+ }
@@ -0,0 +1,113 @@
1
+ /**
2
+ * The RFC 8628 device-flow client (C1), with no UI and no ambient clock.
3
+ *
4
+ * TWO CALLS AND A STATE MACHINE:
5
+ *
6
+ * start() -> POST {baseUrl}/api/device/code {client_id, scope}
7
+ * poll() -> POST {baseUrl}/api/device/token {grant_type, device_code, client_id}
8
+ *
9
+ * EVERYTHING IS INJECTED - `fetch`, the clock and `sleep`. That is not test
10
+ * decoration: the polling loop's whole contract is about TIME (the server's
11
+ * interval, the `slow_down` growth, the 60 s cap, the `expires_in` ceiling), and
12
+ * a test that waits those seconds is a test nobody runs. With `now` and `sleep`
13
+ * as dependencies the intervals are data a fake clock can measure, and the
14
+ * shipped defaults are the only place a real timer exists.
15
+ *
16
+ * WHAT THIS MODULE REFUSES TO DO, each for a reason:
17
+ *
18
+ * - Never treat a non-200 as success, and never read the site's
19
+ * `{"error":{"code":...}}` envelope (C1). The device endpoints answer in the
20
+ * OAuth shape `{"error":"authorization_pending"}`; an object where a string
21
+ * belongs means this is not the endpoint we think it is, which is an error,
22
+ * not a token.
23
+ * - Never log or embed the `device_code` or the `access_token`. The token is
24
+ * returned to the caller and registered with the redactor there; the device
25
+ * code is a 34.6-bit credential that would let anyone redeem the grant.
26
+ * - Never poll past `expires_in`. The loop stops before a wait that would end
27
+ * after the deadline, so a terminal cannot sit there one interval too long
28
+ * holding a grant the server has already deleted.
29
+ * - Never spin: `authorization_pending` waits the server's interval, 429 waits
30
+ * the server's `retry-after`, and a transport failure backs off exponentially
31
+ * from the interval, capped at the same 60 s the server caps its own interval
32
+ * at. `maxNetworkRetries` bounds the backoff.
33
+ */
34
+ /** A whole request may not hang longer than this. */
35
+ export declare const DEFAULT_REQUEST_TIMEOUT_MS = 10000;
36
+ /** Consecutive transport failures before `poll()` gives up. */
37
+ export declare const DEFAULT_MAX_NETWORK_RETRIES = 5;
38
+ /** A 429 without a usable `retry-after` header waits this long. */
39
+ export declare const DEFAULT_RETRY_AFTER_SECONDS = 5;
40
+ export interface DeviceCodeInfo {
41
+ readonly deviceCode: string;
42
+ readonly userCode: string;
43
+ readonly verificationUri: string;
44
+ readonly verificationUriComplete: string;
45
+ readonly expiresInSec: number;
46
+ readonly intervalSec: number;
47
+ }
48
+ export interface DeviceTokenInfo {
49
+ readonly accessToken: string;
50
+ readonly tokenType: string;
51
+ readonly expiresInSec: number;
52
+ readonly scope: string;
53
+ readonly tokenPrefix: string;
54
+ }
55
+ export type DeviceCodeResult = {
56
+ readonly kind: 'code';
57
+ readonly code: DeviceCodeInfo;
58
+ } | {
59
+ readonly kind: 'invalid';
60
+ readonly message: string;
61
+ } | {
62
+ readonly kind: 'network';
63
+ readonly message: string;
64
+ } | {
65
+ readonly kind: 'cancelled';
66
+ };
67
+ export type DevicePollResult = {
68
+ readonly kind: 'token';
69
+ readonly token: DeviceTokenInfo;
70
+ } | {
71
+ readonly kind: 'denied';
72
+ } | {
73
+ readonly kind: 'expired';
74
+ } | {
75
+ readonly kind: 'invalid';
76
+ readonly message: string;
77
+ } | {
78
+ readonly kind: 'network';
79
+ readonly message: string;
80
+ } | {
81
+ readonly kind: 'cancelled';
82
+ };
83
+ export interface PollInput {
84
+ readonly code: DeviceCodeInfo;
85
+ readonly signal?: AbortSignal;
86
+ readonly onProgress?: (progress: {
87
+ readonly elapsedSec: number;
88
+ }) => void;
89
+ }
90
+ export interface DeviceClientDeps {
91
+ readonly baseUrl: string;
92
+ readonly fetchImpl?: typeof fetch;
93
+ readonly now?: () => number;
94
+ /** Resolves after `ms`, or as soon as `signal` aborts. Injected in tests. */
95
+ readonly sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
96
+ readonly maxNetworkRetries?: number;
97
+ readonly requestTimeoutMs?: number;
98
+ }
99
+ export interface DeviceClient {
100
+ start(options?: {
101
+ readonly signal?: AbortSignal;
102
+ }): Promise<DeviceCodeResult>;
103
+ poll(input: PollInput): Promise<DevicePollResult>;
104
+ }
105
+ /**
106
+ * Build a client bound to one origin.
107
+ *
108
+ * A FACTORY RATHER THAN MODULE STATE: the base URL is per-login (the user may
109
+ * point `ARAGON_WEB_URL` at staging), and a module-level singleton would leak
110
+ * one login's origin into the next. The object is cheap; callers create one per
111
+ * `startLogin`.
112
+ */
113
+ export declare function createDeviceClient(deps: DeviceClientDeps): DeviceClient;