@agentage/cli 0.58.0 → 0.60.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
@@ -26,7 +26,7 @@ the extensions of your account's profile once; after that each machine keeps its
26
26
 
27
27
  `agentage setup --no-browser` prints the sign-in URL. Open it in a browser on this same machine,
28
28
  because sign-in returns to `localhost`. On a server, use a personal access token from the
29
- dashboard (**Settings -> API tokens**):
29
+ dashboard (**Settings**, then **API tokens**):
30
30
 
31
31
  ```bash
32
32
  AGENTAGE_TOKEN=aga_... agentage status
@@ -48,7 +48,8 @@ More: [docs/reference.md](docs/reference.md#token-auth-ci-and-headless).
48
48
  | `agentage extension ...` | Manage extensions, see [Extensions](#extensions) |
49
49
  | any command with `--json` | One JSON object on stdout: `{ success, data }` or `{ success, error }` |
50
50
 
51
- More: [author commands](docs/extensions.md#author-commands) and [the lifecycle](docs/extensions.md#lifecycle).
51
+ More: [author commands](docs/extensions.md#author-commands) and
52
+ [the lifecycle](docs/reference.md#extension-lifecycle).
52
53
 
53
54
  ## Extensions
54
55
 
@@ -68,8 +69,9 @@ agentage probe ping # run a command by its exten
68
69
  agentage extension remove probe # take it out again; --purge also deletes its data
69
70
  ```
70
71
 
71
- Extensions run in the CLI process with your privileges, so install only ones you trust. npm runs with
72
- `--ignore-scripts`. The account token leaves the environment before extension code loads.
72
+ Extensions run with your privileges, in the daemon and in the CLI process, so install only ones
73
+ you trust. npm runs with `--ignore-scripts`. The account token leaves the environment before
74
+ extension code loads.
73
75
 
74
76
  More: [docs/profiles.md](docs/profiles.md).
75
77
 
