ai-props 2.1.3 → 2.3.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.
Files changed (73) hide show
  1. package/.dev.vars +2 -0
  2. package/CHANGELOG.md +11 -0
  3. package/README.md +2 -0
  4. package/package.json +39 -13
  5. package/src/ai.ts +12 -31
  6. package/src/cascade.ts +795 -0
  7. package/src/client.ts +440 -0
  8. package/src/durable-cascade.ts +743 -0
  9. package/src/event-bridge.ts +478 -0
  10. package/src/generate.ts +14 -12
  11. package/src/hoc.ts +15 -19
  12. package/src/hono-jsx.ts +675 -0
  13. package/src/index.ts +30 -0
  14. package/src/mdx-types.ts +169 -0
  15. package/src/mdx-utils.ts +437 -0
  16. package/src/mdx.ts +1008 -0
  17. package/src/rpc.ts +614 -0
  18. package/src/streaming.ts +618 -0
  19. package/src/validate.ts +15 -29
  20. package/src/worker.ts +547 -0
  21. package/test/cascade.test.ts +338 -0
  22. package/test/durable-cascade.test.ts +319 -0
  23. package/test/event-bridge.test.ts +351 -0
  24. package/test/generate.test.ts +6 -16
  25. package/test/mdx.test.ts +817 -0
  26. package/test/worker/capnweb-rpc.test.ts +1084 -0
  27. package/test/worker/full-flow.integration.test.ts +1463 -0
  28. package/test/worker/hono-jsx.test.ts +1258 -0
  29. package/test/worker/mdx-parsing.test.ts +1148 -0
  30. package/test/worker/setup.ts +56 -0
  31. package/test/worker.test.ts +595 -0
  32. package/tsconfig.json +2 -1
  33. package/vitest.config.js +6 -0
  34. package/vitest.config.ts +15 -1
  35. package/vitest.workers.config.ts +58 -0
  36. package/wrangler.jsonc +27 -0
  37. package/.turbo/turbo-build.log +0 -4
  38. package/LICENSE +0 -21
  39. package/dist/ai.d.ts +0 -125
  40. package/dist/ai.d.ts.map +0 -1
  41. package/dist/ai.js +0 -199
  42. package/dist/ai.js.map +0 -1
  43. package/dist/cache.d.ts +0 -66
  44. package/dist/cache.d.ts.map +0 -1
  45. package/dist/cache.js +0 -183
  46. package/dist/cache.js.map +0 -1
  47. package/dist/generate.d.ts +0 -69
  48. package/dist/generate.d.ts.map +0 -1
  49. package/dist/generate.js +0 -221
  50. package/dist/generate.js.map +0 -1
  51. package/dist/hoc.d.ts +0 -164
  52. package/dist/hoc.d.ts.map +0 -1
  53. package/dist/hoc.js +0 -236
  54. package/dist/hoc.js.map +0 -1
  55. package/dist/index.d.ts +0 -15
  56. package/dist/index.d.ts.map +0 -1
  57. package/dist/index.js +0 -21
  58. package/dist/index.js.map +0 -1
  59. package/dist/types.d.ts +0 -152
  60. package/dist/types.d.ts.map +0 -1
  61. package/dist/types.js +0 -7
  62. package/dist/types.js.map +0 -1
  63. package/dist/validate.d.ts +0 -58
  64. package/dist/validate.d.ts.map +0 -1
  65. package/dist/validate.js +0 -253
  66. package/dist/validate.js.map +0 -1
  67. package/src/ai.js +0 -198
  68. package/src/cache.js +0 -182
  69. package/src/generate.js +0 -220
  70. package/src/hoc.js +0 -235
  71. package/src/index.js +0 -20
  72. package/src/types.js +0 -6
  73. package/src/validate.js +0 -252
