@abstractframework/code 0.5.0 → 0.6.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
@@ -13,6 +13,15 @@ Run it without installing anything:
13
13
  npx @abstractframework/code # serves on http://127.0.0.1:3002
14
14
  ```
15
15
 
16
+ The server listens on `127.0.0.1` by default; pass `--host 0.0.0.0` to accept
17
+ other machines directly (it then prints a warning that it is exposed beyond
18
+ this machine). AbstractGateway (0.7.0 or later) can also start it
19
+ and serve it at `/apps/code/` on the gateway's own address, which is the one
20
+ address to expose or tunnel for a remote machine. Launch flags:
21
+ `--gateway-url <url>`, `--port <n>`, `--host <addr>`, `--help`; without
22
+ `--gateway-url` the server uses the gateway installed on this computer
23
+ (`~/.abstractframework/gateway.json`), else `http://127.0.0.1:8080`.
24
+
16
25
  The interface uses AbstractUIC themes, authentication, settings, and reusable
17
26
  workflow chat. It builds without a sibling checkout: the shared
18
27
  `@abstractframework/*` components install from npm like any other dependency,
@@ -32,7 +41,7 @@ npm run dev
32
41
 
33
42
  In the UI:
34
43
  - set `Gateway URL` (e.g. `http://127.0.0.1:8080`), or configure it on the
35
- server with `ABSTRACTCODE_GATEWAY_URL`
44
+ server with `--gateway-url` (the packaged server; `npm start -- --gateway-url …`)
36
45
  - set `Gateway user` and that user's `Gateway token`
37
46
 
38
47
  When a Gateway user is provided, the web server exchanges the token for a
@@ -51,10 +60,11 @@ gateway's versions. Agent tasks use the composer; structured workflows use
51
60
  event waits appear in the conversation. Runs and history remain on the gateway
52
61
  when you close the browser. Unsent drafts and queued turns do not survive reload.
53
62
 
54
- Whether a browser may change the Gateway URL is decided by the **connection
55
- peer**, not by any request header: only a request arriving from loopback may
56
- reconfigure it, and the server-configured Gateway URL is authoritative for
57
- everyone else. Set `ABSTRACTCODE_ALLOW_REMOTE_BROWSER_GATEWAY_CONFIG=1` to allow
63
+ Whether a browser may change the Gateway URL is decided by the browser's
64
+ address: only a browser on this machine may reconfigure it (forwarded headers
65
+ count only from a loopback peer such as the gateway's `/apps/code/` relay),
66
+ and a sign-in over a loopback connection must name a loopback host. The
67
+ server-configured Gateway URL is authoritative for everyone else. Set `ABSTRACTCODE_ALLOW_REMOTE_BROWSER_GATEWAY_CONFIG=1` to allow
58
68
  it from anywhere, behind your own access control. Behind a reverse proxy every
59
69
  peer is the proxy, so loopback carries no meaning there — set
60
70
  `ABSTRACTCODE_TRUST_PROXY_HEADERS=1` to refuse browser-supplied changes
package/bin/cli.js CHANGED
@@ -1,30 +1,35 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { createCodeServer } from "./server.js";
4
-
5
- const port = process.env.PORT || 3002;
6
- const host = process.env.HOST || "0.0.0.0";
7
- const server = createCodeServer();
8
-
9
- server.listen(port, host, () => {
10
- console.log(`
11
- ╔════════════════════════════════════════════════════╗
12
- ║ AbstractCode Web UI is running! ║
13
- ╚════════════════════════════════════════════════════╝
3
+ import { createGatewayUrlResolver, parseAppFlagsOrExit } from "@abstractframework/app-server";
4
+
5
+ import { bindExposureWarning, createCodeServer } from "./server.js";
6
+
7
+ // The shared launch flags: --gateway-url (aliases --gateway, --url), --port,
8
+ // --host (default 127.0.0.1: the gateway serves this app at /apps/code/),
9
+ // --help. Environment variables are legacy aliases only (PORT, HOST,
10
+ // ABSTRACTCODE_GATEWAY_URL, ABSTRACTGATEWAY_URL).
11
+ const flags = parseAppFlagsOrExit(process.argv.slice(2), {
12
+ appName: "AbstractCode Web",
13
+ command: "abstractcode-web",
14
+ envPrefix: "ABSTRACTCODE",
15
+ defaultPort: 3002,
16
+ });
14
17
 
15
- 🌐 Local: http://localhost:${port}
16
- 🌐 Network: http://${host}:${port}
18
+ // A flag or environment choice is fixed; otherwise the local gateway pointer
19
+ // is followed (re-read when the gateway refuses a connection, so a running
20
+ // app follows the gateway onto a new port).
21
+ const fixed = flags.gatewayUrlSource === "flag" || flags.gatewayUrlSource.startsWith("env:");
22
+ const server = createCodeServer({ defaultGatewayUrl: fixed ? flags.gatewayUrl : createGatewayUrlResolver() });
17
23
 
18
- 💻 Browser-based coding assistant
19
- 🔗 Connect to AbstractGateway in settings
20
- 🚀 Start coding with durable agent sessions
24
+ // Said before listening, so it shows even when the bind then fails.
25
+ const exposure = bindExposureWarning(flags.host, flags.port);
26
+ if (exposure) console.warn(exposure);
21
27
 
22
- Press Ctrl+C to stop
23
- `);
28
+ server.listen(flags.port, flags.host, () => {
29
+ console.log(`AbstractCode Web on http://${flags.host}:${flags.port}/ (gateway ${flags.gatewayUrl}, from ${flags.gatewayUrlSource})`);
24
30
  });
25
31
 
26
32
  function shutdown() {
27
- console.log("\n\n👋 Shutting down AbstractCode Web...\n");
28
33
  server.close(() => process.exit(0));
29
34
  }
30
35