@agentage/cli 0.64.0 → 0.65.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/dist/commands/extension/lifecycle-list.js +8 -0
- package/dist/commands/status/status.js +3 -0
- package/dist/lib/auth/callback-page.d.ts +1 -1
- package/dist/lib/auth/callback-page.js +16 -3
- package/dist/lib/auth/callback-server.d.ts +1 -1
- package/dist/lib/auth/callback-server.js +4 -2
- package/dist/lib/auth/return-link.d.ts +2 -0
- package/dist/lib/auth/return-link.js +8 -0
- package/dist/lib/auth/sign-in.js +2 -1
- package/dist/lib/update/update-cache.d.ts +1 -0
- package/dist/lib/update/update-cache.js +5 -0
- package/package.json +2 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
1
2
|
import {} from '../../lib/daemon/host-client.js';
|
|
2
3
|
import { CliError, messageOf, WithMeta } from '../../lib/json-output.js';
|
|
3
4
|
import {} from '../../lib/net/market.js';
|
|
@@ -29,11 +30,18 @@ const available = async (deps) => {
|
|
|
29
30
|
console.error(`skipped ${skipped.map((s) => `${s.id} (${s.reason})`).join(', ')}`);
|
|
30
31
|
return new WithMeta(offered, { skipped });
|
|
31
32
|
};
|
|
33
|
+
// A failed folder row whose folder is gone (a deleted worktree) can only be removed.
|
|
34
|
+
const goneHints = (rows) => {
|
|
35
|
+
for (const r of rows)
|
|
36
|
+
if (r.state === 'failed' && typeof r['path'] === 'string' && !existsSync(r['path']))
|
|
37
|
+
console.error(`${r.id}: its folder is gone; remove the row: agentage extension remove ${r.id}`);
|
|
38
|
+
};
|
|
32
39
|
export const runList = async (opts, deps) => {
|
|
33
40
|
if (opts.available)
|
|
34
41
|
return available(deps);
|
|
35
42
|
const rows = (await (await deps.host()).list()).map(shown);
|
|
36
43
|
printRows(rows);
|
|
44
|
+
goneHints(rows);
|
|
37
45
|
return rows;
|
|
38
46
|
};
|
|
39
47
|
// The market's newest. A market that answers without the id keeps the installed version (one
|
|
@@ -4,6 +4,7 @@ import { resolveAuth } from '../../lib/auth/credentials.js';
|
|
|
4
4
|
import { daemonOfStatus } from './status-daemon.js';
|
|
5
5
|
import { DEFAULT_FQDN, siteFqdn } from '../../lib/net/origins.js';
|
|
6
6
|
import { gatherStatus } from '../../lib/status/status-info.js';
|
|
7
|
+
import { markUpdateReported } from '../../lib/update/update-cache.js';
|
|
7
8
|
import { INSTALL_HINT } from '../../lib/update/update-check.js';
|
|
8
9
|
import { signedInAccount } from '../extension/account.js';
|
|
9
10
|
import { printWarnings, summaryLines } from '../extension/row-lines.js';
|
|
@@ -43,6 +44,8 @@ const updateLine = (update) => {
|
|
|
43
44
|
export const printStatus = (report) => {
|
|
44
45
|
row('version', report.version);
|
|
45
46
|
row('update', updateLine(report.update));
|
|
47
|
+
if (report.update.status.kind !== 'unknown')
|
|
48
|
+
markUpdateReported();
|
|
46
49
|
const t = report.target;
|
|
47
50
|
const targetSuffix = t.reachable ? '' : ' - unreachable';
|
|
48
51
|
// "production" is the default site only: any other production-shaped fqdn came from the override.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const escapeHtml: (text: string) => string;
|
|
2
|
-
export declare const callbackPage: (ok: boolean, detail: string) => string;
|
|
2
|
+
export declare const callbackPage: (ok: boolean, detail: string, returnLink?: string) => string;
|
|
@@ -19,6 +19,8 @@ box-shadow:0 10px 15px -3px oklch(0 0 0/.1),0 4px 6px -4px oklch(0 0 0/.1)}
|
|
|
19
19
|
h1{font-size:1.25rem;font-weight:600;letter-spacing:-.02em;margin-bottom:8px}
|
|
20
20
|
p{color:oklch(0.59 0.014 256);font-size:.875rem;line-height:1.5}
|
|
21
21
|
.hint{margin-top:24px;font-size:.75rem;color:oklch(0.59 0.014 256)}
|
|
22
|
+
.open{display:inline-block;margin-top:20px;padding:8px 16px;border-radius:.5rem;font-size:.875rem;
|
|
23
|
+
font-weight:600;background:#f3a52b;color:#000;text-decoration:none}
|
|
22
24
|
`;
|
|
23
25
|
const ICON = {
|
|
24
26
|
ok: '<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg>',
|
|
@@ -27,14 +29,25 @@ const ICON = {
|
|
|
27
29
|
const ESCAPES = { '&': '&', '<': '<', '>': '>', '"': '"' };
|
|
28
30
|
// The error text comes from the authorization server's redirect: never trust it as markup.
|
|
29
31
|
export const escapeHtml = (text) => text.replace(/[&<>"]/g, (c) => ESCAPES[c] ?? c);
|
|
30
|
-
|
|
32
|
+
// A success with a return link (the desktop deep link) hands over to the app; the text stays.
|
|
33
|
+
const handOver = (link) => {
|
|
34
|
+
if (!link)
|
|
35
|
+
return { head: '', body: '' };
|
|
36
|
+
const href = escapeHtml(link);
|
|
37
|
+
return {
|
|
38
|
+
head: `<meta http-equiv="refresh" content="0;url=${href}">`,
|
|
39
|
+
body: `<a class="open" href="${href}">Open the agentage app</a>`,
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export const callbackPage = (ok, detail, returnLink) => {
|
|
31
43
|
const kind = ok ? 'ok' : 'err';
|
|
32
44
|
const title = ok ? 'Signed in' : 'Sign-in failed';
|
|
33
45
|
const hint = ok ? 'You can close this tab.' : 'Run agentage setup again to retry.';
|
|
34
|
-
|
|
46
|
+
const back = handOver(ok ? returnLink : undefined);
|
|
47
|
+
return (`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">${back.head}` +
|
|
35
48
|
`<title>${title} - agentage</title><style>${STYLE}</style></head><body><main class="card ${kind}">` +
|
|
36
49
|
`<div class="brand"><svg viewBox="0 0 416 416" aria-hidden="true"><rect width="416" height="416" rx="83" fill="#f3a52b"/>` +
|
|
37
50
|
`<g transform="translate(25.7 25.7) scale(1.3812)"><path d="${LOGO}" fill="#000"/></g></svg>agentage</div>` +
|
|
38
|
-
`<div class="icon">${ICON[kind]}</div><h1>${title}</h1><p>${escapeHtml(detail)}</p
|
|
51
|
+
`<div class="icon">${ICON[kind]}</div><h1>${title}</h1><p>${escapeHtml(detail)}</p>${back.body}` +
|
|
39
52
|
`<p class="hint">${hint}</p></main></body></html>`);
|
|
40
53
|
};
|
|
@@ -3,4 +3,4 @@ export interface CallbackServer {
|
|
|
3
3
|
waitForCode: (timeoutMs?: number) => Promise<string>;
|
|
4
4
|
close: () => void;
|
|
5
5
|
}
|
|
6
|
-
export declare const startCallbackServer: (expectedState: string) => Promise<CallbackServer>;
|
|
6
|
+
export declare const startCallbackServer: (expectedState: string, returnLink?: string) => Promise<CallbackServer>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { createServer } from 'node:http';
|
|
2
2
|
import { callbackPage as page } from './callback-page.js';
|
|
3
|
-
|
|
3
|
+
const TERMINAL = 'You can return to the terminal.';
|
|
4
|
+
// returnLink: the fixed deep link of a sign-in the desktop started (return-link.ts), else none.
|
|
5
|
+
export const startCallbackServer = (expectedState, returnLink) => new Promise((resolveServer) => {
|
|
4
6
|
let settle = null;
|
|
5
7
|
let result = null;
|
|
6
8
|
const finish = (code, error) => {
|
|
@@ -33,7 +35,7 @@ export const startCallbackServer = (expectedState) => new Promise((resolveServer
|
|
|
33
35
|
}
|
|
34
36
|
res
|
|
35
37
|
.writeHead(200, { 'content-type': 'text/html' })
|
|
36
|
-
.end(page(true, 'You can return to the
|
|
38
|
+
.end(page(true, returnLink ? 'You can return to the agentage app.' : TERMINAL, returnLink));
|
|
37
39
|
finish(code);
|
|
38
40
|
});
|
|
39
41
|
// Bind loopback only so the one-shot sign-in callback is never LAN-reachable.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// The last hop of a sign-in the desktop started: a fixed allowlist, never a value from a request.
|
|
2
|
+
export const SIGN_IN_RETURN_ENV = 'AGENTAGE_SIGN_IN_RETURN';
|
|
3
|
+
const RETURNS = { desktop: 'agentage://signed-in' };
|
|
4
|
+
// Unset, empty or any other value (a prototype key too) is no link: the page keeps its text.
|
|
5
|
+
export const returnLinkOf = (env = process.env) => {
|
|
6
|
+
const raw = env[SIGN_IN_RETURN_ENV] ?? '';
|
|
7
|
+
return Object.hasOwn(RETURNS, raw) ? RETURNS[raw] : undefined;
|
|
8
|
+
};
|
package/dist/lib/auth/sign-in.js
CHANGED
|
@@ -8,6 +8,7 @@ import { startCallbackServer } from './callback-server.js';
|
|
|
8
8
|
import { credentialLinks, detectEnvMismatch } from './env-match.js';
|
|
9
9
|
import { introspectToken } from './introspect.js';
|
|
10
10
|
import { revokePlatformPats } from './platform-pat.js';
|
|
11
|
+
import { returnLinkOf } from './return-link.js';
|
|
11
12
|
import { buildAuthorizeUrl, exchangeCode, pkcePair, randomState, registerClient, revokeToken, tokensFrom, } from './oauth.js';
|
|
12
13
|
const defaultDeps = {
|
|
13
14
|
register: registerClient,
|
|
@@ -49,7 +50,7 @@ export const signIn = async (opts, deps = defaultDeps) => {
|
|
|
49
50
|
const authUrl = to.auth;
|
|
50
51
|
ensureConfigDir();
|
|
51
52
|
const state = randomState();
|
|
52
|
-
const server = await deps.startServer(state);
|
|
53
|
+
const server = await deps.startServer(state, returnLinkOf());
|
|
53
54
|
try {
|
|
54
55
|
const { clientId, code, verifier } = await authorize(server, state, opts, deps, authUrl);
|
|
55
56
|
const redirectUri = server.redirectUri;
|
|
@@ -4,6 +4,7 @@ export interface UpdateCache {
|
|
|
4
4
|
}
|
|
5
5
|
export declare const isUpdateCache: (value: unknown) => value is UpdateCache;
|
|
6
6
|
export declare const readUpdateCache: () => UpdateCache | null;
|
|
7
|
+
export declare const markUpdateReported: () => void;
|
|
7
8
|
export declare const updateHint: () => string | null;
|
|
8
9
|
export declare const fetchLatestVersion: (timeoutMs: number, url?: string) => Promise<string | null>;
|
|
9
10
|
export interface RefreshDeps {
|
|
@@ -17,9 +17,14 @@ const writeUpdateCache = (latest, now) => {
|
|
|
17
17
|
ensureConfigDir();
|
|
18
18
|
writeJsonAtomic(cachePath(), { checkedAt: now, latest });
|
|
19
19
|
};
|
|
20
|
+
// Set once a run printed the live update row (status, and setup through it): one line, one version.
|
|
21
|
+
let reported = false;
|
|
22
|
+
export const markUpdateReported = () => void (reported = true);
|
|
20
23
|
// The one dim hint line printed after a command, read purely from the cache (never the network),
|
|
21
24
|
// only when the cached latest is newer than us. null = print nothing.
|
|
22
25
|
export const updateHint = () => {
|
|
26
|
+
if (reported)
|
|
27
|
+
return null;
|
|
23
28
|
const c = readUpdateCache();
|
|
24
29
|
if (!c?.latest)
|
|
25
30
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentage/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.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.
|
|
57
|
+
"@agentage/extension": "0.18.8",
|
|
58
58
|
"@electric-sql/pglite": "^0.5.16",
|
|
59
59
|
"@tailwindcss/postcss": "^4.3.5",
|
|
60
60
|
"chalk": "^6.0.0",
|