@puckeditor/cloud-client 0.8.0-canary.63de6e49 → 0.8.0-canary.844eb87d
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/{chunk-XI3V7SYA.mjs → chunk-NYUJ34K5.mjs} +29 -4
- package/dist/experimental.d.mts +1 -1
- package/dist/experimental.d.ts +1 -1
- package/dist/experimental.js +28 -4
- package/dist/experimental.mjs +3 -2
- package/dist/index.d.mts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +28 -4
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -22195,14 +22195,17 @@ var cloudApi = async (path, body, options = {}, onChunk) => {
|
|
|
22195
22195
|
"No Puck API key specified. Set the PUCK_API_KEY environment variable, or provide one to the function"
|
|
22196
22196
|
);
|
|
22197
22197
|
}
|
|
22198
|
-
const { context, tools = {} } = ai;
|
|
22198
|
+
const { context, tools = {}, designMode } = ai;
|
|
22199
22199
|
const res = await fetch(`${host}/${path}`, {
|
|
22200
22200
|
headers: { "x-api-key": apiKey, "puck-api-version": apiVersion },
|
|
22201
22201
|
method: "post",
|
|
22202
22202
|
body: JSON.stringify({
|
|
22203
22203
|
...body,
|
|
22204
22204
|
context,
|
|
22205
|
-
tools: prepareUserTools(tools)
|
|
22205
|
+
tools: prepareUserTools(tools),
|
|
22206
|
+
...designMode ? {
|
|
22207
|
+
designMode
|
|
22208
|
+
} : {}
|
|
22206
22209
|
})
|
|
22207
22210
|
});
|
|
22208
22211
|
if (!res.body) {
|
|
@@ -22224,12 +22227,33 @@ var cloudApi = async (path, body, options = {}, onChunk) => {
|
|
|
22224
22227
|
};
|
|
22225
22228
|
|
|
22226
22229
|
// src/api/chat.ts
|
|
22230
|
+
function chatPrivate({ chatId, messages, config: config2, pageData, mode }, options = {}) {
|
|
22231
|
+
const resolvedMode = mode ?? options?.ai?.mode;
|
|
22232
|
+
const stream = createUIMessageStream({
|
|
22233
|
+
execute: async ({ writer }) => {
|
|
22234
|
+
await cloudApi(
|
|
22235
|
+
"chat",
|
|
22236
|
+
{ chatId, config: config2, messages, pageData, mode: resolvedMode },
|
|
22237
|
+
options,
|
|
22238
|
+
(chunk) => {
|
|
22239
|
+
if (chunk.type === "data-finish") {
|
|
22240
|
+
options.ai?.onFinish?.(chunk.data);
|
|
22241
|
+
} else {
|
|
22242
|
+
writer.write(chunk);
|
|
22243
|
+
}
|
|
22244
|
+
}
|
|
22245
|
+
);
|
|
22246
|
+
}
|
|
22247
|
+
});
|
|
22248
|
+
return createUIMessageStreamResponse({ stream });
|
|
22249
|
+
}
|
|
22227
22250
|
function chat({ chatId, messages, config: config2, pageData }, options = {}) {
|
|
22251
|
+
const resolvedMode = options?.ai?.mode;
|
|
22228
22252
|
const stream = createUIMessageStream({
|
|
22229
22253
|
execute: async ({ writer }) => {
|
|
22230
22254
|
await cloudApi(
|
|
22231
22255
|
"chat",
|
|
22232
|
-
{ chatId, config: config2, messages, pageData },
|
|
22256
|
+
{ chatId, config: config2, messages, pageData, mode: resolvedMode },
|
|
22233
22257
|
options,
|
|
22234
22258
|
(chunk) => {
|
|
22235
22259
|
if (chunk.type === "data-finish") {
|
|
@@ -22435,7 +22459,7 @@ var routeRegistry = [
|
|
|
22435
22459
|
{
|
|
22436
22460
|
pattern: "/api/puck/chat",
|
|
22437
22461
|
methods: {
|
|
22438
|
-
POST: ({ body }, options) =>
|
|
22462
|
+
POST: ({ body }, options) => chatPrivate(body, options)
|
|
22439
22463
|
}
|
|
22440
22464
|
}
|
|
22441
22465
|
];
|
|
@@ -22502,6 +22526,7 @@ var endpoints = ["chat"];
|
|
|
22502
22526
|
|
|
22503
22527
|
export {
|
|
22504
22528
|
getApiKey,
|
|
22529
|
+
chatPrivate,
|
|
22505
22530
|
chat,
|
|
22506
22531
|
createAttachments,
|
|
22507
22532
|
getAttachment,
|
package/dist/experimental.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PuckCloudOptions as PuckCloudOptions$1 } from './index.mjs';
|
|
2
|
-
export { ChatParams, Endpoint, GenerateParams, OnFinishCallback, OnFinishResult, UserTool, UserToolRegistry, chat, endpoints, generate, tool } from './index.mjs';
|
|
2
|
+
export { ChatParams, DesignModeOptions, Endpoint, GenerateParams, OnFinishCallback, OnFinishResult, UserTool, UserToolRegistry, chat, endpoints, generate, tool } from './index.mjs';
|
|
3
3
|
import { Data } from '@puckeditor/core';
|
|
4
4
|
import 'zod/v4';
|
|
5
5
|
import 'ai';
|
package/dist/experimental.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PuckCloudOptions as PuckCloudOptions$1 } from './index.js';
|
|
2
|
-
export { ChatParams, Endpoint, GenerateParams, OnFinishCallback, OnFinishResult, UserTool, UserToolRegistry, chat, endpoints, generate, tool } from './index.js';
|
|
2
|
+
export { ChatParams, DesignModeOptions, Endpoint, GenerateParams, OnFinishCallback, OnFinishResult, UserTool, UserToolRegistry, chat, endpoints, generate, tool } from './index.js';
|
|
3
3
|
import { Data } from '@puckeditor/core';
|
|
4
4
|
import 'zod/v4';
|
|
5
5
|
import 'ai';
|
package/dist/experimental.js
CHANGED
|
@@ -22238,14 +22238,17 @@ var cloudApi = async (path, body, options = {}, onChunk) => {
|
|
|
22238
22238
|
"No Puck API key specified. Set the PUCK_API_KEY environment variable, or provide one to the function"
|
|
22239
22239
|
);
|
|
22240
22240
|
}
|
|
22241
|
-
const { context, tools = {} } = ai;
|
|
22241
|
+
const { context, tools = {}, designMode } = ai;
|
|
22242
22242
|
const res = await fetch(`${host}/${path}`, {
|
|
22243
22243
|
headers: { "x-api-key": apiKey, "puck-api-version": apiVersion },
|
|
22244
22244
|
method: "post",
|
|
22245
22245
|
body: JSON.stringify({
|
|
22246
22246
|
...body,
|
|
22247
22247
|
context,
|
|
22248
|
-
tools: prepareUserTools(tools)
|
|
22248
|
+
tools: prepareUserTools(tools),
|
|
22249
|
+
...designMode ? {
|
|
22250
|
+
designMode
|
|
22251
|
+
} : {}
|
|
22249
22252
|
})
|
|
22250
22253
|
});
|
|
22251
22254
|
if (!res.body) {
|
|
@@ -22267,12 +22270,33 @@ var cloudApi = async (path, body, options = {}, onChunk) => {
|
|
|
22267
22270
|
};
|
|
22268
22271
|
|
|
22269
22272
|
// src/api/chat.ts
|
|
22273
|
+
function chatPrivate({ chatId, messages, config: config2, pageData, mode }, options = {}) {
|
|
22274
|
+
const resolvedMode = mode ?? options?.ai?.mode;
|
|
22275
|
+
const stream = createUIMessageStream({
|
|
22276
|
+
execute: async ({ writer }) => {
|
|
22277
|
+
await cloudApi(
|
|
22278
|
+
"chat",
|
|
22279
|
+
{ chatId, config: config2, messages, pageData, mode: resolvedMode },
|
|
22280
|
+
options,
|
|
22281
|
+
(chunk) => {
|
|
22282
|
+
if (chunk.type === "data-finish") {
|
|
22283
|
+
options.ai?.onFinish?.(chunk.data);
|
|
22284
|
+
} else {
|
|
22285
|
+
writer.write(chunk);
|
|
22286
|
+
}
|
|
22287
|
+
}
|
|
22288
|
+
);
|
|
22289
|
+
}
|
|
22290
|
+
});
|
|
22291
|
+
return createUIMessageStreamResponse({ stream });
|
|
22292
|
+
}
|
|
22270
22293
|
function chat({ chatId, messages, config: config2, pageData }, options = {}) {
|
|
22294
|
+
const resolvedMode = options?.ai?.mode;
|
|
22271
22295
|
const stream = createUIMessageStream({
|
|
22272
22296
|
execute: async ({ writer }) => {
|
|
22273
22297
|
await cloudApi(
|
|
22274
22298
|
"chat",
|
|
22275
|
-
{ chatId, config: config2, messages, pageData },
|
|
22299
|
+
{ chatId, config: config2, messages, pageData, mode: resolvedMode },
|
|
22276
22300
|
options,
|
|
22277
22301
|
(chunk) => {
|
|
22278
22302
|
if (chunk.type === "data-finish") {
|
|
@@ -22826,7 +22850,7 @@ var routeRegistry = [
|
|
|
22826
22850
|
{
|
|
22827
22851
|
pattern: "/api/puck/chat",
|
|
22828
22852
|
methods: {
|
|
22829
|
-
POST: ({ body }, options) =>
|
|
22853
|
+
POST: ({ body }, options) => chatPrivate(body, options)
|
|
22830
22854
|
}
|
|
22831
22855
|
},
|
|
22832
22856
|
{
|
package/dist/experimental.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
chat,
|
|
3
|
+
chatPrivate,
|
|
3
4
|
clientTool,
|
|
4
5
|
createAttachments,
|
|
5
6
|
deleteAttachment,
|
|
@@ -10,7 +11,7 @@ import {
|
|
|
10
11
|
getAttachment,
|
|
11
12
|
handlePuckRequest,
|
|
12
13
|
tool
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-NYUJ34K5.mjs";
|
|
14
15
|
import {
|
|
15
16
|
init_react_import
|
|
16
17
|
} from "./chunk-O6DC5HI2.mjs";
|
|
@@ -327,7 +328,7 @@ var routeRegistry = [
|
|
|
327
328
|
{
|
|
328
329
|
pattern: "/api/puck/chat",
|
|
329
330
|
methods: {
|
|
330
|
-
POST: ({ body }, options) =>
|
|
331
|
+
POST: ({ body }, options) => chatPrivate(body, options)
|
|
331
332
|
}
|
|
332
333
|
},
|
|
333
334
|
{
|
package/dist/index.d.mts
CHANGED
|
@@ -30,10 +30,25 @@ type DataFinish = {
|
|
|
30
30
|
type OnFinishResult = DataFinish;
|
|
31
31
|
type OnFinishCallback = (result: OnFinishResult) => void;
|
|
32
32
|
type UserToolRegistry = Record<string, UserTool>;
|
|
33
|
+
type DesignModeOptions = {
|
|
34
|
+
/**
|
|
35
|
+
* Set to true to allow design-mode requests. Defaults to false.
|
|
36
|
+
*/
|
|
37
|
+
allowed?: boolean;
|
|
38
|
+
instructions?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Set to true to allow generated components to include scripts. When
|
|
41
|
+
* disabled, the `script` field is removed from the custom component schema,
|
|
42
|
+
* so the model never generates it. Defaults to false.
|
|
43
|
+
*/
|
|
44
|
+
scripts?: boolean;
|
|
45
|
+
};
|
|
33
46
|
type PuckAiOptions = {
|
|
34
47
|
context?: string;
|
|
35
48
|
tools?: UserToolRegistry;
|
|
36
49
|
onFinish?: OnFinishCallback;
|
|
50
|
+
designMode?: DesignModeOptions;
|
|
51
|
+
mode?: "assembly" | "design";
|
|
37
52
|
};
|
|
38
53
|
type PuckCloudOptions = {
|
|
39
54
|
ai?: PuckAiOptions;
|
|
@@ -68,4 +83,4 @@ declare function puckHandler(request: Request, options?: PuckCloudOptions): Prom
|
|
|
68
83
|
declare const endpoints: readonly ["chat"];
|
|
69
84
|
type Endpoint = (typeof endpoints)[number];
|
|
70
85
|
|
|
71
|
-
export { type ChatParams, type Endpoint, type GenerateParams, type OnFinishCallback, type OnFinishResult, type PuckCloudOptions, type UserTool, type UserToolRegistry, chat, endpoints, generate, puckHandler, tool };
|
|
86
|
+
export { type ChatParams, type DesignModeOptions, type Endpoint, type GenerateParams, type OnFinishCallback, type OnFinishResult, type PuckCloudOptions, type UserTool, type UserToolRegistry, chat, endpoints, generate, puckHandler, tool };
|
package/dist/index.d.ts
CHANGED
|
@@ -30,10 +30,25 @@ type DataFinish = {
|
|
|
30
30
|
type OnFinishResult = DataFinish;
|
|
31
31
|
type OnFinishCallback = (result: OnFinishResult) => void;
|
|
32
32
|
type UserToolRegistry = Record<string, UserTool>;
|
|
33
|
+
type DesignModeOptions = {
|
|
34
|
+
/**
|
|
35
|
+
* Set to true to allow design-mode requests. Defaults to false.
|
|
36
|
+
*/
|
|
37
|
+
allowed?: boolean;
|
|
38
|
+
instructions?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Set to true to allow generated components to include scripts. When
|
|
41
|
+
* disabled, the `script` field is removed from the custom component schema,
|
|
42
|
+
* so the model never generates it. Defaults to false.
|
|
43
|
+
*/
|
|
44
|
+
scripts?: boolean;
|
|
45
|
+
};
|
|
33
46
|
type PuckAiOptions = {
|
|
34
47
|
context?: string;
|
|
35
48
|
tools?: UserToolRegistry;
|
|
36
49
|
onFinish?: OnFinishCallback;
|
|
50
|
+
designMode?: DesignModeOptions;
|
|
51
|
+
mode?: "assembly" | "design";
|
|
37
52
|
};
|
|
38
53
|
type PuckCloudOptions = {
|
|
39
54
|
ai?: PuckAiOptions;
|
|
@@ -68,4 +83,4 @@ declare function puckHandler(request: Request, options?: PuckCloudOptions): Prom
|
|
|
68
83
|
declare const endpoints: readonly ["chat"];
|
|
69
84
|
type Endpoint = (typeof endpoints)[number];
|
|
70
85
|
|
|
71
|
-
export { type ChatParams, type Endpoint, type GenerateParams, type OnFinishCallback, type OnFinishResult, type PuckCloudOptions, type UserTool, type UserToolRegistry, chat, endpoints, generate, puckHandler, tool };
|
|
86
|
+
export { type ChatParams, type DesignModeOptions, type Endpoint, type GenerateParams, type OnFinishCallback, type OnFinishResult, type PuckCloudOptions, type UserTool, type UserToolRegistry, chat, endpoints, generate, puckHandler, tool };
|
package/dist/index.js
CHANGED
|
@@ -22240,14 +22240,17 @@ var cloudApi = async (path, body, options = {}, onChunk) => {
|
|
|
22240
22240
|
"No Puck API key specified. Set the PUCK_API_KEY environment variable, or provide one to the function"
|
|
22241
22241
|
);
|
|
22242
22242
|
}
|
|
22243
|
-
const { context, tools = {} } = ai;
|
|
22243
|
+
const { context, tools = {}, designMode } = ai;
|
|
22244
22244
|
const res = await fetch(`${host}/${path}`, {
|
|
22245
22245
|
headers: { "x-api-key": apiKey, "puck-api-version": apiVersion },
|
|
22246
22246
|
method: "post",
|
|
22247
22247
|
body: JSON.stringify({
|
|
22248
22248
|
...body,
|
|
22249
22249
|
context,
|
|
22250
|
-
tools: prepareUserTools(tools)
|
|
22250
|
+
tools: prepareUserTools(tools),
|
|
22251
|
+
...designMode ? {
|
|
22252
|
+
designMode
|
|
22253
|
+
} : {}
|
|
22251
22254
|
})
|
|
22252
22255
|
});
|
|
22253
22256
|
if (!res.body) {
|
|
@@ -22269,12 +22272,33 @@ var cloudApi = async (path, body, options = {}, onChunk) => {
|
|
|
22269
22272
|
};
|
|
22270
22273
|
|
|
22271
22274
|
// src/api/chat.ts
|
|
22275
|
+
function chatPrivate({ chatId, messages, config: config2, pageData, mode }, options = {}) {
|
|
22276
|
+
const resolvedMode = mode ?? options?.ai?.mode;
|
|
22277
|
+
const stream = createUIMessageStream({
|
|
22278
|
+
execute: async ({ writer }) => {
|
|
22279
|
+
await cloudApi(
|
|
22280
|
+
"chat",
|
|
22281
|
+
{ chatId, config: config2, messages, pageData, mode: resolvedMode },
|
|
22282
|
+
options,
|
|
22283
|
+
(chunk) => {
|
|
22284
|
+
if (chunk.type === "data-finish") {
|
|
22285
|
+
options.ai?.onFinish?.(chunk.data);
|
|
22286
|
+
} else {
|
|
22287
|
+
writer.write(chunk);
|
|
22288
|
+
}
|
|
22289
|
+
}
|
|
22290
|
+
);
|
|
22291
|
+
}
|
|
22292
|
+
});
|
|
22293
|
+
return createUIMessageStreamResponse({ stream });
|
|
22294
|
+
}
|
|
22272
22295
|
function chat({ chatId, messages, config: config2, pageData }, options = {}) {
|
|
22296
|
+
const resolvedMode = options?.ai?.mode;
|
|
22273
22297
|
const stream = createUIMessageStream({
|
|
22274
22298
|
execute: async ({ writer }) => {
|
|
22275
22299
|
await cloudApi(
|
|
22276
22300
|
"chat",
|
|
22277
|
-
{ chatId, config: config2, messages, pageData },
|
|
22301
|
+
{ chatId, config: config2, messages, pageData, mode: resolvedMode },
|
|
22278
22302
|
options,
|
|
22279
22303
|
(chunk) => {
|
|
22280
22304
|
if (chunk.type === "data-finish") {
|
|
@@ -22480,7 +22504,7 @@ var routeRegistry = [
|
|
|
22480
22504
|
{
|
|
22481
22505
|
pattern: "/api/puck/chat",
|
|
22482
22506
|
methods: {
|
|
22483
|
-
POST: ({ body }, options) =>
|
|
22507
|
+
POST: ({ body }, options) => chatPrivate(body, options)
|
|
22484
22508
|
}
|
|
22485
22509
|
}
|
|
22486
22510
|
];
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED