@puckeditor/plugin-ai 0.9.0-canary.ce36db61 → 0.9.0-canary.d4a0bc62
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/dist/index.d.mts +53 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +510 -139
- package/dist/index.mjs +493 -122
- package/package.json +8 -8
package/dist/index.d.mts
CHANGED
|
@@ -115,6 +115,37 @@ type DataToolStatus = {
|
|
|
115
115
|
status: ToolStatus;
|
|
116
116
|
toolCallId: string;
|
|
117
117
|
};
|
|
118
|
+
type AiFieldTypeShape<Value> = {
|
|
119
|
+
/** What the field represents, and any rules for using it */
|
|
120
|
+
description?: string;
|
|
121
|
+
/**
|
|
122
|
+
* JSON Schema for the field's value — the shape the model may write, at
|
|
123
|
+
* creation and in later edits. Without one the model never writes the
|
|
124
|
+
* field, like `ai.exclude`.
|
|
125
|
+
*/
|
|
126
|
+
schema?: Record<string, any>;
|
|
127
|
+
/**
|
|
128
|
+
* What a field the model designs starts as. When set, the model places the
|
|
129
|
+
* field and this value fills it; the model authors a value against `schema`
|
|
130
|
+
* only when this is absent.
|
|
131
|
+
*/
|
|
132
|
+
defaultValue?: Value;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* A user field type registered by the developer's config. Puck can't infer a
|
|
136
|
+
* value shape for one, so a type carries `schema`, `defaultValue`, or both.
|
|
137
|
+
*/
|
|
138
|
+
type AiFieldType$1<Value = AiFieldTypeValue> = AiFieldTypeShape<Value> & ({
|
|
139
|
+
schema: Record<string, any>;
|
|
140
|
+
} | {
|
|
141
|
+
defaultValue: Value;
|
|
142
|
+
});
|
|
143
|
+
/**
|
|
144
|
+
* Any JSON-ish value. Spelled out rather than `unknown` so a union with a
|
|
145
|
+
* function form doesn't collapse, which would drop the callback's parameter
|
|
146
|
+
* types at the call site.
|
|
147
|
+
*/
|
|
148
|
+
type AiFieldTypeValue = string | number | boolean | null | readonly unknown[] | Record<string, unknown>;
|
|
118
149
|
type AddOperation = {
|
|
119
150
|
op: "add";
|
|
120
151
|
id: string;
|
|
@@ -247,6 +278,21 @@ type PuckProviderMetadata = {
|
|
|
247
278
|
|
|
248
279
|
type PuckMessage = UIMessage<PuckProviderMetadata, PuckDataParts>;
|
|
249
280
|
|
|
281
|
+
type AiFieldTypeContext = {
|
|
282
|
+
/** The designed component the field belongs to */
|
|
283
|
+
componentName: string;
|
|
284
|
+
/** The field's name within that component */
|
|
285
|
+
fieldName: string;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* A field type the developer's config registers: `schema` is what the model
|
|
289
|
+
* may write, `defaultValue` is what a designed field starts as — one or both.
|
|
290
|
+
* In the editor the default may be a function of the component and field
|
|
291
|
+
* being created.
|
|
292
|
+
*/
|
|
293
|
+
type AiFieldType = AiFieldType$1<AiFieldTypeValue | ((ctx: AiFieldTypeContext) => AiFieldTypeValue)>;
|
|
294
|
+
type AiFieldTypeRegistry = Record<string, AiFieldType>;
|
|
295
|
+
|
|
250
296
|
type Mode = "assembly" | "design";
|
|
251
297
|
type RequestOptions = {
|
|
252
298
|
body?: {
|
|
@@ -263,6 +309,13 @@ type RequestOptions = {
|
|
|
263
309
|
};
|
|
264
310
|
type AiPluginProps = {
|
|
265
311
|
host?: string;
|
|
312
|
+
/**
|
|
313
|
+
* Field types this config registers, keyed by field type. Each gives either
|
|
314
|
+
* a `schema` the AI writes the value against, or a `defaultValue` every
|
|
315
|
+
* field of the type starts with. Sent to the server as JSON, so a function
|
|
316
|
+
* `defaultValue` only resolves in the editor.
|
|
317
|
+
*/
|
|
318
|
+
fieldTypes?: AiFieldTypeRegistry;
|
|
266
319
|
chat?: {
|
|
267
320
|
attachments?: {
|
|
268
321
|
enabled?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -115,6 +115,37 @@ type DataToolStatus = {
|
|
|
115
115
|
status: ToolStatus;
|
|
116
116
|
toolCallId: string;
|
|
117
117
|
};
|
|
118
|
+
type AiFieldTypeShape<Value> = {
|
|
119
|
+
/** What the field represents, and any rules for using it */
|
|
120
|
+
description?: string;
|
|
121
|
+
/**
|
|
122
|
+
* JSON Schema for the field's value — the shape the model may write, at
|
|
123
|
+
* creation and in later edits. Without one the model never writes the
|
|
124
|
+
* field, like `ai.exclude`.
|
|
125
|
+
*/
|
|
126
|
+
schema?: Record<string, any>;
|
|
127
|
+
/**
|
|
128
|
+
* What a field the model designs starts as. When set, the model places the
|
|
129
|
+
* field and this value fills it; the model authors a value against `schema`
|
|
130
|
+
* only when this is absent.
|
|
131
|
+
*/
|
|
132
|
+
defaultValue?: Value;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* A user field type registered by the developer's config. Puck can't infer a
|
|
136
|
+
* value shape for one, so a type carries `schema`, `defaultValue`, or both.
|
|
137
|
+
*/
|
|
138
|
+
type AiFieldType$1<Value = AiFieldTypeValue> = AiFieldTypeShape<Value> & ({
|
|
139
|
+
schema: Record<string, any>;
|
|
140
|
+
} | {
|
|
141
|
+
defaultValue: Value;
|
|
142
|
+
});
|
|
143
|
+
/**
|
|
144
|
+
* Any JSON-ish value. Spelled out rather than `unknown` so a union with a
|
|
145
|
+
* function form doesn't collapse, which would drop the callback's parameter
|
|
146
|
+
* types at the call site.
|
|
147
|
+
*/
|
|
148
|
+
type AiFieldTypeValue = string | number | boolean | null | readonly unknown[] | Record<string, unknown>;
|
|
118
149
|
type AddOperation = {
|
|
119
150
|
op: "add";
|
|
120
151
|
id: string;
|
|
@@ -247,6 +278,21 @@ type PuckProviderMetadata = {
|
|
|
247
278
|
|
|
248
279
|
type PuckMessage = UIMessage<PuckProviderMetadata, PuckDataParts>;
|
|
249
280
|
|
|
281
|
+
type AiFieldTypeContext = {
|
|
282
|
+
/** The designed component the field belongs to */
|
|
283
|
+
componentName: string;
|
|
284
|
+
/** The field's name within that component */
|
|
285
|
+
fieldName: string;
|
|
286
|
+
};
|
|
287
|
+
/**
|
|
288
|
+
* A field type the developer's config registers: `schema` is what the model
|
|
289
|
+
* may write, `defaultValue` is what a designed field starts as — one or both.
|
|
290
|
+
* In the editor the default may be a function of the component and field
|
|
291
|
+
* being created.
|
|
292
|
+
*/
|
|
293
|
+
type AiFieldType = AiFieldType$1<AiFieldTypeValue | ((ctx: AiFieldTypeContext) => AiFieldTypeValue)>;
|
|
294
|
+
type AiFieldTypeRegistry = Record<string, AiFieldType>;
|
|
295
|
+
|
|
250
296
|
type Mode = "assembly" | "design";
|
|
251
297
|
type RequestOptions = {
|
|
252
298
|
body?: {
|
|
@@ -263,6 +309,13 @@ type RequestOptions = {
|
|
|
263
309
|
};
|
|
264
310
|
type AiPluginProps = {
|
|
265
311
|
host?: string;
|
|
312
|
+
/**
|
|
313
|
+
* Field types this config registers, keyed by field type. Each gives either
|
|
314
|
+
* a `schema` the AI writes the value against, or a `defaultValue` every
|
|
315
|
+
* field of the type starts with. Sent to the server as JSON, so a function
|
|
316
|
+
* `defaultValue` only resolves in the editor.
|
|
317
|
+
*/
|
|
318
|
+
fieldTypes?: AiFieldTypeRegistry;
|
|
266
319
|
chat?: {
|
|
267
320
|
attachments?: {
|
|
268
321
|
enabled?: boolean;
|