@@ -93,16 +95,19 @@ More: [docs/extensions.md](docs/extensions.md#run-it-locally).
93
95
 
94
96
  Everything lives in the config directory, `~/.agentage` by default:
95
97
 
96
- | Path | What |
97
- | --------------------------- | --------------------------------------------------- |
98
- | `~/.agentage/auth.json` | your sign-in, owner-only |
99
- | `~/.agentage/profile.json` | the profile: what this account wants |
100
- | `~/.agentage/machine.json` | this machine's id, name, dev extensions and account |
101
- | `~/.agentage/extensions/` | installed extensions; `current` names the live tree |
102
- | `~/.agentage/state/` | the last run of each extension |
103
- | `~/.agentage/commands.json` | cli 0.51's command holders; read, never written |
104
- | `~/.agentage/secrets.json` | extension secrets, owner-only |
105
- | `~/.agentage/data/<id>/` | what each extension keeps |
98
+ | Path | What |
99
+ | ------------------------------- | ----------------------------------------------------- |
100
+ | `~/.agentage/auth.json` | your sign-in, owner-only |
101
+ | `~/.agentage/profile.json` | the profile: what this account wants |
102
+ | `~/.agentage/machine.json` | this machine's id, name, dev extensions and account |
103
+ | `~/.agentage/installation.json` | this machine's extension list, written by the daemon |
104
+ | `~/.agentage/daemon.json` | the running daemon: pid, port, host token; owner-only |
105
+ | `~/.agentage/extensions/` | installed extensions, one tree per id and version |
106
+ | `~/.agentage/state/` | the last run of each extension |
107
+ | `~/.agentage/commands.json` | cli 0.51's command holders; read, never written |
108
+ | `~/.agentage/secrets.json` | extension secrets, owner-only |
109
+ | `~/.agentage/data/<id>/` | what each extension keeps |
110
+ | `~/.agentage/logs/` | `daemon.log` and each extension's log |
106
111
 
107
112
  `status` writes `machine.json` even before you sign in.
108
113
 
@@ -114,7 +119,8 @@ delete `~/.agentage`.
114
119
  - `setup` registers a one-off OAuth client and waits for the browser on a localhost callback.
115
120
  - Tokens land in `~/.agentage/auth.json` (owner-only) and refresh automatically.
116
121
  - `status` checks the session against the account's introspection endpoint.
117
- - Nothing runs in the background.
122
+ - The daemon is the only background process. It starts when a command needs it and runs until
123
+ `agentage daemon stop`. Nothing installs on a timer.
118
124
 
119
125
  ## Configuration
120
126
 
@@ -124,6 +130,7 @@ delete `~/.agentage`.
124
130
  | `AGENTAGE_CONFIG_DIR` | `~/.agentage` | Config and credentials directory |
125
131
  | `AGENTAGE_TOKEN` | - | Personal access token for CI and headless machines |
126
132
  | `AGENTAGE_EXTENSIONS_DIR` | `<config>/extensions` | Where extensions are installed |
133
+ | `AGENTAGE_DAEMON_PORT` | `4243` | The daemon's port on 127.0.0.1 |
127
134
  | `NO_COLOR` | - | Disable colored output |
128
135
 
129
136
  ## Develop
@@ -139,16 +146,19 @@ npm registry that serves `fixtures/`.
139
146
 
140
147
  ## Release
141
148
 
142
- GitHub Actions publishes to npm when a release PR merges to `master` as a `chore(release): X.Y.Z`
143
- commit that touches `package.json`. It skips a version already on npm.
149
+ Dispatch `prepare-release.yml` (a weekly schedule also dispatches it). It opens a
150
+ `chore(release): X.Y.Z` PR and arms auto-merge. On the merge, `release.yml` runs verify and the
151
+ agentage/e2e cli tier on the packed cli, then publishes to npm with OIDC trusted publishing and
152
+ provenance, and pushes the tag `vX.Y.Z`. It skips a version already on npm.
144
153
 
145
154
  - The publish worked but the tag push failed: push the tag by hand on the release commit
146
- (`git tag v0.52.0 <release commit> && git push origin v0.52.0`); never publish again.
147
- - The agentage/e2e cli tier (`e2e.yml` on a PR) is not a required check; `release.yml` runs only
148
- its `@smoke` tests before the publish. No workflow of this repo runs its lifecycle, execution
149
- and reload tests on a candidate; agentage/e2e runs them on its own PRs against the published cli.
155
+ (`git tag vX.Y.Z <release commit> && git push origin vX.Y.Z`); never publish again.
156
+ - The cli tier failed: fix the cli or the e2e test, then dispatch `release.yml` again.
157
+ - `release.yml` runs only the `@smoke` tests of the agentage/e2e cli tier on the candidate. The
158
+ lifecycle, execution and reload tests of agentage/e2e run on its own PRs against the published
159
+ cli.
150
160
  - Before the release PR merges, check: the PR checks of the release commit are green, and the cli
151
- project of agentage/e2e passes 48 of 48 against the packed tarball of that commit
161
+ project of agentage/e2e passes in full against the packed tarball of that commit
152
162
  (`AGENTAGE_CLI_TARBALL=<tgz> npm run test:cli -- --retries=0`).
153
163
 
154
164
  ## Documentation
@@ -0,0 +1,18 @@
1
+ import { type Command } from 'commander';
2
+ import { type AuthState } from '../../lib/fs/config.js';
3
+ import { type Links } from '../../lib/net/origins.js';
4
+ export interface AuthTokenOptions {
5
+ json?: boolean;
6
+ }
7
+ export interface SessionToken {
8
+ accessToken: string;
9
+ expiresAt: string | null;
10
+ }
11
+ export interface AuthTokenDeps {
12
+ read: () => AuthState | null;
13
+ refresh: (auth: AuthState, links: Links) => Promise<void>;
14
+ now: () => number;
15
+ }
16
+ export declare const MIN_LIFE_MS = 60000;
17
+ export declare const runAuthToken: (opts?: AuthTokenOptions, deps?: AuthTokenDeps) => Promise<SessionToken>;
18
+ export declare const registerAuth: (program: Command, token: (opts: AuthTokenOptions) => Promise<void>) => void;
@@ -0,0 +1,56 @@
1
+ import {} from 'commander';
2
+ import { refreshOrThrow } from '../../lib/auth/api.js';
3
+ import { AuthRequiredError } from '../../lib/auth/auth-errors.js';
4
+ import { credentialLinks } from '../../lib/auth/env-match.js';
5
+ import { readAuth } from '../../lib/fs/config.js';
6
+ import { addJson } from '../../lib/json-output.js';
7
+ import { helpOrUnknown } from '../extension/list.js';
8
+ import {} from '../../lib/net/origins.js';
9
+ const defaultDeps = { read: readAuth, refresh: refreshOrThrow, now: Date.now };
10
+ // A token that lives under this long is refreshed first, so the caller can still use it.
11
+ export const MIN_LIFE_MS = 60_000;
12
+ const fresh = (auth, now) => !!auth && auth.kind !== 'pat' && (auth.tokens.expiresAt ?? 0) - now >= MIN_LIFE_MS;
13
+ // Another process may have rotated the refresh token first: its stored, fresh token serves.
14
+ const refreshed = async (auth, deps) => {
15
+ try {
16
+ await deps.refresh(auth, credentialLinks(auth));
17
+ return auth;
18
+ }
19
+ catch (err) {
20
+ const stored = deps.read();
21
+ if (!(err instanceof AuthRequiredError) || !fresh(stored, deps.now()))
22
+ throw err;
23
+ if (stored.tokens.accessToken === auth.tokens.accessToken)
24
+ throw err;
25
+ return stored;
26
+ }
27
+ };
28
+ // Only the stored session: AGENTAGE_TOKEN (a PAT) is never read here, so it is never printed.
29
+ export const runAuthToken = async (opts = {}, deps = defaultDeps) => {
30
+ const auth = deps.read();
31
+ if (!auth || auth.kind === 'pat')
32
+ throw new AuthRequiredError('not signed in - run: agentage setup');
33
+ const live = fresh(auth, deps.now()) ? auth : await refreshed(auth, deps);
34
+ const { accessToken, expiresAt } = live.tokens;
35
+ // With --json the token goes only into the envelope on stdout, never to stderr.
36
+ if (!opts.json)
37
+ console.log(accessToken);
38
+ return {
39
+ accessToken,
40
+ expiresAt: expiresAt === undefined ? null : new Date(expiresAt).toISOString(),
41
+ };
42
+ };
43
+ const HELP = `
44
+ Prints a short-lived access token of the signed-in session on stdout, refreshed first when it
45
+ expires within 60 s; --json gives { accessToken, expiresAt }. It never prints a personal access
46
+ token (AGENTAGE_TOKEN). Signed out, it exits 1 with auth_required. The desktop uses it.`;
47
+ export const registerAuth = (program, token) => {
48
+ const group = program
49
+ .command('auth', { hidden: true })
50
+ .description('The session of this machine, for other local clients')
51
+ .allowExcessArguments()
52
+ .action(helpOrUnknown);
53
+ addJson(group.command('token').description('Print a fresh session access token'))
54
+ .addHelpText('after', HELP)
55
+ .action(token);
56
+ };
@@ -37,7 +37,9 @@ const registerApi = (program, ext, run) => {
37
37
  };
38
38
  // Manifests only, never code: each stub hands the command line, --help included, to the extension.
39
39
  export const registerDelegates = (program, argv, wrap, tool = loadKitTool) => {
40
- const core = program.commands.map((command) => command.name());
40
+ // Hidden commands (auth, for local clients) stay out of the usage line.
41
+ const shown = program.createHelp().visibleCommands(program);
42
+ const core = shown.map((command) => command.name()).filter((name) => name !== 'help');
41
43
  // The daemon's installation once it exists; before the one-time move, the old lists.
42
44
  const extensions = installedExtensions() ?? loadSet(scan(readMachine() ?? NO_MACHINE));
43
45
  const verbs = claimVerbs(extensions, readHeld());
@@ -1,3 +1,4 @@
1
+ import { runAuthToken } from './commands/auth/token.js';
1
2
  import {} from './commands/auth/setup.js';
2
3
  import { runDaemonRestart, runDaemonStatus, runDaemonStop } from './commands/daemon/daemon.js';
3
4
  import { runDaemonStart } from './commands/daemon/start.js';
@@ -70,6 +71,7 @@ export const defaultDeps = {
70
71
  }),
71
72
  status: (opts) => runStatus(opts),
72
73
  update: (opts) => runUpdate(opts),
74
+ authToken: (opts) => runAuthToken(opts),
73
75
  extensionInstall: (opts) => runInstall(opts, { ...lifecycle, fromNpm, hasMarket, sealOff }),
74
76
  extensionRemove: (opts) => runRemove(opts, { ...lifecycle, io: terminalIo() }),
75
77
  extensionList: (opts) => runList(opts, listDeps),
package/dist/program.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Command } from 'commander';
2
2
  import { type SetupOptions } from './commands/auth/setup.js';