package/.dev.vars ADDED
@@ -0,0 +1,2 @@
1
+ AI_GATEWAY_TOKEN=oS40l795q0Hrn-uKQ2Zew6utQV-GPrey6d9lUrlt
2
+ AI_GATEWAY_URL=https://gateway.ai.cloudflare.com/v1/b6641681fe423910342b9ffa1364c76d/mdxai
package/CHANGELOG.md CHANGED
@@ -1,10 +1,21 @@
1
1
  # ai-props
2
2
 
3
+ ## 2.3.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [9e2779a]
8
+ - Updated dependencies [2787830]
9
+ - ai-functions@2.3.0
10
+ - language-models@2.3.0
11
+ - ai-providers@2.3.0
12
+
3
13
  ## 2.1.3
4
14
 
5
15
  ### Patch Changes
6
16
 
7
17
  - Documentation and testing improvements
18
+
8
19
  - Add deterministic AI testing suite with self-validating patterns
9
20
  - Apply StoryBrand narrative to all package READMEs
10
21
  - Update TESTING.md with four principles of deterministic AI testing
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # ai-props
2
2
 
3
+ ![Stability: Experimental](https://img.shields.io/badge/stability-experimental-red)
4
+
3
5
  **Stop manually writing placeholder props. Let AI fill in the blanks.**
4
6
 
5
7
  You've built a beautiful component library. But every time you use a component, you're stuck inventing placeholder text, mock data, and dummy content. Your `<UserCard />` needs a bio. Your `<ProductCard />` needs a description. Your `<SEOHead />` needs meta tags.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-props",
3
- "version": "2.1.3",
3
+ "version": "2.3.0",
4
4
  "description": "AI-powered props primitives for intelligent component properties",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -9,14 +9,48 @@
9
9
  ".": {
10
10
  "import": "./dist/index.js",
11
11
  "types": "./dist/index.d.ts"
12
+ },
13
+ "./worker": {
14
+ "import": "./dist/worker.js",
15
+ "types": "./dist/worker.d.ts"
16
+ },
17
+ "./mdx": {
18
+ "import": "./dist/mdx.js",
19
+ "types": "./dist/mdx.d.ts"
20
+ },
21
+ "./streaming": {
22
+ "import": "./dist/streaming.js",
23
+ "types": "./dist/streaming.d.ts"
24
+ },
25
+ "./rpc": {
26
+ "import": "./dist/rpc.js",
27
+ "types": "./dist/rpc.d.ts"
28
+ },
29
+ "./client": {
30
+ "import": "./dist/client.js",
31
+ "types": "./dist/client.d.ts"
12
32
  }
13
33
  },
34
+ "scripts": {
35
+ "build": "tsc",
36
+ "dev": "tsc --watch",
37
+ "test": "vitest run",
38
+ "test:worker": "vitest --config vitest.workers.config.ts",
39
+ "typecheck": "tsc --noEmit",
40
+ "lint": "eslint .",
41
+ "clean": "rm -rf dist"
42
+ },
14
43
  "dependencies": {
15
- "ai-functions": "2.1.3"
44
+ "ai-functions": "2.3.0",
45
+ "ai-providers": "2.3.0",
46
+ "language-models": "2.3.0",
47
+ "hono": "^4.0.0"
16
48
  },
17
49
  "devDependencies": {
50
+ "@cloudflare/vitest-pool-workers": "^0.8.0",
51
+ "@cloudflare/workers-types": "^4.20250109.0",
18
52
  "typescript": "^5.7.2",
19
- "vitest": "^2.1.9"
53
+ "vitest": "3.0.4"
20
54
  },
21
55
  "keywords": [
22
56
  "ai",
@@ -24,13 +58,5 @@
24
58
  "react",
25
59
  "primitives"
26
60
  ],
27
- "license": "MIT",
28
- "scripts": {
29
- "build": "tsc",
30
- "dev": "tsc --watch",
31
- "test": "vitest",
32
- "typecheck": "tsc --noEmit",
33
- "lint": "eslint .",
34
- "clean": "rm -rf dist"
35
- }
36
- }
61
+ "license": "MIT"
62
+ }
package/src/ai.ts CHANGED
@@ -8,12 +8,7 @@
8
8
  */
