@assistant-ui/next 0.0.2 → 0.0.3

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
@@ -33,7 +33,7 @@ by opting in with `"use client"`, so secrets can't leak by omission.
33
33
  ```tsx
34
34
  "use generative";
35
35
  import { z } from "zod";
36
- import { defineToolkit } from "@assistant-ui/next";
36
+ import { defineToolkit } from "@assistant-ui/react";
37
37
  import { db } from "@/db"; // server-only
38
38
  import { Chart } from "@/ui/chart"; // client-only
39
39
 
package/SPEC.md CHANGED
@@ -28,7 +28,7 @@ A module opts in with a leading directive and a single default export wrapped in
28
28
  ```tsx
29
29
  "use generative";
30
30
  import { z } from "zod";
31
- import { defineToolkit } from "@assistant-ui/next";
31
+ import { defineToolkit } from "@assistant-ui/react";
32
32
  import { db } from "@/db"; // server-only dependency
33
33
  import { Chart } from "@/ui/chart"; // client-only dependency
34
34
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- import { defineToolkit } from "./define-toolkit.js";
2
- import { hitl } from "./hitl.js";
3
1
  import { WithAuiOptions, withAui } from "./with-aui.js";
4
- export { type WithAuiOptions, defineToolkit, hitl, withAui };
2
+ export { type WithAuiOptions, withAui };
package/dist/index.js CHANGED
@@ -1,4 +1,2 @@
1
- import { defineToolkit } from "./define-toolkit.js";
2
- import { hitl } from "./hitl.js";
3
1
  import { withAui } from "./with-aui.js";
4
- export { defineToolkit, hitl, withAui };
2
+ export { withAui };
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","names":[],"sources":["../src/loader.ts"],"mappings":";;UAYU,uBAAA;EACR,YAAA;EACA,aAAA;EACA,SAAA;EACA,UAAA;IAAiB,IAAA;EAAA;EACjB,KAAA,KAAU,GAAA,WAAc,IAAA,WAAe,GAAA;AAAA;;iBAuDjB,gBAAA,CACtB,IAAA,EAAM,uBAAuB,EAC7B,MAAA"}
1
+ {"version":3,"file":"loader.d.ts","names":[],"sources":["../src/loader.ts"],"mappings":";;UAeU,uBAAA;EACR,YAAA;EACA,aAAA;EACA,SAAA;EACA,UAAA;IAAiB,IAAA;EAAA;EACjB,KAAA,KAAU,GAAA,WAAc,IAAA,WAAe,GAAA;AAAA;;iBAuDjB,gBAAA,CACtB,IAAA,EAAM,uBAAuB,EAC7B,MAAA"}
package/dist/loader.js CHANGED
@@ -1,5 +1,5 @@
1
- import { compileGenerative, isGenerativeModule } from "./compile.js";
2
1
  import * as nodePath from "node:path";
2
+ import { compileGenerative, isGenerativeModule } from "@assistant-ui/x-generative-compiler";
3
3
  //#region src/loader.ts
4
4
  /** This package's name, used in the facade's re-export specifier. */
