@puckeditor/cloud-client 0.8.0-canary.eb8b0718 → 0.8.0-canary.fa7850b7

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.
@@ -22410,7 +22410,11 @@ async function fetchWithRetry(input, init) {
22410
22410
 
22411
22411
  // src/lib/cloud-api.ts
22412
22412
  var DEFAULT_API_VERSION = "v2";
22413
- var CLOUD_CLIENT_VERSION = true ? "0.8.0-canary.eb8b0718" : "unknown";
22413
+ var DEFAULT_V2_MODELS = {
22414
+ assembly: "openai/gpt-5.4-mini",
22415
+ design: "openai/gpt-5.6-luna"
22416
+ };
22417
+ var CLOUD_CLIENT_VERSION = true ? "0.8.0-canary.fa7850b7" : "unknown";
22414
22418
  var cloudApi = async (path, body, options = {}, onChunk, forwardHeaders) => {
22415
22419
  const {
22416
22420
  ai = {},
@@ -22423,8 +22427,11 @@ var cloudApi = async (path, body, options = {}, onChunk, forwardHeaders) => {
22423
22427
  "No Puck API key specified. Set the PUCK_API_KEY environment variable, or provide one to the function"
22424
22428
  );
22425
22429
  }
22426
- const { context, tools = {}, designMode, model, providerOptions } = ai;
22427
- const providerApiKey = model || designMode?.model ? ai.providerApiKey ?? process.env.OPENAI_API_KEY : void 0;
22430
+ const { context, tools = {}, designMode, providerOptions } = ai;
22431
+ const bodyMode = "mode" in body ? body.mode : void 0;
22432
+ const mode = bodyMode === "design" || bodyMode === void 0 && ai.mode === "design" ? "design" : "assembly";
22433
+ const model = ai.model ?? (apiVersion === DEFAULT_API_VERSION ? DEFAULT_V2_MODELS[mode] : void 0);
22434
+ const providerApiKey = ai.model || designMode?.model ? ai.providerApiKey ?? process.env.OPENAI_API_KEY : void 0;
22428
22435
  const sealedProviderKey = providerApiKey ? await sealProviderKey(providerApiKey, apiKey) : void 0;
22429
22436
  const res = await fetchWithRetry(`${host}/${path}`, {
22430
22437
  headers: {
@@ -22469,9 +22476,14 @@ var cloudApi = async (path, body, options = {}, onChunk, forwardHeaders) => {
22469
22476
  };
22470
22477
 
22471
22478
  // src/api/chat.ts
22479
+ var handleStreamError = (error48) => {
22480
+ console.error(error48);
22481
+ return error48 instanceof Error ? error48.message : "An error occurred.";
22482
+ };
22472
22483
  function chatPrivate({ chatId, messages, config: config2, pageData, mode }, options = {}, forwardHeaders) {
22473
22484
  const resolvedMode = mode ?? options?.ai?.mode;
22474
22485
  const stream = createUIMessageStream({
22486
+ onError: handleStreamError,
22475
22487
  execute: async ({ writer }) => {
22476
22488
  await cloudApi(
22477
22489
  "chat",
@@ -22493,6 +22505,7 @@ function chatPrivate({ chatId, messages, config: config2, pageData, mode }, opti
22493
22505
  function chat({ chatId, messages, config: config2, pageData }, options = {}, forwardHeaders) {
22494
22506
  const resolvedMode = options?.ai?.mode;
22495
22507
  const stream = createUIMessageStream({
22508
+ onError: handleStreamError,
22496
22509
  execute: async ({ writer }) => {
22497
22510
  await cloudApi(
22498
22511
  "chat",
@@ -22535,20 +22548,25 @@ async function generate({
22535
22548
  apiKey,
22536
22549
  host
22537
22550
  };
22538
- await cloudApi(
22539
- "generate",
22540
- { prompt, config: config2, pageData, mode },
22541
- options,
22542
- (chunk) => {
22543
- if (chunk.type === "data-page") {
22544
- result = chunk.data;
22545
- } else if (chunk.type === "data-finish") {
22546
- onFinish?.(chunk.data);
22547
- } else if (chunk.type === "error") {
22548
- throw new Error(chunk.errorText);
22551
+ try {
22552
+ await cloudApi(
22553
+ "generate",
22554
+ { prompt, config: config2, pageData, mode },
22555
+ options,
22556
+ (chunk) => {
22557
+ if (chunk.type === "data-page") {
22558
+ result = chunk.data;
22559
+ } else if (chunk.type === "data-finish") {
22560
+ onFinish?.(chunk.data);
22561
+ } else if (chunk.type === "error") {
22562
+ throw new Error(chunk.errorText);
22563
+ }
22549
22564
  }
22550
- }
22551
- );
22565
+ );
22566
+ } catch (error48) {
22567
+ console.error(error48);
22568
+ throw error48;
22569
+ }
22552
22570
  return result;
22553
22571
  }
22554
22572
 
@@ -22453,7 +22453,11 @@ async function fetchWithRetry(input, init) {
22453
22453
 
22454
22454
  // src/lib/cloud-api.ts
22455
22455
  var DEFAULT_API_VERSION = "v2";
22456
- var CLOUD_CLIENT_VERSION = true ? "0.8.0-canary.eb8b0718" : "unknown";
22456
+ var DEFAULT_V2_MODELS = {
22457
+ assembly: "openai/gpt-5.4-mini",
22458
+ design: "openai/gpt-5.6-luna"
22459
+ };
22460
+ var CLOUD_CLIENT_VERSION = true ? "0.8.0-canary.fa7850b7" : "unknown";
22457
22461
  var cloudApi = async (path, body, options = {}, onChunk, forwardHeaders) => {
22458
22462
  const {
22459
22463
  ai = {},
@@ -22466,8 +22470,11 @@ var cloudApi = async (path, body, options = {}, onChunk, forwardHeaders) => {
22466
22470
  "No Puck API key specified. Set the PUCK_API_KEY environment variable, or provide one to the function"
22467
22471
  );
22468
22472
  }
22469
- const { context, tools = {}, designMode, model, providerOptions } = ai;
22470
- const providerApiKey = model || designMode?.model ? ai.providerApiKey ?? process.env.OPENAI_API_KEY : void 0;
22473
+ const { context, tools = {}, designMode, providerOptions } = ai;
22474
+ const bodyMode = "mode" in body ? body.mode : void 0;
22475
+ const mode = bodyMode === "design" || bodyMode === void 0 && ai.mode === "design" ? "design" : "assembly";
22476
+ const model = ai.model ?? (apiVersion === DEFAULT_API_VERSION ? DEFAULT_V2_MODELS[mode] : void 0);
22477
+ const providerApiKey = ai.model || designMode?.model ? ai.providerApiKey ?? process.env.OPENAI_API_KEY : void 0;
22471
22478
  const sealedProviderKey = providerApiKey ? await sealProviderKey(providerApiKey, apiKey) : void 0;
22472
22479
  const res = await fetchWithRetry(`${host}/${path}`, {
22473
22480
  headers: {
@@ -22512,9 +22519,14 @@ var cloudApi = async (path, body, options = {}, onChunk, forwardHeaders) => {
22512
22519
  };
22513
22520
 
22514
22521
  // src/api/chat.ts
22522
+ var handleStreamError = (error48) => {
22523
+ console.error(error48);
22524
+ return error48 instanceof Error ? error48.message : "An error occurred.";
22525
+ };
22515
22526
  function chatPrivate({ chatId, messages, config: config2, pageData, mode }, options = {}, forwardHeaders) {
22516
22527
  const resolvedMode = mode ?? options?.ai?.mode;
22517
22528
  const stream = createUIMessageStream({
22529
+ onError: handleStreamError,
22518
22530
  execute: async ({ writer }) => {
22519
22531
  await cloudApi(
22520
22532
  "chat",
@@ -22536,6 +22548,7 @@ function chatPrivate({ chatId, messages, config: config2, pageData, mode }, opti
22536
22548
  function chat({ chatId, messages, config: config2, pageData }, options = {}, forwardHeaders) {
22537
22549
  const resolvedMode = options?.ai?.mode;
22538
22550
  const stream = createUIMessageStream({
22551
+ onError: handleStreamError,
22539
22552
  execute: async ({ writer }) => {
22540
22553
  await cloudApi(
22541
22554
  "chat",
@@ -23064,20 +23077,25 @@ async function generate({
23064
23077
  apiKey,
23065
23078
  host
23066
23079
  };
23067
- await cloudApi(
23068
- "generate",
23069
- { prompt, config: config2, pageData, mode },
23070
- options,
23071
- (chunk) => {
23072
- if (chunk.type === "data-page") {
23073
- result = chunk.data;
23074
- } else if (chunk.type === "data-finish") {
23075
- onFinish?.(chunk.data);
23076
- } else if (chunk.type === "error") {
23077
- throw new Error(chunk.errorText);
23080
+ try {
23081
+ await cloudApi(
23082
+ "generate",
23083
+ { prompt, config: config2, pageData, mode },
23084
+ options,
23085
+ (chunk) => {
23086
+ if (chunk.type === "data-page") {
23087
+ result = chunk.data;
23088
+ } else if (chunk.type === "data-finish") {
23089
+ onFinish?.(chunk.data);
23090
+ } else if (chunk.type === "error") {
23091
+ throw new Error(chunk.errorText);
23092
+ }
23078
23093
  }
23079
- }
23080
- );
23094
+ );
23095
+ } catch (error48) {
23096
+ console.error(error48);
23097
+ throw error48;
23098
+ }
23081
23099
  return result;
23082
23100
  }
23083
23101
 
@@ -11,7 +11,7 @@ import {
11
11
  getAttachment,
12
12
  handlePuckRequest,
13
13
  tool
14
- } from "./chunk-6RWNT6EW.mjs";
14
+ } from "./chunk-GFTVWACW.mjs";
15
15
  import {
16
16
  init_react_import
17
17
  } from "./chunk-O6DC5HI2.mjs";
package/dist/index.d.mts CHANGED
@@ -641,7 +641,7 @@ type DesignModeOptions = {
641
641
  scripts?: boolean;
642
642
  /**
643
643
  * Model override for design-mode requests. Falls back to `ai.model`, or
644
- * the managed design model when unset.
644
+ * `openai/gpt-5.6-luna` when unset.
645
645
  */
646
646
  model?: PuckAiModel;
647
647
  /**
@@ -666,9 +666,12 @@ type PuckAiOptions = {
666
666
  designMode?: DesignModeOptions;
667
667
  mode?: "assembly" | "design";
668
668
  /**
669
- * Provider-qualified model id, e.g. "openai/gpt-5.4-mini". Runs on Puck's
670
- * managed infrastructure (supported models only) unless a provider key is
671
- * available, in which case it runs on your own provider account (BYOK).
669
+ * Provider-qualified model id, e.g. "openai/gpt-5.4-mini". When explicitly
670
+ * configured, it runs on Puck's managed infrastructure (supported models
671
+ * only) unless a provider key is available, in which case it runs on your
672
+ * own provider account (BYOK).
673
+ * Defaults to `openai/gpt-5.4-mini` in assembly mode and
674
+ * `openai/gpt-5.6-luna` in design mode.
672
675
  */
673
676
  model?: PuckAiModel;
674
677
  /**
package/dist/index.d.ts CHANGED
@@ -641,7 +641,7 @@ type DesignModeOptions = {
641
641
  scripts?: boolean;
642
642
  /**
643
643
  * Model override for design-mode requests. Falls back to `ai.model`, or
644
- * the managed design model when unset.
644
+ * `openai/gpt-5.6-luna` when unset.
645
645
  */
646
646
  model?: PuckAiModel;
647
647
  /**
@@ -666,9 +666,12 @@ type PuckAiOptions = {
666
666
  designMode?: DesignModeOptions;
667
667
  mode?: "assembly" | "design";
668
668
  /**
669
- * Provider-qualified model id, e.g. "openai/gpt-5.4-mini". Runs on Puck's
670
- * managed infrastructure (supported models only) unless a provider key is
671
- * available, in which case it runs on your own provider account (BYOK).
669
+ * Provider-qualified model id, e.g. "openai/gpt-5.4-mini". When explicitly
670
+ * configured, it runs on Puck's managed infrastructure (supported models
671
+ * only) unless a provider key is available, in which case it runs on your
672
+ * own provider account (BYOK).
673
+ * Defaults to `openai/gpt-5.4-mini` in assembly mode and
674
+ * `openai/gpt-5.6-luna` in design mode.
672
675
  */
673
676
  model?: PuckAiModel;
674
677
  /**
package/dist/index.js CHANGED
@@ -22455,7 +22455,11 @@ async function fetchWithRetry(input, init) {
22455
22455
 
22456
22456
  // src/lib/cloud-api.ts
22457
22457
  var DEFAULT_API_VERSION = "v2";
22458
- var CLOUD_CLIENT_VERSION = true ? "0.8.0-canary.eb8b0718" : "unknown";
22458
+ var DEFAULT_V2_MODELS = {
22459
+ assembly: "openai/gpt-5.4-mini",
22460
+ design: "openai/gpt-5.6-luna"
22461
+ };
22462
+ var CLOUD_CLIENT_VERSION = true ? "0.8.0-canary.fa7850b7" : "unknown";
22459
22463
  var cloudApi = async (path, body, options = {}, onChunk, forwardHeaders) => {
22460
22464
  const {
22461
22465
  ai = {},
@@ -22468,8 +22472,11 @@ var cloudApi = async (path, body, options = {}, onChunk, forwardHeaders) => {
22468
22472
  "No Puck API key specified. Set the PUCK_API_KEY environment variable, or provide one to the function"
22469
22473
  );
22470
22474
  }
22471
- const { context, tools = {}, designMode, model, providerOptions } = ai;
22472
- const providerApiKey = model || designMode?.model ? ai.providerApiKey ?? process.env.OPENAI_API_KEY : void 0;
22475
+ const { context, tools = {}, designMode, providerOptions } = ai;
22476
+ const bodyMode = "mode" in body ? body.mode : void 0;
22477
+ const mode = bodyMode === "design" || bodyMode === void 0 && ai.mode === "design" ? "design" : "assembly";
22478
+ const model = ai.model ?? (apiVersion === DEFAULT_API_VERSION ? DEFAULT_V2_MODELS[mode] : void 0);
22479
+ const providerApiKey = ai.model || designMode?.model ? ai.providerApiKey ?? process.env.OPENAI_API_KEY : void 0;
22473
22480
  const sealedProviderKey = providerApiKey ? await sealProviderKey(providerApiKey, apiKey) : void 0;
22474
22481
  const res = await fetchWithRetry(`${host}/${path}`, {
22475
22482
  headers: {
@@ -22514,9 +22521,14 @@ var cloudApi = async (path, body, options = {}, onChunk, forwardHeaders) => {
22514
22521
  };
22515
22522
 
22516
22523
  // src/api/chat.ts
22524
+ var handleStreamError = (error48) => {
22525
+ console.error(error48);
22526
+ return error48 instanceof Error ? error48.message : "An error occurred.";
22527
+ };
22517
22528
  function chatPrivate({ chatId, messages, config: config2, pageData, mode }, options = {}, forwardHeaders) {
22518
22529
  const resolvedMode = mode ?? options?.ai?.mode;
22519
22530
  const stream = createUIMessageStream({
22531
+ onError: handleStreamError,
22520
22532
  execute: async ({ writer }) => {
22521
22533
  await cloudApi(
22522
22534
  "chat",
@@ -22538,6 +22550,7 @@ function chatPrivate({ chatId, messages, config: config2, pageData, mode }, opti
22538
22550
  function chat({ chatId, messages, config: config2, pageData }, options = {}, forwardHeaders) {
22539
22551
  const resolvedMode = options?.ai?.mode;
22540
22552
  const stream = createUIMessageStream({
22553
+ onError: handleStreamError,
22541
22554
  execute: async ({ writer }) => {
22542
22555
  await cloudApi(
22543
22556
  "chat",
@@ -22580,20 +22593,25 @@ async function generate({
22580
22593
  apiKey,
22581
22594
  host
22582
22595
  };
22583
- await cloudApi(
22584
- "generate",
22585
- { prompt, config: config2, pageData, mode },
22586
- options,
22587
- (chunk) => {
22588
- if (chunk.type === "data-page") {
22589
- result = chunk.data;
22590
- } else if (chunk.type === "data-finish") {
22591
- onFinish?.(chunk.data);
22592
- } else if (chunk.type === "error") {
22593
- throw new Error(chunk.errorText);
22596
+ try {
22597
+ await cloudApi(
22598
+ "generate",
22599
+ { prompt, config: config2, pageData, mode },
22600
+ options,
22601
+ (chunk) => {
22602
+ if (chunk.type === "data-page") {
22603
+ result = chunk.data;
22604
+ } else if (chunk.type === "data-finish") {
22605
+ onFinish?.(chunk.data);
22606
+ } else if (chunk.type === "error") {
22607
+ throw new Error(chunk.errorText);
22608
+ }
22594
22609
  }
22595
- }
22596
- );
22610
+ );
22611
+ } catch (error48) {
22612
+ console.error(error48);
22613
+ throw error48;
22614
+ }
22597
22615
  return result;
22598
22616
  }
22599
22617
 
package/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  generate,
5
5
  puckHandler,
6
6
  tool
7
- } from "./chunk-6RWNT6EW.mjs";
7
+ } from "./chunk-GFTVWACW.mjs";
8
8
  import "./chunk-O6DC5HI2.mjs";
9
9
  export {
10
10
  chat,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puckeditor/cloud-client",
3
- "version": "0.8.0-canary.eb8b0718",
3
+ "version": "0.8.0-canary.fa7850b7",
4
4
  "author": "Chris Villa <chris@puckeditor.com>",
5
5
  "repository": "puckeditor/puck",
6
6
  "bugs": "https://github.com/puckeditor/puck/issues",
@@ -34,7 +34,7 @@
34
34
  ],
35
35
  "devDependencies": {
36
36
  "@ai-sdk/openai": "^3.0.85",
37
- "@puckeditor/core": "0.22.0",
37
+ "@puckeditor/core": "0.23.0-canary.e7fef140",
38
38
  "@types/node": "^24.10.1",
39
39
  "ai": "^6.0.228",
40
40
  "eslint": "^9.39.4",
@@ -44,9 +44,9 @@
44
44
  "vite-tsconfig-paths": "^5.1.4",
45
45
  "vitest": "^4.1.0",
46
46
  "zod": "^4.1.12",
47
- "eslint-config-custom": "0.8.0-canary.eb8b0718",
48
- "tsconfig": "0.8.0-canary.eb8b0718",
49
- "tsup-config": "0.8.0-canary.eb8b0718"
47
+ "eslint-config-custom": "0.8.0-canary.fa7850b7",
48
+ "tsconfig": "0.8.0-canary.fa7850b7",
49
+ "tsup-config": "0.8.0-canary.fa7850b7"
50
50
  },
51
51
  "scripts": {
52
52
  "lint": "eslint \"**/*.ts*\"",