@agentuity/vite 3.0.0-beta.8

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 ADDED
@@ -0,0 +1,39 @@
1
+ # @agentuity/vite
2
+
3
+ Vite plugin for the Agentuity public-URL devmode tunnel.
4
+
5
+ When `agentuity dev --public` is active, the CLI exports
6
+ `AGENTUITY_DEVMODE_HOSTNAME` so this plugin can configure Vite for the
7
+ gravity tunnel: it adds the public hostname to `server.allowedHosts`
8
+ and points `server.hmr` at `wss://<hostname>:443` so HMR works for
9
+ users browsing the public URL.
10
+
11
+ The plugin is a no-op when the env var isn't set, so it's safe to
12
+ keep in `vite.config.ts` permanently.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ bun add -d @agentuity/vite
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```ts
23
+ // vite.config.ts
24
+ import { defineConfig } from 'vite';
25
+ import agentuity from '@agentuity/vite';
26
+
27
+ export default defineConfig({
28
+ plugins: [agentuity()],
29
+ });
30
+ ```
31
+
32
+ For SvelteKit / Astro / similar — the plugin works in any Vite-based
33
+ config; just add it to the `plugins` array.
34
+
35
+ ## Options
36
+
37
+ | Option | Type | Default | Description |
38
+ |--------|------|---------|-------------|
39
+ | `hostname` | `string` | `process.env.AGENTUITY_DEVMODE_HOSTNAME` | Override the public hostname the plugin reacts to. Useful for testing. |
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Agentuity Vite plugin.
3
+ *
4
+ * Wires Vite's dev server up to a gravity public-URL tunnel that the
5
+ * Agentuity CLI may be running. When `agentuity dev --public` is
6
+ * active, the CLI exports `AGENTUITY_DEVMODE_HOSTNAME` (and
7
+ * `AGENTUITY_DEVMODE_URL`) into the user's framework process.
8
+ *
9
+ * This plugin reads that hostname and:
10
+ *
11
+ * 1. Adds it to `server.allowedHosts` so Vite stops rejecting
12
+ * requests with "Blocked request. This host is not allowed."
13
+ * 2. Configures `server.hmr` so the HMR WebSocket connects back
14
+ * through the tunnel using `wss://<hostname>:443`. Without this,
15
+ * the browser tries to dial Vite directly on the local port and
16
+ * HMR silently fails for users browsing the public URL.
17
+ *
18
+ * The plugin is a no-op when the env var is absent, so it's safe to
19
+ * always include in `vite.config.ts`.
20
+ */
21
+ import type { Plugin } from 'vite';
22
+ export interface AgentuityVitePluginOptions {
23
+ /**
24
+ * Override the hostname the plugin reacts to. When omitted, the
25
+ * plugin reads `process.env.AGENTUITY_DEVMODE_HOSTNAME`.
26
+ */
27
+ hostname?: string;
28
+ }
29
+ /**
30
+ * Vite plugin: enables Agentuity public-URL devmode (gravity tunnel).
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * // vite.config.ts
35
+ * import { defineConfig } from 'vite';
36
+ * import agentuity from '@agentuity/vite';
37
+ *
38
+ * export default defineConfig({
39
+ * plugins: [agentuity()],
40
+ * });
41
+ * ```
42
+ */
43
+ export default function agentuity(options?: AgentuityVitePluginOptions): Plugin;
44
+ export { agentuity };
45
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,MAAM,CAAC;AAI/C,MAAM,WAAW,0BAA0B;IAC1C;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,OAAO,GAAE,0BAA+B,GAAG,MAAM,CA2BlF;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Agentuity Vite plugin.
3
+ *
4
+ * Wires Vite's dev server up to a gravity public-URL tunnel that the
5
+ * Agentuity CLI may be running. When `agentuity dev --public` is
6
+ * active, the CLI exports `AGENTUITY_DEVMODE_HOSTNAME` (and
7
+ * `AGENTUITY_DEVMODE_URL`) into the user's framework process.
8
+ *
9
+ * This plugin reads that hostname and:
10
+ *
11
+ * 1. Adds it to `server.allowedHosts` so Vite stops rejecting
12
+ * requests with "Blocked request. This host is not allowed."
13
+ * 2. Configures `server.hmr` so the HMR WebSocket connects back
14
+ * through the tunnel using `wss://<hostname>:443`. Without this,
15
+ * the browser tries to dial Vite directly on the local port and
16
+ * HMR silently fails for users browsing the public URL.
17
+ *
18
+ * The plugin is a no-op when the env var is absent, so it's safe to
19
+ * always include in `vite.config.ts`.
20
+ */
21
+ const ENV_HOSTNAME = 'AGENTUITY_DEVMODE_HOSTNAME';
22
+ /**
23
+ * Vite plugin: enables Agentuity public-URL devmode (gravity tunnel).
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * // vite.config.ts
28
+ * import { defineConfig } from 'vite';
29
+ * import agentuity from '@agentuity/vite';
30
+ *
31
+ * export default defineConfig({
32
+ * plugins: [agentuity()],
33
+ * });
34
+ * ```
35
+ */
36
+ export default function agentuity(options = {}) {
37
+ return {
38
+ name: 'agentuity:devmode',
39
+ // Only apply during dev. Production builds don't need this.
40
+ apply: 'serve',
41
+ config() {
42
+ const hostname = options.hostname ?? process.env[ENV_HOSTNAME];
43
+ if (!hostname) {
44
+ return undefined;
45
+ }
46
+ return {
47
+ server: {
48
+ // Vite requires the hostname to be in this list — strings
49
+ // are matched exactly, regex entries can broaden matches.
50
+ allowedHosts: [hostname],
51
+ // HMR comes in over the gravity TLS tunnel on port 443.
52
+ // Without this Vite tells the browser to dial localhost
53
+ // directly, which fails for clients hitting the public URL.
54
+ hmr: {
55
+ host: hostname,
56
+ clientPort: 443,
57
+ protocol: 'wss',
58
+ },
59
+ },
60
+ };
61
+ },
62
+ };
63
+ }
64
+ export { agentuity };
65
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,MAAM,YAAY,GAAG,4BAA4B,CAAC;AAUlD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,UAAsC,EAAE;IACzE,OAAO;QACN,IAAI,EAAE,mBAAmB;QACzB,4DAA4D;QAC5D,KAAK,EAAE,OAAO;QACd,MAAM;YACL,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YAC/D,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACf,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,OAAO;gBACN,MAAM,EAAE;oBACP,0DAA0D;oBAC1D,0DAA0D;oBAC1D,YAAY,EAAE,CAAC,QAAQ,CAAC;oBACxB,wDAAwD;oBACxD,wDAAwD;oBACxD,4DAA4D;oBAC5D,GAAG,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,UAAU,EAAE,GAAG;wBACf,QAAQ,EAAE,KAAK;qBACf;iBACD;aACD,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC;AAED,OAAO,EAAE,SAAS,EAAE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@agentuity/vite",
3
+ "version": "3.0.0-beta.8",
4
+ "description": "Vite plugin for the Agentuity dev public-URL tunnel",
5
+ "license": "Apache-2.0",
6
+ "author": "Agentuity employees and contributors",
7
+ "type": "module",
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.js",
13
+ "types": "./dist/index.d.ts"
14
+ }
15
+ },
16
+ "files": [
17
+ "AGENTS.md",
18
+ "README.md",
19
+ "src",
20
+ "dist"
21
+ ],
22
+ "scripts": {
23
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
24
+ "build": "tsgo --build --force",
25
+ "typecheck": "tsgo --noEmit",
26
+ "prepublishOnly": "bun run clean && bun run build",
27
+ "test": "bun test"
28
+ },
29
+ "peerDependencies": {
30
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0"
31
+ },
32
+ "devDependencies": {
33
+ "@types/bun": "latest",
34
+ "@types/node": "^22.0.0",
35
+ "typescript": "^6.0.2",
36
+ "vite": "^7.0.0"
37
+ },
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "sideEffects": false,
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/agentuity/sdk.git",
45
+ "directory": "packages/vite"
46
+ }
47
+ }
package/src/index.ts ADDED
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Agentuity Vite plugin.
3
+ *
4
+ * Wires Vite's dev server up to a gravity public-URL tunnel that the
5
+ * Agentuity CLI may be running. When `agentuity dev --public` is
6
+ * active, the CLI exports `AGENTUITY_DEVMODE_HOSTNAME` (and
7
+ * `AGENTUITY_DEVMODE_URL`) into the user's framework process.
8
+ *
9
+ * This plugin reads that hostname and:
10
+ *
11
+ * 1. Adds it to `server.allowedHosts` so Vite stops rejecting
12
+ * requests with "Blocked request. This host is not allowed."
13
+ * 2. Configures `server.hmr` so the HMR WebSocket connects back
14
+ * through the tunnel using `wss://<hostname>:443`. Without this,
15
+ * the browser tries to dial Vite directly on the local port and
16
+ * HMR silently fails for users browsing the public URL.
17
+ *
18
+ * The plugin is a no-op when the env var is absent, so it's safe to
19
+ * always include in `vite.config.ts`.
20
+ */
21
+
22
+ import type { Plugin, UserConfig } from 'vite';
23
+
24
+ const ENV_HOSTNAME = 'AGENTUITY_DEVMODE_HOSTNAME';
25
+
26
+ export interface AgentuityVitePluginOptions {
27
+ /**
28
+ * Override the hostname the plugin reacts to. When omitted, the
29
+ * plugin reads `process.env.AGENTUITY_DEVMODE_HOSTNAME`.
30
+ */
31
+ hostname?: string;
32
+ }
33
+
34
+ /**
35
+ * Vite plugin: enables Agentuity public-URL devmode (gravity tunnel).
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * // vite.config.ts
40
+ * import { defineConfig } from 'vite';
41
+ * import agentuity from '@agentuity/vite';
42
+ *
43
+ * export default defineConfig({
44
+ * plugins: [agentuity()],
45
+ * });
46
+ * ```
47
+ */
48
+ export default function agentuity(options: AgentuityVitePluginOptions = {}): Plugin {
49
+ return {
50
+ name: 'agentuity:devmode',
51
+ // Only apply during dev. Production builds don't need this.
52
+ apply: 'serve',
53
+ config(): UserConfig | undefined {
54
+ const hostname = options.hostname ?? process.env[ENV_HOSTNAME];
55
+ if (!hostname) {
56
+ return undefined;
57
+ }
58
+ return {
59
+ server: {
60
+ // Vite requires the hostname to be in this list — strings
61
+ // are matched exactly, regex entries can broaden matches.
62
+ allowedHosts: [hostname],
63
+ // HMR comes in over the gravity TLS tunnel on port 443.
64
+ // Without this Vite tells the browser to dial localhost
65
+ // directly, which fails for clients hitting the public URL.
66
+ hmr: {
67
+ host: hostname,
68
+ clientPort: 443,
69
+ protocol: 'wss',
70
+ },
71
+ },
72
+ };
73
+ },
74
+ };
75
+ }
76
+
77
+ export { agentuity };