@agentage/extension 0.18.8 → 0.18.9

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.
@@ -12,12 +12,13 @@ export declare const readShell: (dir: string, version?: string) => Promise<Shell
12
12
  type User = {
13
13
  id: string;
14
14
  email?: string;
15
- name?: string;
16
15
  };
17
- export declare const sessionOf: ({ sub, text }: CliUser) => {
16
+ type Session = {
18
17
  user: User | null;
19
- host: "local";
18
+ host: 'local';
19
+ signIn?: string;
20
20
  };
21
+ export declare const sessionOf: ({ sub, text }: CliUser) => Session;
21
22
  export declare const shellRoutes: (app: Express, { shell, entries, events, user }: ShellDeps) => void;
22
23
  export interface ShellDeps {
23
24
  shell?: Shell;
@@ -8,6 +8,7 @@ import { hasApp } from './app-files.js';
8
8
  import {} from './cli-user-watch.js';
9
9
  import {} from './entries.js';
10
10
  import {} from './shell-events.js';
11
+ import { LOCAL_SIGN_IN, signInPage } from './sign-in-page.js';
11
12
  // The shell the kit carries (dist/shell, written by the kit build); none when run from src.
12
13
  export const kitShellDir = (base = import.meta.url) => {
13
14
  const dir = fileURLToPath(new URL('../../shell', base));
@@ -21,11 +22,11 @@ export const readShell = async (dir, version) => {
21
22
  return { dir, package: pkg.name, version: version ?? pkg.version };
22
23
  };
23
24
  const textOf = (value) => (typeof value === 'string' ? value : undefined);
24
- // K9: the user the children run as (issuer checked in cli-user.ts); email, name of its auth.json.
25
- // No `signIn` (S4 A4): on the daemon the shell keeps its `agentage setup` hint.
25
+ // K9: the user the children run as (issuer checked in cli-user.ts) and the email of its auth.json.
26
+ // The fields of a cloud app host's session (id, email; no name), so both frames show one label.
26
27
  export const sessionOf = ({ sub, text }) => {
27
28
  if (sub === undefined)
28
- return { user: null, host: 'local' };
29
+ return { user: null, host: 'local', signIn: LOCAL_SIGN_IN };
29
30
  let shown = {};
30
31
  try {
31
32
  shown = JSON.parse(text ?? '').user ?? {};
@@ -34,8 +35,7 @@ export const sessionOf = ({ sub, text }) => {
34
35
  // the sub alone
35
36
  }
36
37
  const email = textOf(shown['email']);
37
- const name = textOf(shown['name']);
38
- return { user: { id: sub, ...(email && { email }), ...(name && { name }) }, host: 'local' };
38
+ return { user: { id: sub, ...(email && { email }) }, host: 'local' };
39
39
  };
40
40
  // First path segments that are daemon routes: an unknown path under them stays a JSON 404.
41
41
  const OWN = new Set(['api', 'mcp', 'host', 'shell', 'app', 'health', '.well-known']);
@@ -52,11 +52,13 @@ const page = (shell, entries) => async (req, res, next) => {
52
52
  const notAFile = (req) => {
53
53
  throw fail('NOT_FOUND', `${req.originalUrl} is not a shell file`);
54
54
  };
55
- // S1.2.1: /, /{id}/* (the shell page, 404 for an id with no app), /shell/*, the session, the events.
55
+ // S1.2.1: /, /{id}/* (the shell page, 404 for an id with no app), /shell/*, the session, the events,
56
+ // and the page of the Sign in link.
56
57
  export const shellRoutes = (app, { shell, entries, events, user }) => {
57
58
  app.get('/shell/session', async (_req, res) => {
58
59
  res.set('Cache-Control', 'no-store').json(sessionOf(user));
59
60
  });
61
+ app.get(LOCAL_SIGN_IN, signInPage);
60
62
  app.get('/shell/events', events.stream);
61
63
  if (!shell)
62
64
  return;
@@ -0,0 +1,3 @@
1
+ import { type RequestHandler } from 'express';
2
+ export declare const LOCAL_SIGN_IN = "/shell/sign-in";
3
+ export declare const signInPage: RequestHandler;
@@ -0,0 +1,30 @@
1
+ import {} from 'express';
2
+ // The shell's Sign in link on the daemon: one fixed same-origin path, never a URL of another origin.
3
+ export const LOCAL_SIGN_IN = '/shell/sign-in';
4
+ const PAGE = `<!doctype html>
5
+ <html lang="en">
6
+ <meta charset="utf-8">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
+ <title>Sign in - agentage</title>
9
+ <style>
10
+ :root { color-scheme: light dark; }
11
+ body { font: 15px/1.5 system-ui, sans-serif; max-width: 32rem; margin: 15vh auto; padding: 0 16px; }
12
+ code { font-size: 14px; padding: 2px 6px; border-radius: 4px; background: rgba(127, 127, 127, 0.18); }
13
+ </style>
14
+ <h1>Sign in</h1>
15
+ <p>This dashboard runs on your machine. To sign in, run <code>agentage setup</code> in a terminal.</p>
16
+ <p>The dashboard shows your account a few seconds after the sign-in.</p>
17
+ <p><a href="/">Back to the dashboard</a></p>
18
+ </html>
19
+ `;
20
+ // A browser cannot start the cli: the page says how to sign in. The desktop catches the link first.
21
+ export const signInPage = (_req, res) => {
22
+ res
23
+ .status(200)
24
+ .set({
25
+ 'Content-Type': 'text/html; charset=utf-8',
26
+ 'Cache-Control': 'no-store',
27
+ 'Content-Security-Policy': "default-src 'none'; style-src 'unsafe-inline'",
28
+ })
29
+ .send(PAGE);
30
+ };
@@ -4,7 +4,7 @@
4
4
  <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'sha256-rPnVQ9IYe8CdsZZF35pNR4JDk/fH7Uqv6mzmCnCCky8=' 'sha256-lofENefBf5fETbin4TmrCuvlqGNlwIr9jsrkSYCOq+c=' 'sha256-ZowhplWzFwaUWeLf0FFjuCiJ6T38qHnoSSn0bfCSIG4='; style-src 'self'; img-src 'self' data:; font-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'" />
5
5
  <meta charset="utf-8" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <meta name="agentage-shell" content="0.18.8" />
7
+ <meta name="agentage-shell" content="0.18.9" />
8
8
  <title>agentage</title>
9
9
  <script>
10
10
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentage/extension",
3
- "version": "0.18.8",
3
+ "version": "0.18.9",
4
4
  "description": "The agentage extension kit: create(ctx) per part (pages, ui, api, mcp, worker, cli), the store, /health, discovery, the envelope, and the build tool with up and token",
5
5
  "type": "module",
6
6
  "license": "MIT",