@puckeditor/plugin-ai 0.8.0-canary.fed2989a → 0.8.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.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as react from 'react';
2
+ import { ReactNode } from 'react';
2
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
4
  import { PuckAction, Data, Config } from '@puckeditor/core';
4
- import { LanguageModelUsage, UIMessage, CreateUIMessage, DataUIPart, ChatStatus } from 'ai';
5
+ import { LanguageModelUsage, UIMessage, CreateUIMessage, DataUIPart, ChatStatus, ChatOnFinishCallback } from 'ai';
5
6
 
6
7
  type _JSONSchema = boolean | JSONSchema;
7
8
  type JSONSchema = {
@@ -122,14 +123,23 @@ type AddOperation = {
122
123
  type: string;
123
124
  props: object;
124
125
  };
126
+ /**
127
+ * Streamed string tails keyed by prop path (e.g. `html`, `cta.label`,
128
+ * `items[2].title`). Each tail is appended to the value currently at that
129
+ * path. A top-level prop is carried either in `props` (full replacement) or
130
+ * in `appends` — never both — so applying them can't double-append.
131
+ */
132
+ type StringAppends = Record<string, string>;
125
133
  type UpdateOperation = {
126
134
  op: "update";
127
135
  id: string;
128
136
  props: object;
137
+ appends?: StringAppends;
129
138
  };
130
139
  type UpdateRootOperation = {
131
140
  op: "updateRoot";
132
141
  props: object;
142
+ appends?: StringAppends;
133
143
  };
134
144
  type MoveOperation = {
135
145
  op: "move";
@@ -155,6 +165,7 @@ type TokenUsage = {
155
165
  totalTokens: number | undefined;
156
166
  reasoningTokens?: number | undefined;
157
167
  cachedInputTokens?: number | undefined;
168
+ cacheWriteTokens?: number | undefined;
158
169
  };
159
170
  type DataFinish = {
160
171
  totalCost: number;
@@ -222,6 +233,13 @@ type PuckDataParts = {
222
233
  "subagent-event": SubagentEvent;
223
234
  finish: DataFinish;
224
235
  page: Data;
236
+ "version-notice": {
237
+ package: string;
238
+ message: string;
239
+ currentVersion: string;
240
+ latestVersion: string;
241
+ blogUrl: string;
242
+ };
225
243
  };
226
244
  type PuckProviderMetadata = {
227
245
  tokenUsage?: LanguageModelUsage;
@@ -229,6 +247,7 @@ type PuckProviderMetadata = {
229
247
 
230
248
  type PuckMessage = UIMessage<PuckProviderMetadata, PuckDataParts>;
231
249
 
250
+ type Mode = "assembly" | "design";
232
251
  type RequestOptions = {
233
252
  body?: {
234
253
  chatId?: string;
@@ -236,6 +255,7 @@ type RequestOptions = {
236
255
  messages?: PuckMessage[];
237
256
  pageData?: Data;
238
257
  config?: Config;
258
+ mode?: Mode;
239
259
  [key: string]: any;
240
260
  };
241
261
  headers?: HeadersInit;
@@ -255,14 +275,23 @@ type AiPluginProps = {
255
275
  type: "file";
256
276
  }>[];
257
277
  }) => void | Promise<void>;
278
+ onFinish?: ChatOnFinishCallback<PuckMessage>;
258
279
  examplePrompts?: {
259
280
  label: string;
260
281
  href?: string;
261
282
  onClick?: () => void;
262
283
  }[];
284
+ placeholder?: ReactNode;
285
+ actions?: ReactNode | ((state: {
286
+ disabled: boolean;
287
+ }) => ReactNode);
263
288
  };
264
289
  scrollTracking?: boolean;
265
290
  prepareRequest?: (opts: RequestOptions) => RequestOptions | Promise<RequestOptions>;
291
+ designMode?: boolean | {
292
+ visible?: boolean;
293
+ };
294
+ defaultMode?: "assembly" | "design";
266
295
  };
267
296
  declare global {
268
297
  interface Window {
@@ -271,10 +300,12 @@ declare global {
271
300
  setMessages: (_messages: PuckMessage[]) => void;
272
301
  processData: (_messages: DataUIPart<PuckDataParts>) => void;
273
302
  setStatus: (_status: ChatStatus) => void;
303
+ focus: () => void;
274
304
  };
275
305
  }
276
306
  }
277
307
 
308
+ declare function withDynamicConfig(config: Config, data: Data): Config;
278
309
  declare function createAiPlugin(opts?: AiPluginProps): {
279
310
  label: string;
280
311
  name: string;
@@ -282,10 +313,13 @@ declare function createAiPlugin(opts?: AiPluginProps): {
282
313
  icon: react_jsx_runtime.JSX.Element;
283
314
  mobilePanelHeight: "min-content";
284
315
  overrides: {
316
+ drawer: ({ children }: {
317
+ children: react.ReactNode;
318
+ }) => react_jsx_runtime.JSX.Element;
285
319
  preview: ({ children }: {
286
320
  children: react.ReactNode;
287
321
  }) => react_jsx_runtime.JSX.Element;
288
322
  };
289
323
  };
290
324
 
291
- export { type ComponentAiParams, type FieldAiParams, createAiPlugin };
325
+ export { type ComponentAiParams, type FieldAiParams, createAiPlugin, withDynamicConfig };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as react from 'react';
2
+ import { ReactNode } from 'react';
2
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
4
  import { PuckAction, Data, Config } from '@puckeditor/core';
4
- import { LanguageModelUsage, UIMessage, CreateUIMessage, DataUIPart, ChatStatus } from 'ai';
5
+ import { LanguageModelUsage, UIMessage, CreateUIMessage, DataUIPart, ChatStatus, ChatOnFinishCallback } from 'ai';
5
6
 
6
7
  type _JSONSchema = boolean | JSONSchema;
7
8
  type JSONSchema = {
@@ -122,14 +123,23 @@ type AddOperation = {
122
123
  type: string;
123
124
  props: object;
124
125
  };
126
+ /**
127
+ * Streamed string tails keyed by prop path (e.g. `html`, `cta.label`,
128
+ * `items[2].title`). Each tail is appended to the value currently at that
129
+ * path. A top-level prop is carried either in `props` (full replacement) or
130
+ * in `appends` — never both — so applying them can't double-append.
131
+ */
132
+ type StringAppends = Record<string, string>;
125
133
  type UpdateOperation = {
126
134
  op: "update";
127
135
  id: string;
128
136
  props: object;
137
+ appends?: StringAppends;
129
138
  };
130
139
  type UpdateRootOperation = {
131
140
  op: "updateRoot";
132
141
  props: object;
142
+ appends?: StringAppends;
133
143
  };
134
144
  type MoveOperation = {
135
145
  op: "move";
@@ -155,6 +165,7 @@ type TokenUsage = {
155
165
  totalTokens: number | undefined;
156
166
  reasoningTokens?: number | undefined;
157
167
  cachedInputTokens?: number | undefined;
168
+ cacheWriteTokens?: number | undefined;
158
169
  };
159
170
  type DataFinish = {
160
171
  totalCost: number;
@@ -222,6 +233,13 @@ type PuckDataParts = {
222
233
  "subagent-event": SubagentEvent;
223
234
  finish: DataFinish;
224
235
  page: Data;
236
+ "version-notice": {
237
+ package: string;
238
+ message: string;
239
+ currentVersion: string;
240
+ latestVersion: string;
241
+ blogUrl: string;
242
+ };
225
243
  };
226
244
  type PuckProviderMetadata = {
227
245
  tokenUsage?: LanguageModelUsage;
@@ -229,6 +247,7 @@ type PuckProviderMetadata = {
229
247
 
230
248
  type PuckMessage = UIMessage<PuckProviderMetadata, PuckDataParts>;
231
249
 
250
+ type Mode = "assembly" | "design";
232
251
  type RequestOptions = {
233
252
  body?: {
234
253
  chatId?: string;
@@ -236,6 +255,7 @@ type RequestOptions = {
236
255
  messages?: PuckMessage[];
237
256
  pageData?: Data;
238
257
  config?: Config;
258
+ mode?: Mode;
239
259
  [key: string]: any;
240
260
  };
241
261
  headers?: HeadersInit;
@@ -255,14 +275,23 @@ type AiPluginProps = {
255
275
  type: "file";
256
276
  }>[];
257
277
  }) => void | Promise<void>;
278
+ onFinish?: ChatOnFinishCallback<PuckMessage>;
258
279
  examplePrompts?: {
259
280
  label: string;
260
281
  href?: string;
261
282
  onClick?: () => void;
262
283
  }[];
284
+ placeholder?: ReactNode;
285
+ actions?: ReactNode | ((state: {
286
+ disabled: boolean;
287
+ }) => ReactNode);
263
288
  };
264
289
  scrollTracking?: boolean;
265
290
  prepareRequest?: (opts: RequestOptions) => RequestOptions | Promise<RequestOptions>;
291
+ designMode?: boolean | {
292
+ visible?: boolean;
293
+ };
294
+ defaultMode?: "assembly" | "design";
266
295
  };
267
296
  declare global {
268
297
  interface Window {
@@ -271,10 +300,12 @@ declare global {
271
300
  setMessages: (_messages: PuckMessage[]) => void;
272
301
  processData: (_messages: DataUIPart<PuckDataParts>) => void;
273
302
  setStatus: (_status: ChatStatus) => void;
303
+ focus: () => void;
274
304
  };
275
305
  }
276
306
  }
277
307
 
308
+ declare function withDynamicConfig(config: Config, data: Data): Config;
278
309
  declare function createAiPlugin(opts?: AiPluginProps): {
279
310
  label: string;
280
311
  name: string;
@@ -282,10 +313,13 @@ declare function createAiPlugin(opts?: AiPluginProps): {
282
313
  icon: react_jsx_runtime.JSX.Element;
283
314
  mobilePanelHeight: "min-content";
284
315
  overrides: {
316
+ drawer: ({ children }: {
317
+ children: react.ReactNode;
318
+ }) => react_jsx_runtime.JSX.Element;
285
319
  preview: ({ children }: {
286
320
  children: react.ReactNode;
287
321
  }) => react_jsx_runtime.JSX.Element;
288
322
  };
289
323
  };
290
324
 
291
- export { type ComponentAiParams, type FieldAiParams, createAiPlugin };
325
+ export { type ComponentAiParams, type FieldAiParams, createAiPlugin, withDynamicConfig };