ai-props 2.1.3 → 2.4.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 (105) hide show
  1. package/.dev.vars +2 -0
  2. package/.turbo/turbo-build.log +1 -1
  3. package/CHANGELOG.md +20 -0
  4. package/README.md +2 -0
  5. package/dist/ai.d.ts.map +1 -1
  6. package/dist/ai.js +4 -4
  7. package/dist/ai.js.map +1 -1
  8. package/dist/cascade.d.ts +329 -0
  9. package/dist/cascade.d.ts.map +1 -0
  10. package/dist/cascade.js +522 -0
  11. package/dist/cascade.js.map +1 -0
  12. package/dist/client.d.ts +233 -0
  13. package/dist/client.d.ts.map +1 -0
  14. package/dist/client.js +191 -0
  15. package/dist/client.js.map +1 -0
  16. package/dist/durable-cascade.d.ts +280 -0
  17. package/dist/durable-cascade.d.ts.map +1 -0
  18. package/dist/durable-cascade.js +469 -0
  19. package/dist/durable-cascade.js.map +1 -0
  20. package/dist/event-bridge.d.ts +257 -0
  21. package/dist/event-bridge.d.ts.map +1 -0
  22. package/dist/event-bridge.js +317 -0
  23. package/dist/event-bridge.js.map +1 -0
  24. package/dist/generate.d.ts.map +1 -1
  25. package/dist/generate.js +12 -6
  26. package/dist/generate.js.map +1 -1
  27. package/dist/hoc.d.ts.map +1 -1
  28. package/dist/hoc.js +13 -13
  29. package/dist/hoc.js.map +1 -1
  30. package/dist/hono-jsx.d.ts +208 -0
  31. package/dist/hono-jsx.d.ts.map +1 -0
  32. package/dist/hono-jsx.js +459 -0
  33. package/dist/hono-jsx.js.map +1 -0
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +2 -0
  37. package/dist/index.js.map +1 -1
  38. package/dist/mdx-types.d.ts +152 -0
  39. package/dist/mdx-types.d.ts.map +1 -0
  40. package/dist/mdx-types.js +9 -0
  41. package/dist/mdx-types.js.map +1 -0
  42. package/dist/mdx-utils.d.ts +106 -0
  43. package/dist/mdx-utils.d.ts.map +1 -0
  44. package/dist/mdx-utils.js +384 -0
  45. package/dist/mdx-utils.js.map +1 -0
  46. package/dist/mdx.d.ts +230 -0
  47. package/dist/mdx.d.ts.map +1 -0
  48. package/dist/mdx.js +820 -0
  49. package/dist/mdx.js.map +1 -0
  50. package/dist/rpc.d.ts +313 -0
  51. package/dist/rpc.d.ts.map +1 -0
  52. package/dist/rpc.js +359 -0
  53. package/dist/rpc.js.map +1 -0
  54. package/dist/streaming.d.ts +199 -0
  55. package/dist/streaming.d.ts.map +1 -0
  56. package/dist/streaming.js +402 -0
  57. package/dist/streaming.js.map +1 -0
  58. package/dist/validate.d.ts.map +1 -1
  59. package/dist/validate.js +11 -13
  60. package/dist/validate.js.map +1 -1
  61. package/dist/worker.d.ts +270 -0
  62. package/dist/worker.d.ts.map +1 -0
  63. package/dist/worker.js +405 -0
  64. package/dist/worker.js.map +1 -0
  65. package/package.json +39 -13
  66. package/src/ai.ts +12 -31
  67. package/src/cascade.ts +795 -0
  68. package/src/client.ts +440 -0
  69. package/src/durable-cascade.ts +743 -0
  70. package/src/event-bridge.ts +478 -0
  71. package/src/generate.ts +14 -12
  72. package/src/hoc.ts +15 -19
  73. package/src/hono-jsx.ts +675 -0
  74. package/src/index.ts +30 -0
  75. package/src/mdx-types.ts +169 -0
  76. package/src/mdx-utils.ts +437 -0
  77. package/src/mdx.ts +1008 -0
  78. package/src/rpc.ts +614 -0
  79. package/src/streaming.ts +618 -0
  80. package/src/validate.ts +15 -29
  81. package/src/worker.ts +547 -0
  82. package/test/cascade.test.ts +338 -0
  83. package/test/durable-cascade.test.ts +319 -0
  84. package/test/event-bridge.test.ts +351 -0
  85. package/test/generate.test.ts +6 -16
  86. package/test/mdx.test.ts +817 -0
  87. package/test/worker/capnweb-rpc.test.ts +1084 -0
  88. package/test/worker/full-flow.integration.test.ts +1463 -0
  89. package/test/worker/hono-jsx.test.ts +1258 -0
  90. package/test/worker/mdx-parsing.test.ts +1148 -0
  91. package/test/worker/setup.ts +56 -0
  92. package/test/worker.test.ts +595 -0
  93. package/tsconfig.json +2 -1
  94. package/vitest.config.js +6 -0
  95. package/vitest.config.ts +15 -1
  96. package/vitest.workers.config.ts +58 -0
  97. package/wrangler.jsonc +27 -0
  98. package/LICENSE +0 -21
  99. package/src/ai.js +0 -198
  100. package/src/cache.js +0 -182
  101. package/src/generate.js +0 -220
  102. package/src/hoc.js +0 -235
  103. package/src/index.js +0 -20
  104. package/src/types.js +0 -6
  105. package/src/validate.js +0 -252
