@bike4mind/cli 0.2.28-slack-native-search.18717 → 0.2.29-cli-resume-command.18763

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/README.md CHANGED
@@ -101,7 +101,7 @@ While in interactive mode:
101
101
 
102
102
  **Session Management:**
103
103
  - `/save <name>` - Save current session
104
- - `/sessions` - List saved sessions
104
+ - `/resume` - List and resume saved sessions
105
105
 
106
106
  **API Configuration:**
107
107
  - `/set-api <url>` - Connect to self-hosted Bike4Mind instance
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CurationArtifactType
4
- } from "./chunk-F3HPUK2I.js";
4
+ } from "./chunk-XJRPAAUS.js";
5
5
 
6
6
  // ../../b4m-core/packages/services/dist/src/notebookCurationService/artifactExtractor.js
7
7
  var ARTIFACT_TAG_REGEX = /<artifact\s+(.*?)>([\s\S]*?)<\/artifact>/gi;
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  BadRequestError,
4
4
  secureParameters
5
- } from "./chunk-JQOZTED2.js";
5
+ } from "./chunk-UNOJBVD2.js";
6
6
  import {
7
7
  CompletionApiUsageTransaction,
8
8
  GenericCreditDeductTransaction,
@@ -12,7 +12,7 @@ import {
12
12
  TextGenerationUsageTransaction,
13
13
  TransferCreditTransaction,
14
14
  VideoGenerationUsageTransaction
15
- } from "./chunk-F3HPUK2I.js";
15
+ } from "./chunk-XJRPAAUS.js";
16
16
 
17
17
  // ../../b4m-core/packages/services/dist/src/creditService/subtractCredits.js
18
18
  import { z } from "zod";
@@ -15,7 +15,7 @@ import {
15
15
  dayjsConfig_default,
16
16
  extractSnippetMeta,
17
17
  settingsMap
18
- } from "./chunk-F3HPUK2I.js";
18
+ } from "./chunk-XJRPAAUS.js";
19
19
  import {
20
20
  Logger
21
21
  } from "./chunk-OCYRD7D6.js";
@@ -6425,6 +6425,36 @@ var OpenAIBackend = class {
6425
6425
  description: "OpenAI GPT-Image-1 - Advanced multimodal image generation with text integration, supporting up to 2048x2048 resolution and image editing capabilities.",
6426
6426
  rank: 10
6427
6427
  },
6428
+ {
6429
+ id: ImageModels.GPT_IMAGE_1_5,
6430
+ type: "image",
6431
+ name: "GPT-Image-1.5",
6432
+ backend: ModelBackend.OpenAI,
6433
+ contextWindow: 1e4,
6434
+ supportsImageVariation: true,
6435
+ max_tokens: 1e4,
6436
+ pricing: {
6437
+ 1: { input: 8 / 1e6, output: 32 / 1e6 }
6438
+ // $8 / 1M Input tokens, $32 / 1M Output tokens (same as GPT-Image-1)
6439
+ },
6440
+ description: "OpenAI GPT-Image-1.5 - Enhanced version of GPT-Image-1 with improved image generation quality and text integration, supporting up to 2048x2048 resolution and image editing capabilities.",
6441
+ rank: 9
6442
+ },
6443
+ {
6444
+ id: ImageModels.GPT_IMAGE_1_MINI,
6445
+ type: "image",
6446
+ name: "GPT-Image-1 Mini",
6447
+ backend: ModelBackend.OpenAI,
6448
+ contextWindow: 1e4,
6449
+ supportsImageVariation: true,
6450
+ max_tokens: 1e4,
6451
+ pricing: {
6452
+ 1: { input: 4 / 1e6, output: 16 / 1e6 }
6453
+ // Lower pricing for mini variant
6454
+ },
6455
+ description: "OpenAI GPT-Image-1 Mini - Faster, cost-effective version of GPT-Image-1 with good quality image generation and text integration, supporting up to 2048x2048 resolution and image editing capabilities.",
6456
+ rank: 11
6457
+ },
6428
6458
  // OpenAI Speech-to-Text Models