5
5
  const PKG = "@assistant-ui/next";
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","names":[],"sources":["../src/loader.ts"],"sourcesContent":["import * as nodePath from \"node:path\";\nimport { compileGenerative, isGenerativeModule } from \"./compile\";\nimport type { Target } from \"./constants\";\n\n/** This package's name, used in the facade's re-export specifier. */\nconst PKG = \"@assistant-ui/next\";\n\n/** Basenames of the react-server-conditioned indirection modules (see with-aui.ts). */\nconst SERVER_INDIRECTION = \"bundler-redirect.server\";\nconst CLIENT_INDIRECTION = \"bundler-redirect.client\";\n\n/** The subset of the webpack/Turbopack loader context this loader reads. */\ninterface GenerativeLoaderContext {\n resourcePath?: string;\n resourceQuery?: string;\n sourceMap?: boolean;\n getOptions?(): { path?: string } | undefined;\n async(): (err: unknown, code?: string, map?: object | null) => void;\n}\n\n/** Whether this resolution is one of the package's indirection modules. */\nfunction indirectionVariant(resourcePath: string): Target | null {\n const base = nodePath.basename(resourcePath);\n if (base.startsWith(SERVER_INDIRECTION)) return \"server\";\n if (base.startsWith(CLIENT_INDIRECTION)) return \"client\";\n return null;\n}\n\n/** The concrete build forced by a `?generative-env=client|server` resource query. */\nfunction queryTarget(resourceQuery: string | undefined): Target | null {\n if (!resourceQuery) return null;\n // URLSearchParams strips a leading \"?\" per spec.\n const g = new URLSearchParams(resourceQuery).get(\"generative-env\");\n return g === \"server\" || g === \"client\" ? g : null;\n}\n\n/**\n * Facade for a bare generative import: delegates build selection to the\n * `react-server`-conditioned `/bundler-redirect` subpath, passing the module's\n * path via a Turbopack import attribute. See DESIGN.md.\n */\nfunction buildFacade(resourcePath: string): string {\n const options = JSON.stringify(JSON.stringify({ path: resourcePath }));\n const attr =\n `with { turbopackLoader: \"${PKG}/loader\", ` +\n `turbopackLoaderOptions: ${options} }`;\n return [\n `import toolkit from \"${PKG}/bundler-redirect\" ${attr};`,\n `export default toolkit;`,\n ``,\n ].join(\"\\n\");\n}\n\n/**\n * Replaces an indirection module with a re-export of the chosen concrete build,\n * via a relative specifier (Turbopack won't resolve an absolute one). See\n * DESIGN.md.\n */\nfunction buildIndirection(\n variant: Target,\n fromPath: string,\n toPath: string,\n): string {\n let rel = nodePath\n .relative(nodePath.dirname(fromPath), toPath)\n .replace(/\\\\/g, \"/\");\n if (!rel.startsWith(\".\")) rel = `./${rel}`;\n const spec = JSON.stringify(`${rel}?generative-env=${variant}`);\n return `export { default } from ${spec};\\n`;\n}\n\n/** Webpack/Turbopack loader for `\"use generative\"` modules. See DESIGN.md. */\nexport default function generativeLoader(\n this: GenerativeLoaderContext,\n source: string,\n): void {\n const callback = this.async();\n const resourcePath = this.resourcePath ?? \"\";\n\n // 1) Package indirection (resolved via the `react-server` condition).\n const variant = indirectionVariant(resourcePath);\n if (variant) {\n const path = this.getOptions?.()?.path;\n if (!path) {\n callback(\n new Error(\n \"[assistant-ui/next] indirection module loaded without a `path` \" +\n \"option; it must be imported via the generated facade.\",\n ),\n );\n return;\n }\n callback(null, buildIndirection(variant, resourcePath, path));\n return;\n }\n\n // 2) Explicit concrete-build query (used by the indirection).\n const target = queryTarget(this.resourceQuery);\n if (target) {\n if (!isGenerativeModule(source)) {\n callback(null, source);\n return;\n }\n try {\n const { code, map } = compileGenerative(source, {\n target,\n filename: resourcePath,\n sourceMaps: this.sourceMap ?? false,\n });\n callback(null, code, map);\n } catch (error) {\n callback(error);\n }\n return;\n }\n\n // 3) Bare import of a generative module → facade.\n if (isGenerativeModule(source)) {\n callback(null, buildFacade(resourcePath));\n return;\n }\n\n // 4) Not a generative module.\n callback(null, source);\n}\n"],"mappings":";;;;AAKA,MAAM,MAAM;;AAGZ,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;;AAY3B,SAAS,mBAAmB,cAAqC;CAC/D,MAAM,OAAO,SAAS,SAAS,YAAY;CAC3C,IAAI,KAAK,WAAW,kBAAkB,GAAG,OAAO;CAChD,IAAI,KAAK,WAAW,kBAAkB,GAAG,OAAO;CAChD,OAAO;AACT;;AAGA,SAAS,YAAY,eAAkD;CACrE,IAAI,CAAC,eAAe,OAAO;CAE3B,MAAM,IAAI,IAAI,gBAAgB,aAAa,EAAE,IAAI,gBAAgB;CACjE,OAAO,MAAM,YAAY,MAAM,WAAW,IAAI;AAChD;;;;;;AAOA,SAAS,YAAY,cAA8B;CAKjD,OAAO;EACL,wBAAwB,IAAI,qBAAqB,4BAHrB,IAAI,oCAFlB,KAAK,UAAU,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC,CAGjC,EAAE,IAEmB;EACtD;EACA;CACF,EAAE,KAAK,IAAI;AACb;;;;;;AAOA,SAAS,iBACP,SACA,UACA,QACQ;CACR,IAAI,MAAM,SACP,SAAS,SAAS,QAAQ,QAAQ,GAAG,MAAM,EAC3C,QAAQ,OAAO,GAAG;CACrB,IAAI,CAAC,IAAI,WAAW,GAAG,GAAG,MAAM,KAAK;CAErC,OAAO,2BADM,KAAK,UAAU,GAAG,IAAI,kBAAkB,SAChB,EAAE;AACzC;;AAGA,SAAwB,iBAEtB,QACM;CACN,MAAM,WAAW,KAAK,MAAM;CAC5B,MAAM,eAAe,KAAK,gBAAgB;CAG1C,MAAM,UAAU,mBAAmB,YAAY;CAC/C,IAAI,SAAS;EACX,MAAM,OAAO,KAAK,aAAa,GAAG;EAClC,IAAI,CAAC,MAAM;GACT,yBACE,IAAI,MACF,sHAEF,CACF;GACA;EACF;EACA,SAAS,MAAM,iBAAiB,SAAS,cAAc,IAAI,CAAC;EAC5D;CACF;CAGA,MAAM,SAAS,YAAY,KAAK,aAAa;CAC7C,IAAI,QAAQ;EACV,IAAI,CAAC,mBAAmB,MAAM,GAAG;GAC/B,SAAS,MAAM,MAAM;GACrB;EACF;EACA,IAAI;GACF,MAAM,EAAE,MAAM,QAAQ,kBAAkB,QAAQ;IAC9C;IACA,UAAU;IACV,YAAY,KAAK,aAAa;GAChC,CAAC;GACD,SAAS,MAAM,MAAM,GAAG;EAC1B,SAAS,OAAO;GACd,SAAS,KAAK;EAChB;EACA;CACF;CAGA,IAAI,mBAAmB,MAAM,GAAG;EAC9B,SAAS,MAAM,YAAY,YAAY,CAAC;EACxC;CACF;CAGA,SAAS,MAAM,MAAM;AACvB"}
1
+ {"version":3,"file":"loader.js","names":[],"sources":["../src/loader.ts"],"sourcesContent":["import * as nodePath from \"node:path\";\nimport {\n compileGenerative,\n isGenerativeModule,\n type Target,\n} from \"@assistant-ui/x-generative-compiler\";\n\n/** This package's name, used in the facade's re-export specifier. */\nconst PKG = \"@assistant-ui/next\";\n\n/** Basenames of the react-server-conditioned indirection modules (see with-aui.ts). */\nconst SERVER_INDIRECTION = \"bundler-redirect.server\";\nconst CLIENT_INDIRECTION = \"bundler-redirect.client\";\n\n/** The subset of the webpack/Turbopack loader context this loader reads. */\ninterface GenerativeLoaderContext {\n resourcePath?: string;\n resourceQuery?: string;\n sourceMap?: boolean;\n getOptions?(): { path?: string } | undefined;\n async(): (err: unknown, code?: string, map?: object | null) => void;\n}\n\n/** Whether this resolution is one of the package's indirection modules. */\nfunction indirectionVariant(resourcePath: string): Target | null {\n const base = nodePath.basename(resourcePath);\n if (base.startsWith(SERVER_INDIRECTION)) return \"server\";\n if (base.startsWith(CLIENT_INDIRECTION)) return \"client\";\n return null;\n}\n\n/** The concrete build forced by a `?generative-env=client|server` resource query. */\nfunction queryTarget(resourceQuery: string | undefined): Target | null {\n if (!resourceQuery) return null;\n // URLSearchParams strips a leading \"?\" per spec.\n const g = new URLSearchParams(resourceQuery).get(\"generative-env\");\n return g === \"server\" || g === \"client\" ? g : null;\n}\n\n/**\n * Facade for a bare generative import: delegates build selection to the\n * `react-server`-conditioned `/bundler-redirect` subpath, passing the module's\n * path via a Turbopack import attribute. See DESIGN.md.\n */\nfunction buildFacade(resourcePath: string): string {\n const options = JSON.stringify(JSON.stringify({ path: resourcePath }));\n const attr =\n `with { turbopackLoader: \"${PKG}/loader\", ` +\n `turbopackLoaderOptions: ${options} }`;\n return [\n `import toolkit from \"${PKG}/bundler-redirect\" ${attr};`,\n `export default toolkit;`,\n ``,\n ].join(\"\\n\");\n}\n\n/**\n * Replaces an indirection module with a re-export of the chosen concrete build,\n * via a relative specifier (Turbopack won't resolve an absolute one). See\n * DESIGN.md.\n */\nfunction buildIndirection(\n variant: Target,\n fromPath: string,\n toPath: string,\n): string {\n let rel = nodePath\n .relative(nodePath.dirname(fromPath), toPath)\n .replace(/\\\\/g, \"/\");\n if (!rel.startsWith(\".\")) rel = `./${rel}`;\n const spec = JSON.stringify(`${rel}?generative-env=${variant}`);\n return `export { default } from ${spec};\\n`;\n}\n\n/** Webpack/Turbopack loader for `\"use generative\"` modules. See DESIGN.md. */\nexport default function generativeLoader(\n this: GenerativeLoaderContext,\n source: string,\n): void {\n const callback = this.async();\n const resourcePath = this.resourcePath ?? \"\";\n\n // 1) Package indirection (resolved via the `react-server` condition).\n const variant = indirectionVariant(resourcePath);\n if (variant) {\n const path = this.getOptions?.()?.path;\n if (!path) {\n callback(\n new Error(\n \"[assistant-ui/next] indirection module loaded without a `path` \" +\n \"option; it must be imported via the generated facade.\",\n ),\n );\n return;\n }\n callback(null, buildIndirection(variant, resourcePath, path));\n return;\n }\n\n // 2) Explicit concrete-build query (used by the indirection).\n const target = queryTarget(this.resourceQuery);\n if (target) {\n if (!isGenerativeModule(source)) {\n callback(null, source);\n return;\n }\n try {\n const { code, map } = compileGenerative(source, {\n target,\n filename: resourcePath,\n sourceMaps: this.sourceMap ?? false,\n });\n callback(null, code, map);\n } catch (error) {\n callback(error);\n }\n return;\n }\n\n // 3) Bare import of a generative module → facade.\n if (isGenerativeModule(source)) {\n callback(null, buildFacade(resourcePath));\n return;\n }\n\n // 4) Not a generative module.\n callback(null, source);\n}\n"],"mappings":";;;;AAQA,MAAM,MAAM;;AAGZ,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;;AAY3B,SAAS,mBAAmB,cAAqC;CAC/D,MAAM,OAAO,SAAS,SAAS,YAAY;CAC3C,IAAI,KAAK,WAAW,kBAAkB,GAAG,OAAO;CAChD,IAAI,KAAK,WAAW,kBAAkB,GAAG,OAAO;CAChD,OAAO;AACT;;AAGA,SAAS,YAAY,eAAkD;CACrE,IAAI,CAAC,eAAe,OAAO;CAE3B,MAAM,IAAI,IAAI,gBAAgB,aAAa,EAAE,IAAI,gBAAgB;CACjE,OAAO,MAAM,YAAY,MAAM,WAAW,IAAI;AAChD;;;;;;AAOA,SAAS,YAAY,cAA8B;CAKjD,OAAO;EACL,wBAAwB,IAAI,qBAAqB,4BAHrB,IAAI,oCAFlB,KAAK,UAAU,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC,CAGjC,EAAE,IAEmB;EACtD;EACA;CACF,EAAE,KAAK,IAAI;AACb;;;;;;AAOA,SAAS,iBACP,SACA,UACA,QACQ;CACR,IAAI,MAAM,SACP,SAAS,SAAS,QAAQ,QAAQ,GAAG,MAAM,EAC3C,QAAQ,OAAO,GAAG;CACrB,IAAI,CAAC,IAAI,WAAW,GAAG,GAAG,MAAM,KAAK;CAErC,OAAO,2BADM,KAAK,UAAU,GAAG,IAAI,kBAAkB,SAChB,EAAE;AACzC;;AAGA,SAAwB,iBAEtB,QACM;CACN,MAAM,WAAW,KAAK,MAAM;CAC5B,MAAM,eAAe,KAAK,gBAAgB;CAG1C,MAAM,UAAU,mBAAmB,YAAY;CAC/C,IAAI,SAAS;EACX,MAAM,OAAO,KAAK,aAAa,GAAG;EAClC,IAAI,CAAC,MAAM;GACT,yBACE,IAAI,MACF,sHAEF,CACF;GACA;EACF;EACA,SAAS,MAAM,iBAAiB,SAAS,cAAc,IAAI,CAAC;EAC5D;CACF;CAGA,MAAM,SAAS,YAAY,KAAK,aAAa;CAC7C,IAAI,QAAQ;EACV,IAAI,CAAC,mBAAmB,MAAM,GAAG;GAC/B,SAAS,MAAM,MAAM;GACrB;EACF;EACA,IAAI;GACF,MAAM,EAAE,MAAM,QAAQ,kBAAkB,QAAQ;IAC9C;IACA,UAAU;IACV,YAAY,KAAK,aAAa;GAChC,CAAC;GACD,SAAS,MAAM,MAAM,GAAG;EAC1B,SAAS,OAAO;GACd,SAAS,KAAK;EAChB;EACA;CACF;CAGA,IAAI,mBAAmB,MAAM,GAAG;EAC9B,SAAS,MAAM,YAAY,YAAY,CAAC;EACxC;CACF;CAGA,SAAS,MAAM,MAAM;AACvB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assistant-ui/next",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Next.js integration for assistant-ui: the withAui() config wrapper and the \"use generative\" directive compiler that colocates a tool's schema, server-only execute, and client-only render in one file.",
5
5
  "keywords": [
6
6
  "assistant-ui",
@@ -40,20 +40,11 @@
40
40
  ],
41
41
  "sideEffects": false,
42
42
  "dependencies": {
43
- "@babel/generator": "^7.29.7",
44
- "@babel/parser": "^7.29.7",
45
- "@babel/traverse": "^7.29.7",
46
- "@babel/types": "^7.29.7"
47
- },
48
- "peerDependencies": {
49
- "@assistant-ui/core": "^0.2.8"
43
+ "@assistant-ui/x-generative-compiler": "^0.0.2"
50
44
  },
51
45
  "devDependencies": {
52
- "@types/babel__generator": "^7.27.0",
53
- "@types/babel__traverse": "^7.28.0",
54
46
  "@types/node": "^25.9.1",
55
47
  "vitest": "^4.1.7",
56
- "@assistant-ui/core": "0.2.8",
57
48
  "@assistant-ui/x-buildutils": "0.0.10"
58
49
  },
59
50
  "publishConfig": {
@@ -71,7 +62,7 @@
71
62
  },
72
63
  "scripts": {
73
64
  "build": "aui-build",
74
- "test": "vitest run",
65
+ "test": "vitest run --passWithNoTests",
75
66
  "test:watch": "vitest"
76
67
  }
77
68
  }