9
9
 
10
10
  import type { SimpleSchema } from 'ai-functions'
11
- import type {
12
- PropSchema,
13
- AIComponentOptions,
14
- AIComponent,
15
- AIPropsConfig,
16
- } from './types.js'
11
+ import type { PropSchema, AIComponentOptions, AIComponent, AIPropsConfig } from './types.js'
17
12
  import { generateProps, mergeWithGenerated } from './generate.js'
18
13
 
19
14
  /**
@@ -59,23 +54,17 @@ export function AI<P extends Record<string, unknown>>(
59
54
 
60
55
  // Check if all required props are provided
61
56
  const missingRequired = (required as string[]).filter(
62
- key => propsWithDefaults[key as keyof P] === undefined
57
+ (key) => propsWithDefaults[key as keyof P] === undefined
63
58
  )
64
59
  if (missingRequired.length > 0) {
65
- throw new Error(
66
- `Missing required props: ${missingRequired.join(', ')}`
67
- )
60
+ throw new Error(`Missing required props: ${missingRequired.join(', ')}`)
68
61
  }
69
62
 
70
63
  // Generate missing props
71
- const fullProps = await mergeWithGenerated<P>(
72
- filteredSchema,
73
- propsWithDefaults as Partial<P>,
74
- {
75
- model: config.model,
76
- system: config.system,
77
- }
78
- )
64
+ const fullProps = await mergeWithGenerated<P>(filteredSchema, propsWithDefaults as Partial<P>, {
65
+ ...(config.model !== undefined && { model: config.model }),
66
+ ...(config.system !== undefined && { system: config.system }),
67
+ })
79
68
 
80
69
  return fullProps
81
70
  }
@@ -145,9 +134,7 @@ export function createAIComponent<P extends Record<string, unknown>>(
145
134
  * })
146
135
  * ```
147
136
  */
148
- export function definePropsSchema<T extends Record<string, string | SimpleSchema>>(
149
- schema: T
150
- ): T {
137
+ export function definePropsSchema<T extends Record<string, string | SimpleSchema>>(schema: T): T {
151
138
  return schema
152
139
  }
153
140
 
@@ -185,16 +172,13 @@ export function createComponentFactory<P extends Record<string, unknown>>(
185
172
  * Generate multiple instances
186
173
  */
187
174
  generateMany: async (contexts: Partial<P>[]): Promise<P[]> => {
188
- return Promise.all(contexts.map(ctx => component(ctx)))
175
+ return Promise.all(contexts.map((ctx) => component(ctx)))
189
176
  },
190
177
 
191
178
  /**
192
179
  * Generate with specific overrides
193
180
  */
194
- generateWith: async (
195
- context: Partial<P>,
196
- overrides: Partial<P>
197
- ): Promise<P> => {
181
+ generateWith: async (context: Partial<P>, overrides: Partial<P>): Promise<P> => {
198
182
  const generated = await component(context)
199
183
  return { ...generated, ...overrides }
200
184
  },
@@ -232,9 +216,7 @@ export function composeAIComponents<
232
216
  [K in keyof T]: T[K] extends AIComponentOptions<infer P> ? P : never
233
217
  }
234
218
 
235
- const aiComponent = async (
236
- partialProps: Partial<ResultProps>
237
- ): Promise<ResultProps> => {
219
+ const aiComponent = async (partialProps: Partial<ResultProps>): Promise<ResultProps> => {
238
220
  const results: Record<string, unknown> = {}
239
221
 
240
222
  // Generate each component's props
@@ -257,8 +239,7 @@ export function composeAIComponents<
257
239
 
258
240
  aiComponent.schema = composedSchema as PropSchema
259
241
  aiComponent.config = {}
260
- aiComponent.generateProps = (context?: Partial<ResultProps>) =>
261
- aiComponent(context || {})
242
+ aiComponent.generateProps = (context?: Partial<ResultProps>) => aiComponent(context || {})
262
243
 
263
244
  return aiComponent as AIComponent<ResultProps>
264
245
  }