6429
6459
  {
6430
6460
  id: SpeechToTextModels.WHISPER_1,
@@ -9151,7 +9181,7 @@ var QuestMaster = class {
9151
9181
  if (!this.quest) {
9152
9182
  throw new Error("No quest context available");
9153
9183
  }
9154
- await this.onStatusUpdate(this.quest, "Processing quest plan...");
9184
+ await this.onStatusUpdate(this.quest, "Step 2/4: Organizing quests and sub-tasks...");
9155
9185
  const defaultResponse = {
9156
9186
  type: "narrative",
9157
9187
  meta: {
@@ -9233,7 +9263,7 @@ var QuestMaster = class {
9233
9263
  }
9234
9264
  if (extracted.length > 0) {
9235
9265
  this.logger.log("Successfully extracted QuestMaster data:", extracted);
9236
- await this.onStatusUpdate(this.quest, "Extracted QuestMaster data");
9266
+ await this.onStatusUpdate(this.quest, "Step 3/4: Validating quest structure...");
9237
9267
  const validQuests = extracted.filter((quest) => quest !== null && typeof quest === "object" && quest.id && quest.title && quest.description);
9238
9268
  if (validQuests.length === 0) {
9239
9269
  throw new Error("No valid quests found after filtering");
@@ -9326,7 +9356,7 @@ var QuestMaster = class {
9326
9356
  questResponse = defaultResponse;
9327
9357
  this.logger.error("Invalid quest response structure, using default");
9328
9358
  }
9329
- await this.onStatusUpdate(this.quest, "Saving quest plan...");
9359
+ await this.onStatusUpdate(this.quest, "Step 4/4: Saving quest plan...");
9330
9360
  console.log("\u{1F3AF} Creating QuestMasterPlan with userId:", this.userId);
9331
9361
  const questMasterPlan = await this.db.questMasterPlans.create({
9332
9362
  notebookId: this.quest.sessionId,
@@ -9648,7 +9678,7 @@ HANDLING VERBOSE INPUT:
9648
9678
  }
9649
9679
  const { history = [] } = options;
9650
9680
  this.logger.log(`Creating quest plan with ${history.length} history messages for context`);
9651
- await this.onStatusUpdate(this.quest, "Creating quest plan...");
9681
+ await this.onStatusUpdate(this.quest, "Step 1/4: Analyzing your request...");
9652
9682
  if (isGPT5ModelWithToolSupport(model)) {
9653
9683
  this.logger.log(`Using function calling approach for GPT-5 model: ${model}`);
9654
9684
  try {
@@ -9895,6 +9925,9 @@ async function invokeImageProcessor(imageBuffer, lambdaFunctionName, maxSizeMB =
9895
9925
  throw new Error("ImageProcessor Lambda returned no payload");
9896
9926
  }
9897
9927
  const result = JSON.parse(Buffer.from(response.Payload).toString());
9928
+ if (!result.processedBuffer) {
9929
+ throw new Error(`ImageProcessor Lambda returned invalid response - missing processedBuffer. Response: ${JSON.stringify(result)}`);
9930
+ }
9898
9931
  console.log(`[ImageProcessorUtils] Image processed successfully:`, {
9899
9932
  outputSizeMB: result.sizeMB,
9900
9933
  isPng: result.isPng
@@ -9932,24 +9965,28 @@ async function downloadImageAsBuffer(imageUrl) {
9932
9965
 
9933
9966
  // ../../b4m-core/packages/utils/dist/src/imageGeneration/OpenAIImageService.js
9934
9967
  var OpenAIImageService = class extends AIImageService {
9968
+ // Helper to check if a model is a GPT Image model
9969
+ isGPTImageModel(model) {
9970
+ return model === ImageModels.GPT_IMAGE_1 || model === ImageModels.GPT_IMAGE_1_5 || model === ImageModels.GPT_IMAGE_1_MINI;
9971
+ }
9935
9972
  async generate(prompt, options) {
9936
9973
  const openai = new OpenAI5({ apiKey: this.apiKey });
9937
9974
  Logger.log("Generating image... with these params: ", options);
9938
9975
  try {
9939
9976
  const { safety_tolerance, prompt_upsampling, seed: bflSeed, output_format, imagePrompt, stream, ...openaiOptions } = options;
9940
9977
  const parameterWarnings = [];
9941
- if (options.model === ImageModels.GPT_IMAGE_1) {
9942
- console.log("[DEBUG] GPT-Image-1 parameter validation and sanitization...");
9943
- openaiOptions.model = "gpt-image-1";
9978
+ if (this.isGPTImageModel(options.model)) {
9979
+ const modelName = options.model || ImageModels.GPT_IMAGE_1_5;
9980
+ openaiOptions.model = modelName;
9944
9981
  if (openaiOptions.style) {
9945
- parameterWarnings.push(`Style parameter ('${openaiOptions.style}') is not supported by GPT-Image-1 and was removed`);
9982
+ parameterWarnings.push(`Style parameter ('${openaiOptions.style}') is not supported by ${modelName} and was removed`);
9946
9983
  delete openaiOptions.style;
9947
9984
  }
9948
9985
  if (openaiOptions.response_format) {
9949
9986
  delete openaiOptions.response_format;
9950
9987
  }
9951
9988
  if (openaiOptions.quality) {
9952
- parameterWarnings.push(`Quality parameter ('${openaiOptions.quality}') is not supported by GPT-Image-1 text-to-image generation and was removed`);
9989
+ parameterWarnings.push(`Quality parameter ('${openaiOptions.quality}') is not supported by ${modelName} text-to-image generation and was removed`);
9953
9990
  delete openaiOptions.quality;
9954
9991
  }
9955
9992
  const validGPTSizes = ["1024x1024", "1536x1024", "1024x1536"];
@@ -9957,7 +9994,7 @@ var OpenAIImageService = class extends AIImageService {
9957
9994
  if (!validGPTSizes.includes(openaiOptions.size)) {
9958
9995
  const originalSize = openaiOptions.size;
9959
9996
  openaiOptions.size = "1024x1024";
9960
- parameterWarnings.push(`Size '${originalSize}' is not supported by GPT-Image-1, changed to '1024x1024'`);
9997
+ parameterWarnings.push(`Size '${originalSize}' is not supported by ${modelName}, changed to '1024x1024'`);
9961
9998
  }
9962
9999
  } else {
9963
10000
  openaiOptions.size = "1024x1024";
@@ -9965,10 +10002,10 @@ var OpenAIImageService = class extends AIImageService {
9965
10002
  if ("width" in openaiOptions || "height" in openaiOptions) {
9966
10003
  delete openaiOptions.width;
9967
10004
  delete openaiOptions.height;
9968
- parameterWarnings.push("Custom width/height not supported by GPT-Image-1, using standard sizes");
10005
+ parameterWarnings.push(`Custom width/height not supported by ${modelName}, using standard sizes`);
9969
10006
  }
9970
10007
  if (parameterWarnings.length > 0) {
9971
- console.log("[DEBUG] \u26A0\uFE0F GPT-Image-1 parameter adjustments:", parameterWarnings);
10008
+ console.log(`[DEBUG] \u26A0\uFE0F ${modelName} parameter adjustments:`, parameterWarnings);
9972
10009
  }
9973
10010
  } else {
9974
10011
  openaiOptions.response_format = "url";
@@ -9987,99 +10024,37 @@ var OpenAIImageService = class extends AIImageService {
9987
10024
  if (bflSeed !== null && bflSeed !== void 0) {
9988
10025
  openaiOptions.seed = bflSeed;
9989
10026
  }
9990
- console.log("[DEBUG] OpenAI Image generation sanitized params:", {
9991
- model: options.model,
9992
- prompt: prompt.substring(0, 100) + "...",
9993
- finalOptions: openaiOptions,
9994
- adjustments: parameterWarnings.length > 0 ? parameterWarnings : "No adjustments needed"
9995
- });
9996
10027
  let images = [];
9997
- if (false) {
9998
- } else {
9999
- let result;
10000
- if (imagePrompt) {
10001
- console.log("RUNNING IMAGE-TO-IMAGE for ", imagePrompt);
10002
- const imageBuffer = await downloadImageAsBuffer(imagePrompt);
10003
- if (!this.imageProcessorLambdaName) {
10004
- throw new Error("ImageProcessor Lambda name is required for image processing. Please provide it when creating the image service.");
10005
- }
10006
- const pngBuffer = await invokeImageProcessor(imageBuffer, this.imageProcessorLambdaName, 4);
10007
- console.log(`[DEBUG] Image prepared for image-to-image:`, {
10008
- originalUrl: imagePrompt.substring(0, 100) + "...",
10009
- pngSizeMB: (pngBuffer.length / (1024 * 1024)).toFixed(2),
10010
- bufferLength: pngBuffer.length
10028
+ let result;
10029
+ if (imagePrompt) {
10030
+ const imageBuffer = await downloadImageAsBuffer(imagePrompt);
10031
+ if (!this.imageProcessorLambdaName) {
10032
+ throw new Error("ImageProcessor Lambda name is required for image processing. Please provide it when creating the image service.");
10033
+ }
10034
+ const pngBuffer = await invokeImageProcessor(imageBuffer, this.imageProcessorLambdaName, 4);
10035
+ const imageFile = new File([pngBuffer], "image.png", { type: "image/png" });
10036
+ if (this.isGPTImageModel(options.model)) {
10037
+ const editModel = options.model || ImageModels.GPT_IMAGE_1_5;
10038
+ result = await openai.images.edit({
10039
+ model: editModel,
10040
+ image: [imageFile],
10041
+ prompt
10011
10042
  });
10012
- const imageFile = new File([pngBuffer], "image.png", { type: "image/png" });
10013
- if (options.model === ImageModels.GPT_IMAGE_1) {
10014
- console.log("[DEBUG] Using GPT-Image-1 edit endpoint for image-to-image generation");
10015
- const { style, quality, size, ...editOptions } = openaiOptions;
10016
- let editSize;
10017
- const validEditSizes = [
10018
- "auto",
10019
- "1024x1024",
10020
- "1536x1024",
10021
- "1024x1536",
10022
- "256x256",
10023
- "512x512"
10024
- ];
10025
- if (size && validEditSizes.includes(size)) {
10026
- editSize = size;
10027
- } else if (size) {
10028
- console.log(`[DEBUG] Size '${size}' not supported by edit endpoint, using '1024x1024'`);
10029
- editSize = "1024x1024";
10030
- }
10031
- result = await openai.images.edit({
10032
- ...editOptions,
10033
- image: imageFile,
10034
- prompt,
10035
- model: "gpt-image-1",
10036
- ...editSize && { size: editSize }
10037
- });
10038
- console.log("[DEBUG] GPT-Image-1 edit result:", {
10039
- success: !!result,
10040
- dataLength: result?.data?.length,
10041
- hasUrl: !!result?.data?.[0]?.url,
10042
- hasB64: !!result?.data?.[0]?.b64_json
10043
- });
10044
- } else {
10045
- console.log("[DEBUG] Using DALL-E 2 variation endpoint");
10046
- const { style, quality, model, ...opts } = openaiOptions;
10047
- result = await openai.images.createVariation({
10048
- ...opts,
10049
- image: imageFile,
10050
- size: ["256x256", "512x512", "1024x1024"].find((s) => s === openaiOptions.size)
10051
- });
10052
- console.log("[DEBUG] Variation result:", {
10053
- success: !!result,
10054
- dataLength: result?.data?.length,
10055
- hasUrl: !!result?.data?.[0]?.url
10056
- });
10057
- }
10058
10043
  } else {
10059
- console.log("RUNNING GENERATE");
10060
- result = await openai.images.generate({
10061
- prompt,
10062
- ...openaiOptions
10063
- });
10064
- console.log("[DEBUG] OpenAI raw response:", {
10065
- model: options.model,
10066
- resultData: result?.data,
10067
- firstImage: result?.data?.[0],
10068
- firstImageKeys: result?.data?.[0] ? Object.keys(result.data[0]) : "No first image"
10069
- });
10070
- console.log("[DEBUG] OpenAI Image generation response:", {
10071
- model: options.model,
10072
- responseData: result?.data?.length ? `${result.data.length} images generated` : "No images",
10073
- firstUrl: result?.data?.[0]?.url ? "URL received" : "No URL"
10044
+ const { style, quality, model, ...opts } = openaiOptions;
10045
+ result = await openai.images.createVariation({
10046
+ ...opts,
10047
+ image: imageFile,
10048
+ size: ["256x256", "512x512", "1024x1024"].find((s) => s === openaiOptions.size)
10074
10049
  });
10075
10050
  }
10076
- images = this.imageResponseToUrl(result);
10051
+ } else {
10052
+ result = await openai.images.generate({
10053
+ prompt,
10054
+ ...openaiOptions
10055
+ });
10077
10056
  }
10078
- console.log("[DEBUG] OpenAI Image generation completed:", {
10079
- model: options.model,
10080
- imageCount: images.length,
10081
- hasUrls: images.every((url) => url && url.startsWith("http"))
10082
- });
10057
+ images = this.imageResponseToUrl(result);
10083
10058
  return images;
10084
10059
  } catch (error) {
10085
10060
  console.error("[DEBUG] Error in OpenAI image generation:", {
@@ -10122,7 +10097,7 @@ Tip: Consider using alternative models like Flux Pro that may have different con
10122
10097
  throw new Error(`Image response contains neither url nor b64_json: ${JSON.stringify(Object.keys(imageData))}`);
10123
10098
  });
10124
10099
  }
10125
- async edit(image, prompt, { mask = null, model = ImageModels.GPT_IMAGE_1, n = 1, size, response_format = "url", user }) {
10100
+ async edit(image, prompt, { mask = null, model = ImageModels.GPT_IMAGE_1_5, n = 1, size, response_format = "url", user }) {
10126
10101
  try {
10127
10102
  const openai = new OpenAI5({ apiKey: this.apiKey });
10128
10103
  const cleanImageBase64 = image.replace(/^data:image\/(png|jpeg|jpg);base64,/, "");
@@ -10142,35 +10117,35 @@ Tip: Consider using alternative models like Flux Pro that may have different con
10142
10117
  const pngMaskBuffer = await invokeImageProcessor(maskBuffer, this.imageProcessorLambdaName, 4);
10143
10118
  maskFile = new File([pngMaskBuffer], "mask.png", { type: "image/png" });
10144
10119
  }
10145
- console.log("[DEBUG] OpenAI Image edit request:", {
10146
- prompt,
10147
- size,
10148
- imageFile,
10149
- maskFile,
10150
- n,
10151
- response_format,
10152
- user
10153
- });
10154
- const response = await openai.images.edit({
10155
- prompt,
10120
+ let editModel = model;
10121
+ if (!this.isGPTImageModel(model) && model !== ImageModels.DALL_E_2) {
10122
+ console.log(`[DEBUG] \u26A0\uFE0F Edit endpoint doesn't support ${model}, defaulting to gpt-image-1.5`);
10123
+ editModel = ImageModels.GPT_IMAGE_1_5;
10124
+ }
10125
+ const response = await openai.images.edit(this.isGPTImageModel(editModel) ? {
10126
+ model: editModel,
10127
+ image: [imageFile],
10128
+ prompt
10129
+ } : {
10130
+ model: editModel,
10156
10131
  image: imageFile,
10132
+ prompt,
10157
10133
  mask: maskFile,
10158
10134
  n,
10159
10135
  size,
10160
10136
  response_format,
10161
10137
  user
10162
10138
  });
10163
- console.log("[DEBUG] OpenAI Image edit response:", {
10164
- data: response
10165
- });
10166
10139
  if (response.data && response.data.length > 0) {
10167
10140
  const result = response.data[0];
10168
- const dataUrl = response_format === "b64_json" ? result.b64_json : result.url;
10141
+ const dataUrl = result.b64_json ? `data:image/png;base64,${result.b64_json}` : result.url;
10142
+ if (!dataUrl) {
10143
+ throw new Error(`Image response contains neither url nor b64_json: ${JSON.stringify(Object.keys(result))}`);
10144
+ }
10169
10145
  return { type: "success", dataUrl };
10170
10146
  }
10171
10147
  throw new Error("No image was generated");
10172
10148
  } catch (error) {
10173
- console.error("[DEBUG] Error in OpenAI image edit:", error);
10174
10149
  if (error instanceof OpenAI5.APIError) {
10175
10150
  console.error("[DEBUG] OpenAI API error details:", {
10176
10151
  status: error.status,
@@ -10204,8 +10179,8 @@ import axios3 from "axios";
10204
10179
  var BFLImageService = class extends AIImageService {
10205
10180
  baseUrl = "https://api.bfl.ai/v1";
10206
10181
  static failedRequests = {};
10207
- constructor(apiKey, logger) {
10208
- super(apiKey, logger);
10182
+ constructor(apiKey, logger, imageProcessorLambdaName) {
10183
+ super(apiKey, logger, imageProcessorLambdaName);
10209
10184
  }
10210
10185
  async generate(prompt, { n = 1, user = "user", model = ImageModels.FLUX_PRO_1_1, safety_tolerance = 0.5, prompt_upsampling = false, seed = null, output_format = "png", width = 1024, height = 768, aspect_ratio = "16:9", image_prompt, ...modelSpecificOptions }) {
10211
10186
  try {
@@ -10600,8 +10575,8 @@ import { GoogleGenAI as GoogleGenAI2 } from "@google/genai";
10600
10575
  import { v4 as uuidv42 } from "uuid";
10601
10576
  var GeminiImageService = class extends AIImageService {
10602
10577
  genAI;
10603
- constructor(apiKey, logger) {
10604
- super(apiKey, logger);
10578
+ constructor(apiKey, logger, imageProcessorLambdaName) {
10579
+ super(apiKey, logger, imageProcessorLambdaName);
10605
10580
  this.genAI = new GoogleGenAI2({ apiKey });
10606
10581
  }
10607
10582
  async generate(prompt, options) {
@@ -6,12 +6,12 @@ import {
6
6
  getSettingsByNames,
7
7
  obfuscateApiKey,
8
8
  secureParameters
9
- } from "./chunk-JQOZTED2.js";
9
+ } from "./chunk-UNOJBVD2.js";
10
10
  import {
11
11
  ApiKeyType,
12
12
  MementoTier,
13
13
  isSupportedEmbeddingModel
14
- } from "./chunk-F3HPUK2I.js";
14
+ } from "./chunk-XJRPAAUS.js";
15
15
 
16
16
  // ../../b4m-core/packages/services/dist/src/apiKeyService/get.js
17
17
  import { z } from "zod";