@@ -0,0 +1,270 @@
1
+ /**
2
+ * Worker Export - WorkerEntrypoint for RPC access to AI Props
3
+ *
4
+ * Exposes AI props generation methods via Cloudflare RPC.
5
+ * Provides schema-based prop generation, caching, validation,
6
+ * and cascade execution patterns.
7
+ *
8
+ * ## Features
9
+ *
10
+ * - **RPC Service**: WorkerEntrypoint for service binding access
11
+ * - **Cascade Execution**: Code -> Generative -> Agentic -> Human escalation
12
+ * - **Durable Cascades**: Cloudflare Workflows integration for durability
13
+ * - **AI Gateway**: Configuration helpers for Cloudflare AI Gateway
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // wrangler.jsonc
18
+ * {
19
+ * "services": [
20
+ * { "binding": "AI_PROPS", "service": "ai-props" }
21
+ * ]
22
+ * }
23
+ *
24
+ * // worker.ts - consuming service
25
+ * export default {
26
+ * async fetch(request: Request, env: Env) {
27
+ * const service = env.AI_PROPS.connect()
28
+ * const result = await service.generate({
29
+ * schema: { title: 'Page title', description: 'Page description' },
30
+ * context: { topic: 'AI' }
31
+ * })
32
+ * return Response.json(result.props)
33
+ * }
34
+ * }
35
+ * ```
36
+ *
37
+ * ## Cascade Pattern
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * import {
42
+ * DurableCascadeExecutor,
43
+ * createDurableCascadeStep,
44
+ * createAIGatewayConfig
45
+ * } from 'ai-props/worker'
46
+ *
47
+ * // Create a durable cascade for content generation
48
+ * const contentCascade = createDurableCascadeStep({
49
+ * name: 'generate-content',
50
+ * code: async (input) => {
51
+ * if (input.template) return { content: input.template }
52
+ * throw new Error('No template available')
53
+ * },
54
+ * generative: async (input, ctx) => {
55
+ * const result = await ctx.ai.run('@cf/meta/llama-3-8b-instruct', {
56
+ * messages: [{ role: 'user', content: `Generate content about: ${input.topic}` }]
57
+ * })
58
+ * return { content: result.response }
59
+ * }
60
+ * })
61
+ *
62
+ * // In a Cloudflare Workflow
63
+ * const result = await contentCascade.run(step, { topic: 'AI' })
64
+ * console.log(result.tier) // 'code' or 'generative'
65
+ * ```
66
+ *
67
+ * @packageDocumentation
68
+ */
69
+ import { WorkerEntrypoint, RpcTarget } from 'cloudflare:workers';
70
+ import type { PropSchema, GeneratePropsOptions, GeneratePropsResult, AIPropsConfig, PropsCacheEntry, ValidationResult } from './types.js';
71
+ /**
72
+ * Environment bindings for the worker
73
+ */
74
+ export interface Env {
75
+ AI?: unknown;
76
+ }
77
+ /**
78
+ * PropsServiceCore - RpcTarget wrapper for AI props functionality
79
+ *
80
+ * Exposes all required methods as RPC-callable methods.
81
+ * This is the core service class that can be instantiated directly.
82
+ */
83
+ export declare class PropsServiceCore extends RpcTarget {
84
+ private cache;
85
+ constructor();
86
+ /**
87
+ * Generate props using AI
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * const result = await service.generate({
92
+ * schema: {
93
+ * title: 'A compelling page title',
94
+ * description: 'A brief description',
95
+ * },
96
+ * context: { topic: 'AI-powered applications' },
97
+ * })
98
+ * ```
99
+ */
100
+ generate<T = Record<string, unknown>>(options: GeneratePropsOptions): Promise<GeneratePropsResult<T>>;
101
+ /**
102
+ * Generate props synchronously from cache
103
+ *
104
+ * @throws {Error} If props are not in cache
105
+ */
106
+ getSync<T = Record<string, unknown>>(schema: PropSchema, context?: Record<string, unknown>): T;
107
+ /**
108
+ * Pre-generate props for warming the cache
109
+ */
110
+ prefetch(requests: GeneratePropsOptions[]): Promise<void>;
111
+ /**
112
+ * Generate multiple prop sets in parallel
113
+ */
114
+ generateMany<T = Record<string, unknown>>(requests: GeneratePropsOptions[]): Promise<GeneratePropsResult<T>[]>;
115
+ /**
116
+ * Merge partial props with generated props
117
+ *
118
+ * Generates only the missing props, keeping provided ones.
119
+ */
120
+ mergeWithGenerated<T extends Record<string, unknown>>(schema: PropSchema, partialProps: Partial<T>, options?: Omit<GeneratePropsOptions, 'schema' | 'context'>): Promise<T>;
121
+ /**
122
+ * Configure global AI props settings
123
+ */
124
+ configure(config: Partial<AIPropsConfig>): void;
125
+ /**
126
+ * Get current configuration
127
+ */
128
+ getConfig(): AIPropsConfig;
129
+ /**
130
+ * Reset configuration to defaults
131
+ */
132
+ resetConfig(): void;
133
+ /**
134
+ * Get cached props by key
135
+ */
136
+ getCached<T>(key: string): PropsCacheEntry<T> | undefined;
137
+ /**
138
+ * Set props in cache
139
+ */
140
+ setCached<T>(key: string, props: T): void;
141
+ /**
142
+ * Delete cached entry by key
143
+ */
144
+ deleteCached(key: string): boolean;
145
+ /**
146
+ * Clear all cached props
147
+ */
148
+ clearCache(): void;
149
+ /**
150
+ * Get cache size
151
+ */
152
+ getCacheSize(): number;
153
+ /**
154
+ * Create a cache key from schema and context
155
+ */
156
+ createCacheKey(schema: PropSchema, context?: Record<string, unknown>): string;
157
+ /**
158
+ * Configure cache TTL
159
+ */
160
+ configureCache(ttl: number): void;
161
+ /**
162
+ * Validate props against a schema
163
+ */
164
+ validate(props: Record<string, unknown>, schema: PropSchema): ValidationResult;
165
+ /**
166
+ * Check if all required props are present
167
+ */
168
+ hasRequired(props: Record<string, unknown>, required: string[]): boolean;
169
+ /**
170
+ * Get list of missing props according to schema
171
+ */
172
+ getMissing(props: Record<string, unknown>, schema: PropSchema): string[];
173
+ /**
174
+ * Check if props are complete according to schema
175
+ */
176
+ isComplete(props: Record<string, unknown>, schema: PropSchema): boolean;
177
+ /**
178
+ * Sanitize props by removing unknown keys
179
+ */
180
+ sanitize<T extends Record<string, unknown>>(props: T, schema: PropSchema): Partial<T>;
181
+ /**
182
+ * Merge props with default values
183
+ */
184
+ mergeDefaults<T extends Record<string, unknown>>(props: Partial<T>, defaults: Partial<T>, schema: PropSchema): Partial<T>;
185
+ }
186
+ /**
187
+ * PropsService - WorkerEntrypoint for RPC access
188
+ *
189
+ * Provides `connect()` method that returns an RpcTarget service
190
+ * with all AI props methods. Also handles HTTP endpoints for
191
+ * direct JSON-RPC access.
192
+ *
193
+ * @example
194
+ * ```typescript
195
+ * // In consuming worker
196
+ * const service = env.AI_PROPS.connect()
197
+ * const result = await service.generate({
198
+ * schema: { title: 'Page title' }
199
+ * })
200
+ * ```
201
+ */
202
+ export declare class PropsService extends WorkerEntrypoint<Env> {
203
+ private serviceCore;
204
+ /**
205
+ * Get or create the service core instance
206
+ */
207
+ private getServiceCore;
208
+ /**
209
+ * Get a connected service instance for RPC calls
210
+ *
211
+ * Note: Named 'getService' instead of 'connect' because 'connect'
212
+ * is a reserved method name in Cloudflare Workers RPC (used for sockets).
213
+ *
214
+ * @returns PropsServiceCore instance for RPC calls
215
+ */
216
+ getService(): PropsServiceCore;
217
+ /**
218
+ * Alias for getService() - provides the connect() interface
219
+ * Note: This may conflict with the Fetcher's connect() for sockets
220
+ * when accessed via service bindings. Use getService() instead.
221
+ *
222
+ * @deprecated Use getService() instead
223
+ * @returns PropsServiceCore instance for RPC calls
224
+ */
225
+ connect(): PropsServiceCore;
226
+ /**
227
+ * HTTP request handler for JSON-RPC and service info endpoints
228
+ *
229
+ * Routes:
230
+ * - GET / - Returns service info
231
+ * - POST /rpc - JSON-RPC endpoint for calling service methods
232
+ */
233
+ fetch(request: Request): Promise<Response>;
234
+ }
235
+ /**
236
+ * Default export for Cloudflare Workers
237
+ */
238
+ export default PropsService;
239
+ /**
240
+ * Export aliases
241
+ */
242
+ export { PropsService as PropsWorker };
243
+ export { CascadeExecutor, createCascadeStep, type CascadeConfig, type CascadeResult, type CascadeContext, type TierContext, type TierHandler, type TierResult, type CapabilityTier, type FiveWHEvent, type TierRetryConfig, type SkipCondition, type CascadeMetrics, type CascadeStep, TIER_ORDER, DEFAULT_TIER_TIMEOUTS, CascadeTimeoutError, TierSkippedError, AllTiersFailedError, createCascadeContext, recordStep, } from './cascade.js';
244
+ export { DurableCascadeExecutor, createDurableCascadeStep, createAIGatewayConfig, type DurableCascadeConfig, type DurableCascadeTierContext, type DurableStepConfig, type DurableRetryConfig, type WorkflowStep, type AiBinding, type HumanReviewRequest, type AIGatewayConfig, type CodeTierHandler, type AiTierHandler, type HumanTierHandler, } from './durable-cascade.js';
245
+ /**
246
+ * Event System exports for Queue-based event handling
247
+ *
248
+ * @example
249
+ * ```typescript
250
+ * import { EventBridge, createQueueHandler } from 'ai-props/worker'
251
+ *
252
+ * const bridge = new EventBridge(env.MY_QUEUE)
253
+ * bridge.on('user.created', async (data) => {
254
+ * console.log('User created:', data.id)
255
+ * })
256
+ *
257
+ * export default {
258
+ * async fetch(request, env) {
259
+ * await bridge.emit('user.created', { id: '123' })
260
+ * return new Response('OK')
261
+ * },
262
+ * async queue(batch, env) {
263
+ * const handler = createQueueHandler(bridge)
264
+ * await handler.queue(batch, env)
265
+ * }
266
+ * }
267
+ * ```
268
+ */
269
+ export { EventBridge, createQueueHandler, createEventBridge, type QueuedEvent, type EventBridgeConfig, type EventHandler, type EmitOptions, type Queue, type QueueMessage, type MessageBatch, type TypedEventBridge, } from './event-bridge.js';
270
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,KAAK,EACV,UAAU,EACV,oBAAoB,EACpB,mBAAmB,EACnB,aAAa,EAEb,eAAe,EACf,gBAAgB,EACjB,MAAM,YAAY,CAAA;AA4BnB;;GAEG;AACH,MAAM,WAA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AW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,KAAK,EACV,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,gBAAgB,GACtB,MAAM,mBAAmB,CAAA"}
package/dist/worker.js ADDED
@@ -0,0 +1,405 @@
1
+ /**
2
+ * Worker Export - WorkerEntrypoint for RPC access to AI Props
3
+ *
4
+ * Exposes AI props generation methods via Cloudflare RPC.
5
+ * Provides schema-based prop generation, caching, validation,
6
+ * and cascade execution patterns.
7
+ *
8
+ * ## Features
9
+ *
10
+ * - **RPC Service**: WorkerEntrypoint for service binding access
11
+ * - **Cascade Execution**: Code -> Generative -> Agentic -> Human escalation
12
+ * - **Durable Cascades**: Cloudflare Workflows integration for durability
13
+ * - **AI Gateway**: Configuration helpers for Cloudflare AI Gateway
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // wrangler.jsonc
18
+ * {
19
+ * "services": [
20
+ * { "binding": "AI_PROPS", "service": "ai-props" }
21
+ * ]
22
+ * }
23
+ *
24
+ * // worker.ts - consuming service
25
+ * export default {
26
+ * async fetch(request: Request, env: Env) {
27
+ * const service = env.AI_PROPS.connect()
28
+ * const result = await service.generate({
29
+ * schema: { title: 'Page title', description: 'Page description' },
30
+ * context: { topic: 'AI' }
31
+ * })
32
+ * return Response.json(result.props)
33
+ * }
34
+ * }
35
+ * ```
36
+ *
37
+ * ## Cascade Pattern
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * import {
42
+ * DurableCascadeExecutor,
43
+ * createDurableCascadeStep,
44
+ * createAIGatewayConfig
45
+ * } from 'ai-props/worker'
46
+ *
47
+ * // Create a durable cascade for content generation
48
+ * const contentCascade = createDurableCascadeStep({
49
+ * name: 'generate-content',
50
+ * code: async (input) => {
51
+ * if (input.template) return { content: input.template }
52
+ * throw new Error('No template available')
53
+ * },
54
+ * generative: async (input, ctx) => {
55
+ * const result = await ctx.ai.run('@cf/meta/llama-3-8b-instruct', {
56
+ * messages: [{ role: 'user', content: `Generate content about: ${input.topic}` }]
57
+ * })
58
+ * return { content: result.response }
59
+ * }
60
+ * })
61
+ *
62
+ * // In a Cloudflare Workflow
63
+ * const result = await contentCascade.run(step, { topic: 'AI' })
64
+ * console.log(result.tier) // 'code' or 'generative'
65
+ * ```
66
+ *
67
+ * @packageDocumentation
68
+ */
69
+ import { WorkerEntrypoint, RpcTarget } from 'cloudflare:workers';
70
+ import { generateProps, getPropsSync, prefetchProps, generatePropsMany, mergeWithGenerated, configureAIProps, getConfig, resetConfig, } from './generate.js';
71
+ import { MemoryPropsCache, LRUPropsCache, createCacheKey, getDefaultCache, configureCache, clearCache, } from './cache.js';
72
+ import { validateProps, hasRequiredProps, getMissingFromSchema, isComplete, sanitizeProps, mergeWithDefaults, } from './validate.js';
73
+ /**
74
+ * PropsServiceCore - RpcTarget wrapper for AI props functionality
75
+ *
76
+ * Exposes all required methods as RPC-callable methods.
77
+ * This is the core service class that can be instantiated directly.
78
+ */
79
+ export class PropsServiceCore extends RpcTarget {
80
+ cache;
81
+ constructor() {
82
+ super();
83
+ this.cache = getDefaultCache();
84
+ }
85
+ // ==================== Generation ====================
86
+ /**
87
+ * Generate props using AI
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * const result = await service.generate({
92
+ * schema: {
93
+ * title: 'A compelling page title',
94
+ * description: 'A brief description',
95
+ * },
96
+ * context: { topic: 'AI-powered applications' },
97
+ * })
98
+ * ```
99
+ */
100
+ async generate(options) {
101
+ return generateProps(options);
102
+ }
103
+ /**
104
+ * Generate props synchronously from cache
105
+ *
106
+ * @throws {Error} If props are not in cache
107
+ */
108
+ getSync(schema, context) {
109
+ return getPropsSync(schema, context);
110
+ }
111
+ /**
112
+ * Pre-generate props for warming the cache
113
+ */
114
+ async prefetch(requests) {
115
+ return prefetchProps(requests);
116
+ }
117
+ /**
118
+ * Generate multiple prop sets in parallel
119
+ */
120
+ async generateMany(requests) {
121
+ return generatePropsMany(requests);
122
+ }
123
+ /**
124
+ * Merge partial props with generated props
125
+ *
126
+ * Generates only the missing props, keeping provided ones.
127
+ */
128
+ async mergeWithGenerated(schema, partialProps, options) {
129
+ return mergeWithGenerated(schema, partialProps, options);
130
+ }
131
+ // ==================== Configuration ====================
132
+ /**
133
+ * Configure global AI props settings
134
+ */
135
+ configure(config) {
136
+ configureAIProps(config);
137
+ }
138
+ /**
139
+ * Get current configuration
140
+ */
141
+ getConfig() {
142
+ return getConfig();
143
+ }
144
+ /**
145
+ * Reset configuration to defaults
146
+ */
147
+ resetConfig() {
148
+ resetConfig();
149
+ }
150
+ // ==================== Cache Operations ====================
151
+ /**
152
+ * Get cached props by key
153
+ */
154
+ getCached(key) {
155
+ return this.cache.get(key);
156
+ }
157
+ /**
158
+ * Set props in cache
159
+ */
160
+ setCached(key, props) {
161
+ this.cache.set(key, props);
162
+ }
163
+ /**
164
+ * Delete cached entry by key
165
+ */
166
+ deleteCached(key) {
167
+ return this.cache.delete(key);
168
+ }
169
+ /**
170
+ * Clear all cached props
171
+ */
172
+ clearCache() {
173
+ clearCache();
174
+ }
175
+ /**
176
+ * Get cache size
177
+ */
178
+ getCacheSize() {
179
+ return this.cache.size;
180
+ }
181
+ /**
182
+ * Create a cache key from schema and context
183
+ */
184
+ createCacheKey(schema, context) {
185
+ return createCacheKey(schema, context);
186
+ }
187
+ /**
188
+ * Configure cache TTL
189
+ */
190
+ configureCache(ttl) {
191
+ configureCache(ttl);
192
+ this.cache = getDefaultCache();
193
+ }
194
+ // ==================== Validation ====================
195
+ /**
196
+ * Validate props against a schema
197
+ */
198
+ validate(props, schema) {
199
+ return validateProps(props, schema);
200
+ }
201
+ /**
202
+ * Check if all required props are present
203
+ */
204
+ hasRequired(props, required) {
205
+ return hasRequiredProps(props, required);
206
+ }
207
+ /**
208
+ * Get list of missing props according to schema
209
+ */
210
+ getMissing(props, schema) {
211
+ return getMissingFromSchema(props, schema);
212
+ }
213
+ /**
214
+ * Check if props are complete according to schema
215
+ */
216
+ isComplete(props, schema) {
217
+ return isComplete(props, schema);
218
+ }
219
+ /**
220
+ * Sanitize props by removing unknown keys
221
+ */
222
+ sanitize(props, schema) {
223
+ return sanitizeProps(props, schema);
224
+ }
225
+ /**
226
+ * Merge props with default values
227
+ */
228
+ mergeDefaults(props, defaults, schema) {
229
+ return mergeWithDefaults(props, defaults, schema);
230
+ }
231
+ }
232
+ /**
233
+ * PropsService - WorkerEntrypoint for RPC access
234
+ *
235
+ * Provides `connect()` method that returns an RpcTarget service
236
+ * with all AI props methods. Also handles HTTP endpoints for
237
+ * direct JSON-RPC access.
238
+ *
239
+ * @example
240
+ * ```typescript
241
+ * // In consuming worker
242
+ * const service = env.AI_PROPS.connect()
243
+ * const result = await service.generate({
244
+ * schema: { title: 'Page title' }
245
+ * })
246
+ * ```
247
+ */
248
+ export class PropsService extends WorkerEntrypoint {
249
+ serviceCore = null;
250
+ /**
251
+ * Get or create the service core instance
252
+ */
253
+ getServiceCore() {
254
+ if (!this.serviceCore) {
255
+ this.serviceCore = new PropsServiceCore();
256
+ }
257
+ return this.serviceCore;
258
+ }
259
+ /**
260
+ * Get a connected service instance for RPC calls
261
+ *
262
+ * Note: Named 'getService' instead of 'connect' because 'connect'
263
+ * is a reserved method name in Cloudflare Workers RPC (used for sockets).
264
+ *
265
+ * @returns PropsServiceCore instance for RPC calls
266
+ */
267
+ getService() {
268
+ return this.getServiceCore();
269
+ }
270
+ /**
271
+ * Alias for getService() - provides the connect() interface
272
+ * Note: This may conflict with the Fetcher's connect() for sockets
273
+ * when accessed via service bindings. Use getService() instead.
274
+ *
275
+ * @deprecated Use getService() instead
276
+ * @returns PropsServiceCore instance for RPC calls
277
+ */
278
+ connect() {
279
+ return this.getServiceCore();
280
+ }
281
+ /**
282
+ * HTTP request handler for JSON-RPC and service info endpoints
283
+ *
284
+ * Routes:
285
+ * - GET / - Returns service info
286
+ * - POST /rpc - JSON-RPC endpoint for calling service methods
287
+ */
288
+ async fetch(request) {
289
+ const url = new URL(request.url);
290
+ // GET / - Service info
291
+ if (request.method === 'GET' && url.pathname === '/') {
292
+ const service = this.getServiceCore();
293
+ return Response.json({
294
+ name: 'ai-props',
295
+ version: '1.0.0',
296
+ methods: [
297
+ 'generate',
298
+ 'getSync',
299
+ 'prefetch',
300
+ 'generateMany',
301
+ 'mergeWithGenerated',
302
+ 'configure',
303
+ 'getConfig',
304
+ 'resetConfig',
305
+ 'getCached',
306
+ 'setCached',
307
+ 'deleteCached',
308
+ 'clearCache',
309
+ 'getCacheSize',
310
+ 'createCacheKey',
311
+ 'configureCache',
312
+ 'validate',
313
+ 'hasRequired',
314
+ 'getMissing',
315
+ 'isComplete',
316
+ 'sanitize',
317
+ 'mergeDefaults',
318
+ ],
319
+ rpc: '/rpc',
320
+ });
321
+ }
322
+ // POST /rpc - JSON-RPC endpoint
323
+ if (url.pathname === '/rpc' && request.method === 'POST') {
324
+ try {
325
+ const body = (await request.json());
326
+ const { method, args = [] } = body;
327
+ if (!method || typeof method !== 'string') {
328
+ return Response.json({ error: 'Missing or invalid method' }, { status: 400 });
329
+ }
330
+ const service = this.getServiceCore();
331
+ // Check if method exists on service
332
+ const methodFn = service[method];
333
+ if (typeof methodFn !== 'function') {
334
+ return Response.json({ error: `Method "${method}" not found` }, { status: 404 });
335
+ }
336
+ // Call the method
337
+ const result = await methodFn.apply(service, args);
338
+ return Response.json({ result });
339
+ }
340
+ catch (error) {
341
+ const message = error instanceof Error ? error.message : 'Unknown error';
342
+ return Response.json({ error: message }, { status: 500 });
343
+ }
344
+ }
345
+ // 404 for other routes
346
+ return Response.json({ error: 'Not found' }, { status: 404 });
347
+ }
348
+ }
349
+ /**
350
+ * Default export for Cloudflare Workers
351
+ */
352
+ export default PropsService;
353
+ /**
354
+ * Export aliases
355
+ */
356
+ export { PropsService as PropsWorker };
357
+ // =============================================================================
358
+ // Cascade Execution - Code -> Generative -> Agentic -> Human pattern
359
+ // =============================================================================
360
+ export {
361
+ // Base cascade (non-durable)
362
+ CascadeExecutor, createCascadeStep,
363
+ // Constants
364
+ TIER_ORDER, DEFAULT_TIER_TIMEOUTS,
365
+ // Errors
366
+ CascadeTimeoutError, TierSkippedError, AllTiersFailedError,
367
+ // Helpers
368
+ createCascadeContext, recordStep, } from './cascade.js';
369
+ // =============================================================================
370
+ // Durable Cascade - Cloudflare Workflows integration
371
+ // =============================================================================
372
+ export {
373
+ // Durable cascade executor
374
+ DurableCascadeExecutor, createDurableCascadeStep,
375
+ // AI Gateway configuration
376
+ createAIGatewayConfig, } from './durable-cascade.js';
377
+ // =============================================================================
378
+ // Event System - Queue-based event handling
379
+ // =============================================================================
380
+ /**
381
+ * Event System exports for Queue-based event handling
382
+ *
383
+ * @example
384
+ * ```typescript
385
+ * import { EventBridge, createQueueHandler } from 'ai-props/worker'
386
+ *
387
+ * const bridge = new EventBridge(env.MY_QUEUE)
388
+ * bridge.on('user.created', async (data) => {
389
+ * console.log('User created:', data.id)
390
+ * })
391
+ *
392
+ * export default {
393
+ * async fetch(request, env) {
394
+ * await bridge.emit('user.created', { id: '123' })
395
+ * return new Response('OK')
396
+ * },
397
+ * async queue(batch, env) {
398
+ * const handler = createQueueHandler(bridge)
399
+ * await handler.queue(batch, env)
400
+ * }
401
+ * }
402
+ * ```
403
+ */
404
+ export { EventBridge, createQueueHandler, createEventBridge, } from './event-bridge.js';
405
+ //# sourceMappingURL=worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAUhE,OAAO,EACL,aAAa,EACb,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,WAAW,GAC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