package/src/index.ts CHANGED
@@ -1,3 +1 @@
1
1
  export { withAui, type WithAuiOptions } from "./with-aui";
2
- export { defineToolkit } from "./define-toolkit";
3
- export { hitl } from "./hitl";
package/src/loader.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import * as nodePath from "node:path";
2
- import { compileGenerative, isGenerativeModule } from "./compile";
3
- import type { Target } from "./constants";
2
+ import {
3
+ compileGenerative,
4
+ isGenerativeModule,
5
+ type Target,
6
+ } from "@assistant-ui/x-generative-compiler";
4
7
 
5
8
  /** This package's name, used in the facade's re-export specifier. */
6
9
  const PKG = "@assistant-ui/next";
package/dist/compile.d.ts DELETED
@@ -1,30 +0,0 @@
1
- import { Target } from "./constants.js";
2
-
3
- //#region src/compile.d.ts
4
- type ToolType = "frontend" | "backend" | "human";
5
- interface CompileOptions {
6
- /** Which build target to emit. */
7
- target: Target;
8
- /** Source filename, used for error messages and source maps. */
9
- filename?: string;
10
- /** Emit a source map alongside the code. */
11
- sourceMaps?: boolean;
12
- }
13
- interface CompileResult {
14
- code: string;
15
- map?: object | null;
16
- }
17
- /** Thrown when a `"use generative"` file violates an authoring constraint. */
18
- declare class GenerativeCompileError extends Error {
19
- constructor(message: string, filename?: string);
20
- }
21
- /** Whether a source string opts into generative compilation via the directive. */
22
- declare function isGenerativeModule(code: string): boolean;
23
- /**
24
- * Rewrites a `"use generative"` module for a single build target, keeping only the
25
- * regions that target needs and pruning the imports the dropped regions used.
26
- */
27
- declare function compileGenerative(code: string, options: CompileOptions): CompileResult;
28
- //#endregion
29
- export { CompileOptions, CompileResult, GenerativeCompileError, ToolType, compileGenerative, isGenerativeModule };
30
- //# sourceMappingURL=compile.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compile.d.ts","names":[],"sources":["../src/compile.ts"],"mappings":";;;KAeY,QAAA;AAAA,UAEK,cAAA;EAFL;EAIV,MAAA,EAAQ,MAAM;;EAEd,QAAA;EANkB;EAQlB,UAAA;AAAA;AAAA,UAGe,aAAA;EACf,IAAA;EACA,GAAG;AAAA;;cAIQ,sBAAA,SAA+B,KAAK;cACnC,OAAA,UAAiB,QAAA;AAAA;AAP/B;AAAA,iBAcgB,kBAAA,CAAmB,IAAY;;;AAZ1C;AAIL;iBAoCgB,iBAAA,CACd,IAAA,UACA,OAAA,EAAS,cAAA,GACR,aAAa"}
package/dist/compile.js DELETED
@@ -1,235 +0,0 @@
1
- import { DIRECTIVE } from "./constants.js";
2
- import { parse } from "@babel/parser";
3
- import _traverse from "@babel/traverse";
4
- import _generate from "@babel/generator";
5
- import * as t from "@babel/types";
6
- //#region src/compile.ts
7
- const traverse = typeof _traverse === "function" ? _traverse : _traverse.default;
8
- const generate = typeof _generate === "function" ? _generate : _generate.default;
9
- /** Thrown when a `"use generative"` file violates an authoring constraint. */
10
- var GenerativeCompileError = class extends Error {
11
- constructor(message, filename) {
12
- super(`[assistant-ui/next]${filename ? ` ${filename}:` : ""} ${message}`);
13
- this.name = "GenerativeCompileError";
14
- }
15
- };
16
- /** Whether a source string opts into generative compilation via the directive. */
17
- function isGenerativeModule(code) {
18
- let i = code.charCodeAt(0) === 65279 ? 1 : 0;
19
- for (;;) {
20
- while (i < code.length && /\s/.test(code[i])) i++;
21
- if (code.startsWith("//", i)) {
22
- const nl = code.indexOf("\n", i);
23
- if (nl === -1) return false;
24
- i = nl + 1;
25
- } else if (code.startsWith("/*", i)) {
26
- const end = code.indexOf("*/", i + 2);
27
- if (end === -1) return false;
28
- i = end + 2;
29
- } else break;
30
- }
31
- return code.startsWith(`"use generative"`, i) || code.startsWith(`'use generative'`, i);
32
- }
33
- /**
34
- * Rewrites a `"use generative"` module for a single build target, keeping only the
35
- * regions that target needs and pruning the imports the dropped regions used.
36
- */
37
- function compileGenerative(code, options) {
38
- const { target, filename } = options;
39
- const ast = parse(code, {
40
- sourceType: "module",
41
- plugins: [
42
- "typescript",
43
- "jsx",
44
- "explicitResourceManagement"
45
- ]
46
- });
47
- if (!ast.program.directives.some((d) => d.value.value === "use generative")) throw new GenerativeCompileError(`missing "${DIRECTIVE}" directive`, filename);
48
- const object = findDefaultExportObject(ast, filename);
49
- let keptRender = false;
50
- let keptBackendExecute = false;
51
- for (const entry of object.properties) {
52
- const value = entryValue(entry);
53
- if (!value) throw new GenerativeCompileError("each tool must be an inline object literal (`name: { ... }`) so its `execute` can be routed", filename);
54
- const type = inferToolType(value, filename);
55
- const hasRender = !!findMember(value, "render");
56
- const execute = findMember(value, "execute");
57
- if ((type === "frontend" || type === "human") && !hasRender) throw new GenerativeCompileError(`a ${type} tool must declare a \`render\` (it has no server execute to show otherwise)`, filename);
58
- if (target === "client") {
59
- if (execute && type === "frontend") stripUseClient(execute);
60
- else if (execute) removeMember(value, "execute");
61
- if (hasRender) keptRender = true;
62
- } else {
63
- if (hasRender) removeMember(value, "render");
64
- if (execute && type !== "backend") removeMember(value, "execute");
65
- if (execute && type === "backend") keptBackendExecute = true;
66
- }
67
- setToolType(value, type);
68
- }
69
- pruneUnused(ast);
70
- ast.program.directives = ast.program.directives.filter((d) => d.value.value !== "use generative" && d.value.value !== "use client");
71
- if (target === "client" && keptRender) ast.program.directives.unshift(t.directive(t.directiveLiteral("use client")));
72
- if (target === "server" && keptBackendExecute) ast.program.body.unshift(t.importDeclaration([], t.stringLiteral("server-only")));
73
- const result = generate(ast, {
74
- sourceMaps: options.sourceMaps ?? false,
75
- filename,
76
- jsescOption: { minimal: true }
77
- }, code);
78
- return {
79
- code: result.code,
80
- map: result.map
81
- };
82
- }
83
- function findDefaultExportObject(ast, filename) {
84
- let object = null;
85
- let sawDefault = false;
86
- for (const stmt of ast.program.body) {
87
- if (!t.isExportDefaultDeclaration(stmt)) continue;
88
- sawDefault = true;
89
- object = unwrapDefineToolkit(stmt.declaration);
90
- if (object) stmt.declaration = object;
91
- }
92
- if (!sawDefault) throw new GenerativeCompileError("missing a default export", filename);
93
- if (!object) throw new GenerativeCompileError("the default export must be `defineToolkit({ ... })` (imported from \"@assistant-ui/next\"); wrapping is required so a backend `execute` can't be authored in a way that reaches the client", filename);
94
- return object;
95
- }
96
- /**
97
- * Unwraps the required `defineToolkit({ ... })` wrapper (through `satisfies`/`as`
98
- * and parens) to the underlying object literal. Anything else — a bare object, a
99
- * `satisfies Toolkit` without the wrapper, some other call — yields `null` so the
100
- * caller errors.
101
- */
102
- function unwrapDefineToolkit(node) {
103
- if (t.isTSSatisfiesExpression(node) || t.isTSAsExpression(node)) return unwrapDefineToolkit(node.expression);
104
- if (t.isParenthesizedExpression(node)) return unwrapDefineToolkit(node.expression);
105
- if (t.isCallExpression(node) && t.isIdentifier(node.callee, { name: "defineToolkit" }) && t.isObjectExpression(node.arguments[0])) return node.arguments[0];
106
- return null;
107
- }
108
- function entryValue(entry) {
109
- if (t.isObjectProperty(entry) && t.isObjectExpression(entry.value)) return entry.value;
110
- return null;
111
- }
112
- /** A member of an entry object: `render`/`execute`/`type`, as property or method. */
113
- function findMember(object, name) {
114
- return object.properties.find((p) => (t.isObjectProperty(p) || t.isObjectMethod(p)) && memberName(p.key, p.computed) === name);
115
- }
116
- function removeMember(object, name) {
117
- object.properties = object.properties.filter((p) => !((t.isObjectProperty(p) || t.isObjectMethod(p)) && memberName(p.key, p.computed) === name));
118
- }
119
- /** The `BlockStatement` body of an `execute` member, if it has one. */
120
- function executeBody(member) {
121
- if (t.isObjectMethod(member)) return member.body;
122
- const value = member.value;
123
- if ((t.isArrowFunctionExpression(value) || t.isFunctionExpression(value)) && t.isBlockStatement(value.body)) return value.body;
124
- }
125
- /** Whether an `execute` opts into the client via a leading `"use client"`. */
126
- function executeIsClient(member) {
127
- return !!executeBody(member)?.directives.some((d) => d.value.value === "use client");
128
- }
129
- /** Whether an `execute` is the `hitl()` human-in-the-loop sentinel. */
130
- function executeIsHitl(member) {
131
- return t.isObjectProperty(member) && t.isCallExpression(member.value) && t.isIdentifier(member.value.callee, { name: "hitl" });
132
- }
133
- /** Drops the `"use client"` directive from an `execute` body (kept frontend). */
134
- function stripUseClient(member) {
135
- const body = executeBody(member);
136
- if (body) body.directives = body.directives.filter((d) => d.value.value !== "use client");
137
- }
138
- /**
139
- * The tool's nature, inferred from its (mandatory) `execute` rather than an
140
- * authored `type`: `hitl()` → `human`; `"use client"` → `frontend`; otherwise
141
- * `backend`. The loader writes the result back as a `type` field (see
142
- * {@link setToolType}) so the runtime keeps it.
143
- */
144
- function inferToolType(object, filename) {
145
- const execute = findMember(object, "execute");
146
- if (!execute) throw new GenerativeCompileError("every tool must declare an `execute`; use `hitl()` for a human-in-the-loop tool", filename);
147
- if (executeIsHitl(execute)) return "human";
148
- return executeIsClient(execute) ? "frontend" : "backend";
149
- }
150
- /** Writes the resolved `type` back onto the tool object (replacing any author's). */
151
- function setToolType(object, type) {
152
- removeMember(object, "type");
153
- object.properties.push(t.objectProperty(t.identifier("type"), t.stringLiteral(type)));
154
- }
155
- function memberName(key, computed) {
156
- if (computed) return void 0;
157
- if (t.isIdentifier(key)) return key.name;
158
- if (t.isStringLiteral(key)) return key.value;
159
- }
160
- /**
161
- * Removes declarations and import specifiers left unreferenced after region
162
- * removal, to a fixpoint (a dropped helper frees what it used). Keeps exports,
163
- * side-effect imports, and possibly-side-effectful initializers.
164
- */
165
- function pruneUnused(ast) {
166
- const hadSpecifiers = /* @__PURE__ */ new WeakSet();
167
- for (const stmt of ast.program.body) if (t.isImportDeclaration(stmt) && stmt.specifiers.length > 0) hadSpecifiers.add(stmt);
168
- let removedSomething = true;
169
- while (removedSomething) {
170
- removedSomething = false;
171
- traverse(ast, { Program(path) {
172
- path.scope.crawl();
173
- const isUnused = (name) => {
174
- const binding = path.scope.getBinding(name);
175
- return !!binding && !binding.referenced;
176
- };
177
- path.node.body = path.node.body.filter((stmt) => {
178
- if ((t.isFunctionDeclaration(stmt) || t.isClassDeclaration(stmt)) && stmt.id && isUnused(stmt.id.name)) {
179
- removedSomething = true;
180
- return false;
181
- }
182
- if (t.isVariableDeclaration(stmt)) {
183
- stmt.declarations = stmt.declarations.filter((decl) => {
184
- const names = Object.keys(t.getBindingIdentifiers(decl.id));
185
- if (names.length > 0 && isPlainPattern(decl.id) && isRemovableInit(decl.init) && names.every(isUnused)) {
186
- removedSomething = true;
187
- return false;
188
- }
189
- return true;
190
- });
191
- if (stmt.declarations.length === 0) return false;
192
- }
193
- return true;
194
- });
195
- path.stop();
196
- } });
197
- }
198
- traverse(ast, { Program(path) {
199
- path.scope.crawl();
200
- for (const stmt of path.node.body) {
201
- if (!t.isImportDeclaration(stmt)) continue;
202
- stmt.specifiers = stmt.specifiers.filter((spec) => {
203
- const binding = path.scope.getBinding(spec.local.name);
204
- return binding ? binding.referenced : true;
205
- });
206
- }
207
- path.node.body = path.node.body.filter((stmt) => !(t.isImportDeclaration(stmt) && stmt.specifiers.length === 0 && hadSpecifiers.has(stmt)));
208
- path.stop();
209
- } });
210
- }
211
- /**
212
- * Whether a binding pattern is side-effect-free to drop: a plain identifier, or
213
- * an object/array pattern of plain bindings — no default values
214
- * (`{ a = expr }`) or computed keys (`{ [expr]: a }`), which would evaluate (and
215
- * thus could have side effects) at destructuring time.
216
- */
217
- function isPlainPattern(node) {
218
- if (t.isIdentifier(node)) return true;
219
- if (t.isObjectPattern(node)) return node.properties.every((p) => t.isRestElement(p) ? isPlainPattern(p.argument) : !p.computed && isPlainPattern(p.value));
220
- if (t.isArrayPattern(node)) return node.elements.every((el) => el == null || isPlainPattern(el));
221
- return false;
222
- }
223
- /** Whether a variable initializer is safe to drop (no observable side effects). */
224
- function isRemovableInit(node) {
225
- if (node == null) return true;
226
- if (t.isTSAsExpression(node) || t.isTSSatisfiesExpression(node)) return isRemovableInit(node.expression);
227
- if (t.isArrayExpression(node)) return node.elements.every((el) => el == null || t.isExpression(el) && isRemovableInit(el));
228
- if (t.isObjectExpression(node)) return node.properties.every((p) => t.isObjectProperty(p) && !p.computed && t.isExpression(p.value) && isRemovableInit(p.value));
229
- if (t.isTemplateLiteral(node)) return node.expressions.every((e) => t.isExpression(e) && isRemovableInit(e));
230
- return t.isArrowFunctionExpression(node) || t.isFunctionExpression(node) || t.isClassExpression(node) || t.isIdentifier(node) || t.isMemberExpression(node) && !node.computed || t.isJSXElement(node) || t.isJSXFragment(node) || t.isLiteral(node);
231
- }
232
- //#endregion
233
- export { GenerativeCompileError, compileGenerative, isGenerativeModule };
234
-
235
- //# sourceMappingURL=compile.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compile.js","names":[],"sources":["../src/compile.ts"],"sourcesContent":["import { parse } from \"@babel/parser\";\nimport _traverse, { type NodePath } from \"@babel/traverse\";\nimport _generate from \"@babel/generator\";\nimport * as t from \"@babel/types\";\nimport { DIRECTIVE, type Target } from \"./constants\";\n\n// @babel/traverse and @babel/generator are CJS; their default export is the\n// function itself under some interop and `{ default }` under others.\nconst traverse = (\n typeof _traverse === \"function\" ? _traverse : (_traverse as any).default\n) as typeof _traverse;\nconst generate = (\n typeof _generate === \"function\" ? _generate : (_generate as any).default\n) as typeof _generate;\n\nexport type ToolType = \"frontend\" | \"backend\" | \"human\";\n\nexport interface CompileOptions {\n /** Which build target to emit. */\n target: Target;\n /** Source filename, used for error messages and source maps. */\n filename?: string;\n /** Emit a source map alongside the code. */\n sourceMaps?: boolean;\n}\n\nexport interface CompileResult {\n code: string;\n map?: object | null;\n}\n\n/** Thrown when a `\"use generative\"` file violates an authoring constraint. */\nexport class GenerativeCompileError extends Error {\n constructor(message: string, filename?: string) {\n super(`[assistant-ui/next]${filename ? ` ${filename}:` : \"\"} ${message}`);\n this.name = \"GenerativeCompileError\";\n }\n}\n\n/** Whether a source string opts into generative compilation via the directive. */\nexport function isGenerativeModule(code: string): boolean {\n // The directive must be a leading statement, preceded only by an optional BOM,\n // whitespace, and line/block comments. Scanned linearly — a regex over the\n // comment prefix is prone to catastrophic backtracking on crafted input.\n let i = code.charCodeAt(0) === 0xfeff ? 1 : 0;\n for (;;) {\n while (i < code.length && /\\s/.test(code[i]!)) i++;\n if (code.startsWith(\"//\", i)) {\n const nl = code.indexOf(\"\\n\", i);\n if (nl === -1) return false;\n i = nl + 1;\n } else if (code.startsWith(\"/*\", i)) {\n const end = code.indexOf(\"*/\", i + 2);\n if (end === -1) return false;\n i = end + 2;\n } else {\n break;\n }\n }\n return (\n code.startsWith(`\"${DIRECTIVE}\"`, i) || code.startsWith(`'${DIRECTIVE}'`, i)\n );\n}\n\n/**\n * Rewrites a `\"use generative\"` module for a single build target, keeping only the\n * regions that target needs and pruning the imports the dropped regions used.\n */\nexport function compileGenerative(\n code: string,\n options: CompileOptions,\n): CompileResult {\n const { target, filename } = options;\n\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\", \"explicitResourceManagement\"],\n });\n\n if (!ast.program.directives.some((d) => d.value.value === DIRECTIVE)) {\n throw new GenerativeCompileError(\n `missing \"${DIRECTIVE}\" directive`,\n filename,\n );\n }\n\n const object = findDefaultExportObject(ast, filename);\n\n let keptRender = false;\n let keptBackendExecute = false;\n\n for (const entry of object.properties) {\n const value = entryValue(entry);\n if (!value) {\n // A non-inline tool (spread, method, or a call like `makeTool()`) can't be\n // analyzed, so its `execute` would pass through to the client unstripped.\n throw new GenerativeCompileError(\n \"each tool must be an inline object literal (`name: { ... }`) so its \" +\n \"`execute` can be routed\",\n filename,\n );\n }\n\n // Nature is inferred from `execute` (see inferToolType), not an authored\n // `type`. The resolved type is written back below so the runtime keeps it.\n const type = inferToolType(value, filename);\n const hasRender = !!findMember(value, \"render\");\n const execute = findMember(value, \"execute\");\n\n if ((type === \"frontend\" || type === \"human\") && !hasRender) {\n throw new GenerativeCompileError(\n `a ${type} tool must declare a \\`render\\` (it has no server execute to show otherwise)`,\n filename,\n );\n }\n\n if (target === \"client\") {\n // A frontend execute stays (its `\"use client\"` marker is no longer needed\n // once the module is client); a backend execute and a human `hitl()`\n // sentinel are both dropped.\n if (execute && type === \"frontend\") stripUseClient(execute);\n else if (execute) removeMember(value, \"execute\");\n if (hasRender) keptRender = true;\n } else {\n // server: render is never needed; only a backend execute survives.\n if (hasRender) removeMember(value, \"render\");\n if (execute && type !== \"backend\") removeMember(value, \"execute\");\n if (execute && type === \"backend\") keptBackendExecute = true;\n }\n\n setToolType(value, type);\n }\n\n pruneUnused(ast);\n\n // Replace the module directives with the target-appropriate one.\n ast.program.directives = ast.program.directives.filter(\n (d) => d.value.value !== DIRECTIVE && d.value.value !== \"use client\",\n );\n if (target === \"client\" && keptRender) {\n ast.program.directives.unshift(\n t.directive(t.directiveLiteral(\"use client\")),\n );\n }\n if (target === \"server\" && keptBackendExecute) {\n ast.program.body.unshift(\n t.importDeclaration([], t.stringLiteral(\"server-only\")),\n );\n }\n\n const result = generate(\n ast,\n {\n sourceMaps: options.sourceMaps ?? false,\n filename,\n jsescOption: { minimal: true },\n },\n code,\n );\n\n return { code: result.code, map: result.map };\n}\n\nfunction findDefaultExportObject(\n ast: t.File,\n filename: string | undefined,\n): t.ObjectExpression {\n let object: t.ObjectExpression | null = null;\n let sawDefault = false;\n\n for (const stmt of ast.program.body) {\n if (!t.isExportDefaultDeclaration(stmt)) continue;\n sawDefault = true;\n object = unwrapDefineToolkit(stmt.declaration);\n // Emit the bare object literal, dropping the `defineToolkit(...)` wrapper\n // (and the import it pulled).\n if (object) stmt.declaration = object;\n }\n\n if (!sawDefault) {\n throw new GenerativeCompileError(\"missing a default export\", filename);\n }\n if (!object) {\n throw new GenerativeCompileError(\n \"the default export must be `defineToolkit({ ... })` (imported from \" +\n '\"@assistant-ui/next\"); wrapping is required so a backend `execute` ' +\n \"can't be authored in a way that reaches the client\",\n filename,\n );\n }\n return object;\n}\n\n/**\n * Unwraps the required `defineToolkit({ ... })` wrapper (through `satisfies`/`as`\n * and parens) to the underlying object literal. Anything else — a bare object, a\n * `satisfies Toolkit` without the wrapper, some other call — yields `null` so the\n * caller errors.\n */\nfunction unwrapDefineToolkit(node: t.Node): t.ObjectExpression | null {\n if (t.isTSSatisfiesExpression(node) || t.isTSAsExpression(node)) {\n return unwrapDefineToolkit(node.expression);\n }\n if (t.isParenthesizedExpression(node)) {\n return unwrapDefineToolkit(node.expression);\n }\n if (\n t.isCallExpression(node) &&\n t.isIdentifier(node.callee, { name: \"defineToolkit\" }) &&\n t.isObjectExpression(node.arguments[0])\n ) {\n return node.arguments[0];\n }\n return null;\n}\n\ntype Entry = t.ObjectExpression[\"properties\"][number];\n\nfunction entryValue(entry: Entry): t.ObjectExpression | null {\n if (t.isObjectProperty(entry) && t.isObjectExpression(entry.value)) {\n return entry.value;\n }\n return null;\n}\n\n/** A member of an entry object: `render`/`execute`/`type`, as property or method. */\nfunction findMember(\n object: t.ObjectExpression,\n name: string,\n): t.ObjectProperty | t.ObjectMethod | undefined {\n return object.properties.find(\n (p): p is t.ObjectProperty | t.ObjectMethod =>\n (t.isObjectProperty(p) || t.isObjectMethod(p)) &&\n memberName(p.key, p.computed) === name,\n );\n}\n\nfunction removeMember(object: t.ObjectExpression, name: string): void {\n object.properties = object.properties.filter(\n (p) =>\n !(\n (t.isObjectProperty(p) || t.isObjectMethod(p)) &&\n memberName(p.key, p.computed) === name\n ),\n );\n}\n\n/** The `BlockStatement` body of an `execute` member, if it has one. */\nfunction executeBody(\n member: t.ObjectProperty | t.ObjectMethod,\n): t.BlockStatement | undefined {\n if (t.isObjectMethod(member)) return member.body;\n const value = member.value;\n if (\n (t.isArrowFunctionExpression(value) || t.isFunctionExpression(value)) &&\n t.isBlockStatement(value.body)\n ) {\n return value.body;\n }\n return undefined;\n}\n\n/** Whether an `execute` opts into the client via a leading `\"use client\"`. */\nfunction executeIsClient(member: t.ObjectProperty | t.ObjectMethod): boolean {\n return !!executeBody(member)?.directives.some(\n (d) => d.value.value === \"use client\",\n );\n}\n\n/** Whether an `execute` is the `hitl()` human-in-the-loop sentinel. */\nfunction executeIsHitl(member: t.ObjectProperty | t.ObjectMethod): boolean {\n return (\n t.isObjectProperty(member) &&\n t.isCallExpression(member.value) &&\n t.isIdentifier(member.value.callee, { name: \"hitl\" })\n );\n}\n\n/** Drops the `\"use client\"` directive from an `execute` body (kept frontend). */\nfunction stripUseClient(member: t.ObjectProperty | t.ObjectMethod): void {\n const body = executeBody(member);\n if (body) {\n body.directives = body.directives.filter(\n (d) => d.value.value !== \"use client\",\n );\n }\n}\n\n/**\n * The tool's nature, inferred from its (mandatory) `execute` rather than an\n * authored `type`: `hitl()` → `human`; `\"use client\"` → `frontend`; otherwise\n * `backend`. The loader writes the result back as a `type` field (see\n * {@link setToolType}) so the runtime keeps it.\n */\nfunction inferToolType(\n object: t.ObjectExpression,\n filename: string | undefined,\n): ToolType {\n const execute = findMember(object, \"execute\");\n if (!execute) {\n throw new GenerativeCompileError(\n \"every tool must declare an `execute`; use `hitl()` for a \" +\n \"human-in-the-loop tool\",\n filename,\n );\n }\n if (executeIsHitl(execute)) return \"human\";\n return executeIsClient(execute) ? \"frontend\" : \"backend\";\n}\n\n/** Writes the resolved `type` back onto the tool object (replacing any author's). */\nfunction setToolType(object: t.ObjectExpression, type: ToolType): void {\n removeMember(object, \"type\");\n // Append (not prepend) so the inferred type wins over any earlier spread.\n object.properties.push(\n t.objectProperty(t.identifier(\"type\"), t.stringLiteral(type)),\n );\n}\n\nfunction memberName(\n key: t.Node,\n computed: boolean | undefined,\n): string | undefined {\n if (computed) return undefined;\n if (t.isIdentifier(key)) return key.name;\n if (t.isStringLiteral(key)) return key.value;\n return undefined;\n}\n\n/**\n * Removes declarations and import specifiers left unreferenced after region\n * removal, to a fixpoint (a dropped helper frees what it used). Keeps exports,\n * side-effect imports, and possibly-side-effectful initializers.\n */\nfunction pruneUnused(ast: t.File): void {\n const hadSpecifiers = new WeakSet<t.ImportDeclaration>();\n for (const stmt of ast.program.body) {\n if (t.isImportDeclaration(stmt) && stmt.specifiers.length > 0) {\n hadSpecifiers.add(stmt);\n }\n }\n\n let removedSomething = true;\n while (removedSomething) {\n removedSomething = false;\n traverse(ast, {\n Program(path: NodePath<t.Program>) {\n path.scope.crawl();\n const isUnused = (name: string): boolean => {\n const binding = path.scope.getBinding(name);\n return !!binding && !binding.referenced;\n };\n\n path.node.body = path.node.body.filter((stmt) => {\n if (\n (t.isFunctionDeclaration(stmt) || t.isClassDeclaration(stmt)) &&\n stmt.id &&\n isUnused(stmt.id.name)\n ) {\n removedSomething = true;\n return false;\n }\n if (t.isVariableDeclaration(stmt)) {\n stmt.declarations = stmt.declarations.filter((decl) => {\n // Handles destructuring too: drop the declarator only when *every*\n // bound name is unused (else a `const { a } = server` survives and\n // keeps a server import in the client graph). Restricted to plain\n // patterns so a default/computed-key side effect isn't dropped.\n const names = Object.keys(t.getBindingIdentifiers(decl.id));\n if (\n names.length > 0 &&\n isPlainPattern(decl.id) &&\n isRemovableInit(decl.init) &&\n names.every(isUnused)\n ) {\n removedSomething = true;\n return false;\n }\n return true;\n });\n if (stmt.declarations.length === 0) return false;\n }\n return true;\n });\n path.stop();\n },\n });\n }\n\n traverse(ast, {\n Program(path: NodePath<t.Program>) {\n path.scope.crawl();\n for (const stmt of path.node.body) {\n if (!t.isImportDeclaration(stmt)) continue;\n stmt.specifiers = stmt.specifiers.filter((spec) => {\n const binding = path.scope.getBinding(spec.local.name);\n return binding ? binding.referenced : true;\n });\n }\n path.node.body = path.node.body.filter(\n (stmt) =>\n !(\n t.isImportDeclaration(stmt) &&\n stmt.specifiers.length === 0 &&\n hadSpecifiers.has(stmt)\n ),\n );\n path.stop();\n },\n });\n}\n\n/**\n * Whether a binding pattern is side-effect-free to drop: a plain identifier, or\n * an object/array pattern of plain bindings — no default values\n * (`{ a = expr }`) or computed keys (`{ [expr]: a }`), which would evaluate (and\n * thus could have side effects) at destructuring time.\n */\nfunction isPlainPattern(node: t.Node): boolean {\n if (t.isIdentifier(node)) return true;\n if (t.isObjectPattern(node)) {\n return node.properties.every((p) =>\n t.isRestElement(p)\n ? isPlainPattern(p.argument)\n : !p.computed && isPlainPattern(p.value),\n );\n }\n if (t.isArrayPattern(node)) {\n return node.elements.every((el) => el == null || isPlainPattern(el));\n }\n return false; // AssignmentPattern (default), member expr, etc.\n}\n\n/** Whether a variable initializer is safe to drop (no observable side effects). */\nfunction isRemovableInit(node: t.Expression | null | undefined): boolean {\n if (node == null) return true;\n if (t.isTSAsExpression(node) || t.isTSSatisfiesExpression(node)) {\n return isRemovableInit(node.expression);\n }\n // Containers are removable only if every element is — a nested call (e.g.\n // `[track()]`) has an observable side effect that dropping would lose.\n if (t.isArrayExpression(node)) {\n return node.elements.every(\n (el) => el == null || (t.isExpression(el) && isRemovableInit(el)),\n );\n }\n if (t.isObjectExpression(node)) {\n return node.properties.every(\n (p) =>\n t.isObjectProperty(p) &&\n !p.computed &&\n t.isExpression(p.value) &&\n isRemovableInit(p.value),\n );\n }\n if (t.isTemplateLiteral(node)) {\n return node.expressions.every(\n (e) => t.isExpression(e) && isRemovableInit(e),\n );\n }\n return (\n t.isArrowFunctionExpression(node) ||\n t.isFunctionExpression(node) ||\n t.isClassExpression(node) ||\n t.isIdentifier(node) ||\n // non-computed only — `obj[fn()]` could hide a side-effectful key\n (t.isMemberExpression(node) && !node.computed) ||\n t.isJSXElement(node) ||\n t.isJSXFragment(node) ||\n t.isLiteral(node)\n );\n}\n"],"mappings":";;;;;;AAQA,MAAM,WACJ,OAAO,cAAc,aAAa,YAAa,UAAkB;AAEnE,MAAM,WACJ,OAAO,cAAc,aAAa,YAAa,UAAkB;;AAoBnE,IAAa,yBAAb,cAA4C,MAAM;CAChD,YAAY,SAAiB,UAAmB;EAC9C,MAAM,sBAAsB,WAAW,IAAI,SAAS,KAAK,GAAG,GAAG,SAAS;EACxE,KAAK,OAAO;CACd;AACF;;AAGA,SAAgB,mBAAmB,MAAuB;CAIxD,IAAI,IAAI,KAAK,WAAW,CAAC,MAAM,QAAS,IAAI;CAC5C,SAAS;EACP,OAAO,IAAI,KAAK,UAAU,KAAK,KAAK,KAAK,EAAG,GAAG;EAC/C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zB,IAAI,EAAE,iBAAiB,IAAI,KAAK,EAAE,wBAAwB,IAAI,GAC5D,OAAO,gBAAgB,KAAK,UAAU;CAIxC,IAAI,EAAE,kBAAkB,IAAI,GAC1B,OAAO,KAAK,SAAS,OAClB,OAAO,MAAM,QAAS,EAAE,aAAa,EAAE,KAAK,gBAAgB,EAAE,CACjE;CAEF,IAAI,EAAE,mBAAmB,IAAI,GAC3B,OAAO,KAAK,WAAW,OACpB,MACC,EAAE,iBAAiB,CAAC,KACpB,CAAC,EAAE,YACH,EAAE,aAAa,EAAE,KAAK,KACtB,gBAAgB,EAAE,KAAK,CAC3B;CAEF,IAAI,EAAE,kBAAkB,IAAI,GAC1B,OAAO,KAAK,YAAY,OACrB,MAAM,EAAE,aAAa,CAAC,KAAK,gBAAgB,CAAC,CAC/C;CAEF,OACE,EAAE,0BAA0B,IAAI,KAChC,EAAE,qBAAqB,IAAI,KAC3B,EAAE,kBAAkB,IAAI,KACxB,EAAE,aAAa,IAAI,KAElB,EAAE,mBAAmB,IAAI,KAAK,CAAC,KAAK,YACrC,EAAE,aAAa,IAAI,KACnB,EAAE,cAAc,IAAI,KACpB,EAAE,UAAU,IAAI;AAEpB"}
@@ -1,8 +0,0 @@
1
- //#region src/constants.d.ts
2
- /** The directive a module uses to opt into generative compilation. */
3
- declare const DIRECTIVE = "use generative";
4
- /** Build target a generative module is compiled for. */
5
- type Target = "client" | "server";
6
- //#endregion
7
- export { DIRECTIVE, Target };
8
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";;cACa,SAAA;;KAGD,MAAA"}
package/dist/constants.js DELETED
@@ -1,7 +0,0 @@
1
- //#region src/constants.ts
2
- /** The directive a module uses to opt into generative compilation. */
3
- const DIRECTIVE = "use generative";
4
- //#endregion
5
- export { DIRECTIVE };
6
-
7
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["/** The directive a module uses to opt into generative compilation. */\nexport const DIRECTIVE = \"use generative\";\n\n/** Build target a generative module is compiled for. */\nexport type Target = \"client\" | \"server\";\n"],"mappings":";;AACA,MAAa,YAAY"}
@@ -1,19 +0,0 @@
1
- import { Toolkit, ToolkitDeclaration } from "@assistant-ui/core/react";
2
-
3
- //#region src/define-toolkit.d.ts
4
- /**
5
- * Authoring helper for a `"use generative"` toolkit. Accepts the permissive
6
- * {@link ToolkitDeclaration} (a `backend` tool may carry its server `execute`)
7
- * and types the result as the canonical {@link Toolkit}.
8
- *
9
- * It has **no runtime implementation**. The `@assistant-ui/next` compiler strips
10
- * the `defineToolkit(...)` wrapper (and its import) per build, so a correctly
11
- * compiled `export default defineToolkit({...})` never calls this. If it *does*
12
- * run, the module was not compiled by the use-generative loader — e.g.
13
- * `defineToolkit` used outside a `"use generative"` file — which would ship a
14
- * backend `execute` to the client. So it throws instead of silently leaking.
15
- */
16
- declare function defineToolkit(_declaration: ToolkitDeclaration): Toolkit;
17
- //#endregion
18
- export { defineToolkit };
19
- //# sourceMappingURL=define-toolkit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"define-toolkit.d.ts","names":[],"sources":["../src/define-toolkit.ts"],"mappings":";;;;;AAcA;;;;;;;;AAAwE;;iBAAxD,aAAA,CAAc,YAAA,EAAc,kBAAA,GAAqB,OAAO"}
@@ -1,20 +0,0 @@
1
- //#region src/define-toolkit.ts
2
- /**
3
- * Authoring helper for a `"use generative"` toolkit. Accepts the permissive
4
- * {@link ToolkitDeclaration} (a `backend` tool may carry its server `execute`)
5
- * and types the result as the canonical {@link Toolkit}.
6
- *
7
- * It has **no runtime implementation**. The `@assistant-ui/next` compiler strips
8
- * the `defineToolkit(...)` wrapper (and its import) per build, so a correctly
9
- * compiled `export default defineToolkit({...})` never calls this. If it *does*
10
- * run, the module was not compiled by the use-generative loader — e.g.
11
- * `defineToolkit` used outside a `"use generative"` file — which would ship a
12
- * backend `execute` to the client. So it throws instead of silently leaking.
13
- */
14
- function defineToolkit(_declaration) {
15
- throw new Error("[assistant-ui/next] defineToolkit() has no runtime implementation — it is stripped at build time by the use-generative compiler. Reaching it means this module was not compiled (e.g. defineToolkit used outside a \"use generative\" file). Add the directive, or do not use defineToolkit here.");
16
- }
17
- //#endregion
18
- export { defineToolkit };
19
-
20
- //# sourceMappingURL=define-toolkit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"define-toolkit.js","names":[],"sources":["../src/define-toolkit.ts"],"sourcesContent":["import type { Toolkit, ToolkitDeclaration } from \"@assistant-ui/core/react\";\n\n/**\n * Authoring helper for a `\"use generative\"` toolkit. Accepts the permissive\n * {@link ToolkitDeclaration} (a `backend` tool may carry its server `execute`)\n * and types the result as the canonical {@link Toolkit}.\n *\n * It has **no runtime implementation**. The `@assistant-ui/next` compiler strips\n * the `defineToolkit(...)` wrapper (and its import) per build, so a correctly\n * compiled `export default defineToolkit({...})` never calls this. If it *does*\n * run, the module was not compiled by the use-generative loader — e.g.\n * `defineToolkit` used outside a `\"use generative\"` file — which would ship a\n * backend `execute` to the client. So it throws instead of silently leaking.\n */\nexport function defineToolkit(_declaration: ToolkitDeclaration): Toolkit {\n throw new Error(\n \"[assistant-ui/next] defineToolkit() has no runtime implementation — it is \" +\n \"stripped at build time by the use-generative compiler. Reaching it means \" +\n 'this module was not compiled (e.g. defineToolkit used outside a \"use ' +\n 'generative\" file). Add the directive, or do not use defineToolkit here.',\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,cAAc,cAA2C;CACvE,MAAM,IAAI,MACR,mSAIF;AACF"}
package/dist/hitl.d.ts DELETED
@@ -1,18 +0,0 @@
1
- //#region src/hitl.d.ts
2
- /**
3
- * Marks a tool as **human-in-the-loop**: the agent pauses and the UI (`render`)
4
- * supplies the result instead of code. Use it as the tool's `execute`:
5
- *
6
- * ```tsx
7
- * confirm: { execute: hitl(), render: (props) => <Confirm {...props} /> }
8
- * ```
9
- *
10
- * Like {@link defineToolkit}, it has **no runtime implementation**: the
11
- * `@assistant-ui/next` compiler detects `execute: hitl()`, drops it, and stamps
12
- * the tool `type: "human"`. Reaching it at runtime means the module wasn't
13
- * compiled (used outside a `"use generative"` file), so it throws.
14
- */
15
- declare function hitl(): never;
16
- //#endregion
17
- export { hitl };
18
- //# sourceMappingURL=hitl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hitl.d.ts","names":[],"sources":["../src/hitl.ts"],"mappings":";;AAaA;;;;AAAoB;;;;;;;;iBAAJ,IAAA"}
package/dist/hitl.js DELETED
@@ -1,21 +0,0 @@
1
- //#region src/hitl.ts
2
- /**
3
- * Marks a tool as **human-in-the-loop**: the agent pauses and the UI (`render`)
4
- * supplies the result instead of code. Use it as the tool's `execute`:
5
- *
6
- * ```tsx
7
- * confirm: { execute: hitl(), render: (props) => <Confirm {...props} /> }
8
- * ```
9
- *
10
- * Like {@link defineToolkit}, it has **no runtime implementation**: the
11
- * `@assistant-ui/next` compiler detects `execute: hitl()`, drops it, and stamps
12
- * the tool `type: "human"`. Reaching it at runtime means the module wasn't
13
- * compiled (used outside a `"use generative"` file), so it throws.
14
- */
15
- function hitl() {
16
- throw new Error("[assistant-ui/next] hitl() has no runtime implementation — it marks a human-in-the-loop tool and is stripped at build time by the use-generative compiler. Reaching it means this module was not compiled (e.g. hitl() used outside a \"use generative\" file).");
17
- }
18
- //#endregion
19
- export { hitl };
20
-
21
- //# sourceMappingURL=hitl.js.map
package/dist/hitl.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"hitl.js","names":[],"sources":["../src/hitl.ts"],"sourcesContent":["/**\n * Marks a tool as **human-in-the-loop**: the agent pauses and the UI (`render`)\n * supplies the result instead of code. Use it as the tool's `execute`:\n *\n * ```tsx\n * confirm: { execute: hitl(), render: (props) => <Confirm {...props} /> }\n * ```\n *\n * Like {@link defineToolkit}, it has **no runtime implementation**: the\n * `@assistant-ui/next` compiler detects `execute: hitl()`, drops it, and stamps\n * the tool `type: \"human\"`. Reaching it at runtime means the module wasn't\n * compiled (used outside a `\"use generative\"` file), so it throws.\n */\nexport function hitl(): never {\n throw new Error(\n \"[assistant-ui/next] hitl() has no runtime implementation — it marks a \" +\n \"human-in-the-loop tool and is stripped at build time by the \" +\n \"use-generative compiler. Reaching it means this module was not compiled \" +\n '(e.g. hitl() used outside a \"use generative\" file).',\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAaA,SAAgB,OAAc;CAC5B,MAAM,IAAI,MACR,iQAIF;AACF"}