@blinkk/root-cms 2.4.8 → 2.4.9

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/app.js CHANGED
@@ -83,7 +83,7 @@ function convertOneOfTypes(collection) {
83
83
  // package.json
84
84
  var package_default = {
85
85
  name: "@blinkk/root-cms",
86
- version: "2.4.8",
86
+ version: "2.4.9",
87
87
  author: "s@blinkk.com",
88
88
  license: "MIT",
89
89
  engines: {
@@ -248,7 +248,7 @@ var package_default = {
248
248
  yjs: "13.6.27"
249
249
  },
250
250
  peerDependencies: {
251
- "@blinkk/root": "2.4.8",
251
+ "@blinkk/root": "2.4.9",
252
252
  "firebase-admin": ">=11",
253
253
  "firebase-functions": ">=4",
254
254
  preact: ">=10",
package/dist/plugin.js CHANGED
@@ -93,8 +93,7 @@ async function summarizeDiff(cmsClient, options) {
93
93
  "",
94
94
  "Summarize the differences between the two payloads."
95
95
  ].join("\n");
96
- const res = await ai.generate({
97
- model: vertexAI.model(model),
96
+ const res = await generate(ai, model, {
98
97
  messages: [
99
98
  {
100
99
  role: "system",
@@ -117,8 +116,7 @@ async function generateImage(cmsClient, options) {
117
116
  })
118
117
  ]
119
118
  });
120
- const res = await ai.generate({
121
- model: vertexAI.model(model),
119
+ const res = await generate(ai, model, {
122
120
  prompt: [
123
121
  {
124
122
  text: options.prompt
@@ -138,6 +136,19 @@ async function generateImage(cmsClient, options) {
138
136
  }
139
137
  return res.media.url;
140
138
  }
139
+ async function generate(ai, model, options) {
140
+ const generateOptions = {
141
+ ...options,
142
+ model: vertexAI.model(model)
143
+ };
144
+ if (model.startsWith("gemini-3")) {
145
+ generateOptions.config = {
146
+ ...generateOptions.config,
147
+ location: "global"
148
+ };
149
+ }
150
+ return ai.generate(generateOptions);
151
+ }
141
152
  function cleanModelName(model) {
142
153
  return LEGACY_MODEL_RENAME[model] || model;
143
154
  }
@@ -218,14 +229,9 @@ var init_ai = __esm({
218
229
  /** Sends the request to the AI and stores the history in the session and the database. */
219
230
  async sendPrompt(prompt, options = {}) {
220
231
  const chatRequest = await this.buildGenerateRequest(prompt, options);
221
- const res = await this.ai.generate({
222
- model: vertexAI.model(chatRequest.model),
232
+ const res = await generate(this.ai, chatRequest.model, {
223
233
  messages: chatRequest.messages,
224
- prompt: Array.isArray(prompt) ? prompt.flat() : prompt,
225
- // NOTE(stevenle): the global location is required for
226
- // `gemini-3-flash-preview`, it may be possible to remove this in the
227
- // future.
228
- config: { location: "global" }
234
+ prompt: Array.isArray(prompt) ? prompt.flat() : prompt
229
235
  });
230
236
  this.history = res.messages;
231
237
  await this.dbDoc().update({
@@ -2653,7 +2659,7 @@ function api(server, options) {
2653
2659
  // package.json
2654
2660
  var package_default = {
2655
2661
  name: "@blinkk/root-cms",
2656
- version: "2.4.8",
2662
+ version: "2.4.9",
2657
2663
  author: "s@blinkk.com",
2658
2664
  license: "MIT",
2659
2665
  engines: {
@@ -2818,7 +2824,7 @@ var package_default = {
2818
2824
  yjs: "13.6.27"
2819
2825
  },
2820
2826
  peerDependencies: {
2821
- "@blinkk/root": "2.4.8",
2827
+ "@blinkk/root": "2.4.9",
2822
2828
  "firebase-admin": ">=11",
2823
2829
  "firebase-functions": ">=4",
2824
2830
  preact: ">=10",
@@ -2854,6 +2860,10 @@ function sse(server) {
2854
2860
  });
2855
2861
  };
2856
2862
  server.use("/cms/api/sse.connect", async (req, res) => {
2863
+ if (!req.user) {
2864
+ res.status(401).json({ success: false, error: "NOT_AUTHORIZED" });
2865
+ return;
2866
+ }
2857
2867
  res.writeHead(200, {
2858
2868
  "Content-Type": "text/event-stream",
2859
2869
  "Cache-Control": "no-cache",