3
+ import { type AuthTokenOptions } from './commands/auth/token.js';
3
4
  import { type DaemonOptions } from './commands/daemon/daemon.js';
4
5
  import { type ExtensionBuildOptions, type ExtensionCheckOptions } from './commands/extension/build.js';
5
6
  import { type ExtensionCreateOptions } from './commands/extension/create.js';
@@ -17,6 +18,7 @@ export interface ProgramDeps {
17
18
  setup: Run<SetupOptions>;
18
19
  status: Run<StatusOptions>;
19
20
  update: Run<UpdateOptions>;
21
+ authToken: Run<AuthTokenOptions>;
20
22
  extensionInstall: Run<InstallOptions>;
21
23
  extensionRemove: Run<RemoveOptions>;
22
24
  extensionList: Run<ListOptions>;
package/dist/program.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import chalk from 'chalk';
2
2
  import { Command, CommanderError } from 'commander';
3
3
  import { registerSetup } from './commands/auth/setup.js';
4
+ import { registerAuth } from './commands/auth/token.js';
4
5
  import { registerDaemon } from './commands/daemon/daemon.js';
5
6
  import {} from './commands/extension/build.js';
6
7
  import {} from './commands/extension/create.js';
@@ -68,6 +69,7 @@ export const createProgram = (deps = defaultDeps, argv = process.argv) => {
68
69
  registerSetup(program, withAction(deps, deps.setup, 'Setup failed: ', (o) => !!(o.dryRun || o.check)));
69
70
  registerStatus(program, withAction(deps, deps.status, '', pinned));
70
71
  registerUpdate(program, withAction(deps, deps.update));
72
+ registerAuth(program, withAction(deps, deps.authToken));
71
73
  const daemon = (fn) => withAction(deps, fn);
72
74
  registerDaemon(program, {
73
75
  start: daemon(deps.daemon.start),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentage/cli",
3
- "version": "0.58.0",
3
+ "version": "0.60.0",
4
4
  "description": "The agentage CLI - connect this machine to agentage from the terminal",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -54,7 +54,7 @@
54
54
  "prepublishOnly": "npm run verify"
55
55
  },
56
56
  "dependencies": {
57
- "@agentage/extension": "0.18.1",
57
+ "@agentage/extension": "0.18.2",
58
58
  "@electric-sql/pglite": "^0.5.16",
59
59
  "@tailwindcss/postcss": "^4.3.5",
60
60
  "chalk": "^6.0.0",