@quanta-intellect/vessel-browser 0.1.61 → 0.1.63

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/out/main/index.js CHANGED
@@ -3938,6 +3938,7 @@ let flushTimer = null;
3938
3938
  let sessionStartedAt = null;
3939
3939
  function isEnabled() {
3940
3940
  if (POSTHOG_API_KEY === "YOUR_POSTHOG_KEY_HERE") return false;
3941
+ if (process.env.VESSEL_DEV === "1") return false;
3941
3942
  return loadSettings().telemetryEnabled !== false;
3942
3943
  }
3943
3944
  function trackEvent(event, properties = {}) {
@@ -4199,6 +4200,37 @@ function mapActionButtons(interactiveElements) {
4199
4200
  }
4200
4201
  return buttons;
4201
4202
  }
4203
+ function asStructuredObject(value) {
4204
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
4205
+ }
4206
+ function stringifyStructuredScalar(value) {
4207
+ if (typeof value === "string") {
4208
+ const trimmed = value.trim();
4209
+ return trimmed || void 0;
4210
+ }
4211
+ if (typeof value === "number" && Number.isFinite(value)) {
4212
+ return String(value);
4213
+ }
4214
+ return void 0;
4215
+ }
4216
+ function firstStructuredString(...values) {
4217
+ for (const value of values) {
4218
+ const normalized = stringifyStructuredScalar(value);
4219
+ if (normalized) return normalized;
4220
+ }
4221
+ return void 0;
4222
+ }
4223
+ function getOfferPrice(offers) {
4224
+ if (Array.isArray(offers)) {
4225
+ for (const offer2 of offers) {
4226
+ const price = getOfferPrice(offer2);
4227
+ if (price) return price;
4228
+ }
4229
+ return void 0;
4230
+ }
4231
+ const offer = asStructuredObject(offers);
4232
+ return firstStructuredString(offer?.price);
4233
+ }
4202
4234
  function extractPrimaryEntity(pageType, structuredData, metaTags) {
4203
4235
  if (pageType === "product") {
4204
4236
  const product = structuredData?.find(
@@ -4206,14 +4238,27 @@ function extractPrimaryEntity(pageType, structuredData, metaTags) {
4206
4238
  );
4207
4239
  if (product) {
4208
4240
  const attrs = product.attributes ?? {};
4241
+ const aggregateRating = asStructuredObject(attrs.aggregateRating);
4209
4242
  return {
4210
4243
  type: "Product",
4211
- nameField: typeof attrs.name === "string" ? attrs.name : void 0,
4212
- priceField: typeof attrs.price === "string" ? attrs.price : typeof attrs.offers === "object" && attrs.offers !== null ? String(attrs.offers["price"] ?? "") : void 0,
4213
- imageField: typeof attrs.image === "string" ? attrs.image : Array.isArray(attrs.image) ? String(attrs.image[0]) : void 0,
4214
- descriptionField: typeof attrs.description === "string" ? attrs.description : void 0,
4215
- reviewsField: typeof attrs.reviews === "string" ? attrs.reviews : void 0,
4216
- ratingField: typeof attrs.rating === "string" ? attrs.rating : void 0,
4244
+ nameField: firstStructuredString(attrs.name),
4245
+ priceField: firstStructuredString(attrs.price) ?? getOfferPrice(attrs.offers),
4246
+ imageField: firstStructuredString(
4247
+ attrs.image,
4248
+ Array.isArray(attrs.image) ? attrs.image[0] : void 0
4249
+ ),
4250
+ descriptionField: firstStructuredString(attrs.description),
4251
+ reviewsField: firstStructuredString(
4252
+ attrs.reviews,
4253
+ attrs.reviewCount,
4254
+ aggregateRating?.reviewCount,
4255
+ aggregateRating?.ratingCount
4256
+ ),
4257
+ ratingField: firstStructuredString(
4258
+ attrs.rating,
4259
+ attrs.ratingValue,
4260
+ aggregateRating?.ratingValue
4261
+ ),
4217
4262
  addToCartField: void 0
4218
4263
  };
4219
4264
  }
@@ -11749,6 +11794,33 @@ function formatCompactToolResult(name, result) {
11749
11794
  return limitText(result, 18, 1400);
11750
11795
  }
11751
11796
  }
11797
+ function normalizeOptionalString(value) {
11798
+ if (typeof value !== "string") return void 0;
11799
+ const trimmed = value.trim();
11800
+ return trimmed || void 0;
11801
+ }
11802
+ function normalizeKeyFields(value) {
11803
+ if (!Array.isArray(value)) return void 0;
11804
+ const normalized = value.filter((field) => typeof field === "string").map((field) => field.trim()).filter(Boolean);
11805
+ return normalized.length > 0 ? normalized : void 0;
11806
+ }
11807
+ function normalizeAgentHints(value) {
11808
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
11809
+ return void 0;
11810
+ }
11811
+ const normalized = Object.fromEntries(
11812
+ Object.entries(value).map(([key, hint]) => [key.trim(), normalizeOptionalString(hint)]).filter((entry) => Boolean(entry[0] && entry[1]))
11813
+ );
11814
+ return Object.keys(normalized).length > 0 ? normalized : void 0;
11815
+ }
11816
+ function normalizeBookmarkMetadata(input) {
11817
+ return {
11818
+ intent: normalizeOptionalString(input.intent),
11819
+ expectedContent: normalizeOptionalString(input.expectedContent),
11820
+ keyFields: normalizeKeyFields(input.keyFields),
11821
+ agentHints: normalizeAgentHints(input.agentHints)
11822
+ };
11823
+ }
11752
11824
  const HUGGING_FACE_HUB_HOSTS = /* @__PURE__ */ new Set(["huggingface.co", "www.huggingface.co"]);
11753
11825
  const HUGGING_FACE_MODEL_TASKS = [
11754
11826
  {
@@ -12009,6 +12081,14 @@ function buildHuggingFaceSearchShortcut(currentUrl, rawQuery) {
12009
12081
  appliedFilters
12010
12082
  };
12011
12083
  }
12084
+ function getBookmarkMetadataFromArgs(args) {
12085
+ return normalizeBookmarkMetadata({
12086
+ intent: args.intent,
12087
+ expectedContent: args.expectedContent,
12088
+ keyFields: args.keyFields,
12089
+ agentHints: args.agentHints
12090
+ });
12091
+ }
12012
12092
  const DEFAULT_PAGE_SCRIPT_TIMEOUT_MS = 1500;
12013
12093
  const PAGE_SCRIPT_TIMEOUT = /* @__PURE__ */ Symbol("page-script-timeout");
12014
12094
  async function loadPermittedUrl$1(wc, url) {
@@ -15675,14 +15755,7 @@ ${truncated}`;
15675
15755
  note,
15676
15756
  {
15677
15757
  onDuplicate,
15678
- extra: {
15679
- intent: typeof args.intent === "string" && args.intent.trim() ? args.intent.trim() : void 0,
15680
- expectedContent: typeof args.expectedContent === "string" && args.expectedContent.trim() ? args.expectedContent.trim() : void 0,
15681
- keyFields: Array.isArray(args.keyFields) ? args.keyFields.filter(
15682
- (f) => typeof f === "string"
15683
- ) : void 0,
15684
- agentHints: args.agentHints && typeof args.agentHints === "object" ? args.agentHints : void 0
15685
- }
15758
+ extra: getBookmarkMetadataFromArgs(args)
15686
15759
  }
15687
15760
  );
15688
15761
  if (result2.status === "conflict" && result2.existing) {
@@ -15723,12 +15796,7 @@ ${truncated}`;
15723
15796
  folderId: target.folderId,
15724
15797
  title: typeof args.title === "string" && args.title.trim() ? args.title.trim() : void 0,
15725
15798
  note,
15726
- intent: typeof args.intent === "string" && args.intent.trim() ? args.intent.trim() : void 0,
15727
- expectedContent: typeof args.expectedContent === "string" && args.expectedContent.trim() ? args.expectedContent.trim() : void 0,
15728
- keyFields: Array.isArray(args.keyFields) ? args.keyFields.filter(
15729
- (f) => typeof f === "string"
15730
- ) : void 0,
15731
- agentHints: args.agentHints && typeof args.agentHints === "object" ? args.agentHints : void 0
15799
+ ...getBookmarkMetadataFromArgs(args)
15732
15800
  });
15733
15801
  if (!updated) {
15734
15802
  return `Bookmark ${existing.id} not found`;
@@ -15746,14 +15814,7 @@ ${truncated}`;
15746
15814
  note,
15747
15815
  {
15748
15816
  onDuplicate: "update",
15749
- extra: {
15750
- intent: typeof args.intent === "string" && args.intent.trim() ? args.intent.trim() : void 0,
15751
- expectedContent: typeof args.expectedContent === "string" && args.expectedContent.trim() ? args.expectedContent.trim() : void 0,
15752
- keyFields: Array.isArray(args.keyFields) ? args.keyFields.filter(
15753
- (f) => typeof f === "string"
15754
- ) : void 0,
15755
- agentHints: args.agentHints && typeof args.agentHints === "object" ? args.agentHints : void 0
15756
- }
15817
+ extra: getBookmarkMetadataFromArgs(args)
15757
15818
  }
15758
15819
  );
15759
15820
  const bookmark = result2.bookmark;
@@ -17454,6 +17515,14 @@ function readAuditLog(limit = 100) {
17454
17515
  }
17455
17516
  let httpServer = null;
17456
17517
  let mcpAuthToken = null;
17518
+ function getBookmarkMetadataFromToolArgs(args) {
17519
+ return normalizeBookmarkMetadata({
17520
+ intent: args.intent,
17521
+ expectedContent: args.expected_content,
17522
+ keyFields: args.key_fields,
17523
+ agentHints: args.agent_hints
17524
+ });
17525
+ }
17457
17526
  const MCP_AUTH_FILENAME = "mcp-auth.json";
17458
17527
  function getMcpAuthFilePath() {
17459
17528
  const configDir = process.env.VESSEL_CONFIG_DIR || path$1.join(
@@ -20281,7 +20350,15 @@ ${JSON.stringify(otherHighlights, null, 2)}`
20281
20350
  note: zod.z.string().optional().describe("Optional note about why this was bookmarked"),
20282
20351
  on_duplicate: zod.z.enum(["ask", "update", "duplicate"]).optional().describe(
20283
20352
  'How to handle an existing bookmark with the same URL in the same folder: "ask" (default), "update", or "duplicate"'
20284
- )
20353
+ ),
20354
+ intent: zod.z.string().optional().describe(
20355
+ "Human-readable description of what this bookmark is for"
20356
+ ),
20357
+ expected_content: zod.z.string().optional().describe(
20358
+ "Brief description of the content the agent should expect to find here"
20359
+ ),
20360
+ key_fields: zod.z.array(zod.z.string()).optional().describe("Important form field names for this page"),
20361
+ agent_hints: zod.z.record(zod.z.string(), zod.z.string()).optional().describe("Arbitrary key-value hints for the agent")
20285
20362
  }
20286
20363
  },
20287
20364
  async ({
@@ -20294,7 +20371,11 @@ ${JSON.stringify(otherHighlights, null, 2)}`
20294
20371
  folder_summary,
20295
20372
  create_folder_if_missing,
20296
20373
  note,
20297
- on_duplicate
20374
+ on_duplicate,
20375
+ intent,
20376
+ expected_content,
20377
+ key_fields,
20378
+ agent_hints
20298
20379
  }) => {
20299
20380
  return withAction(
20300
20381
  runtime2,
@@ -20309,7 +20390,11 @@ ${JSON.stringify(otherHighlights, null, 2)}`
20309
20390
  folder_name,
20310
20391
  folder_summary,
20311
20392
  create_folder_if_missing,
20312
- note
20393
+ note,
20394
+ intent,
20395
+ expected_content,
20396
+ key_fields,
20397
+ agent_hints
20313
20398
  },
20314
20399
  async () => {
20315
20400
  const currentTab = tabManager.getActiveTab();
@@ -20339,7 +20424,15 @@ ${JSON.stringify(otherHighlights, null, 2)}`
20339
20424
  source.title,
20340
20425
  target.folderId,
20341
20426
  note,
20342
- { onDuplicate: on_duplicate ?? "ask" }
20427
+ {
20428
+ onDuplicate: on_duplicate ?? "ask",
20429
+ extra: getBookmarkMetadataFromToolArgs({
20430
+ intent,
20431
+ expected_content,
20432
+ key_fields,
20433
+ agent_hints
20434
+ })
20435
+ }
20343
20436
  );
20344
20437
  if (result.status === "conflict" && result.existing) {
20345
20438
  return composeFolderAwareResponse(
@@ -20436,7 +20529,11 @@ ${JSON.stringify(otherHighlights, null, 2)}`
20436
20529
  folder_summary: zod.z.string().optional().describe("Optional summary used if a new folder is created"),
20437
20530
  create_folder_if_missing: zod.z.boolean().optional().describe("Create folder_name automatically when it does not exist"),
20438
20531
  note: zod.z.string().optional().describe("Optional note to attach or update on the bookmark"),
20439
- archive: zod.z.boolean().optional().describe('If true, organize into the default "Archive" folder')
20532
+ archive: zod.z.boolean().optional().describe('If true, organize into the default "Archive" folder'),
20533
+ intent: zod.z.string().optional().describe("Human-readable description of what this bookmark is for"),
20534
+ expected_content: zod.z.string().optional().describe("Brief description of content the agent should expect"),
20535
+ key_fields: zod.z.array(zod.z.string()).optional().describe("Important form field names for this page"),
20536
+ agent_hints: zod.z.record(zod.z.string(), zod.z.string()).optional().describe("Arbitrary key-value hints for the agent")
20440
20537
  }
20441
20538
  },
20442
20539
  async (args) => {
@@ -20472,7 +20569,8 @@ ${JSON.stringify(otherHighlights, null, 2)}`
20472
20569
  const updated = updateBookmark(existing.id, {
20473
20570
  folderId: target.folderId,
20474
20571
  title: typeof args.title === "string" && args.title.trim() ? args.title.trim() : void 0,
20475
- note
20572
+ note,
20573
+ ...getBookmarkMetadataFromToolArgs(args)
20476
20574
  });
20477
20575
  if (!updated) {
20478
20576
  return `Bookmark ${existing.id} not found`;
@@ -20483,12 +20581,18 @@ ${JSON.stringify(otherHighlights, null, 2)}`
20483
20581
  );
20484
20582
  }
20485
20583
  if ("error" in source) return `Error: ${source.error}`;
20486
- const bookmark = saveBookmark(
20584
+ const result = saveBookmarkWithPolicy(
20487
20585
  source.url,
20488
20586
  source.title,
20489
20587
  target.folderId,
20490
- note
20588
+ note,
20589
+ {
20590
+ onDuplicate: "update",
20591
+ extra: getBookmarkMetadataFromToolArgs(args)
20592
+ }
20491
20593
  );
20594
+ const bookmark = result.bookmark;
20595
+ if (!bookmark) return "Error: Bookmark save failed";
20492
20596
  return composeFolderAwareResponse(
20493
20597
  `Saved and organized "${bookmark.title}" (${bookmark.url}) into "${describeFolder(bookmark.folderId)}" (id=${bookmark.id})`,
20494
20598
  target.createdFolder
@@ -23344,14 +23448,21 @@ function registerIpcHandlers(windowState, runtime2) {
23344
23448
  Channels.BOOKMARK_SAVE,
23345
23449
  (_, url, title, folderId, note, intent, expectedContent, keyFields, agentHints) => {
23346
23450
  trackBookmarkAction("save");
23347
- return saveBookmarkWithPolicy(url, title, folderId, note, {
23451
+ const result = saveBookmarkWithPolicy(url, title, folderId, note, {
23452
+ onDuplicate: "update",
23348
23453
  extra: {
23349
- intent: intent?.trim() || void 0,
23350
- expectedContent: expectedContent?.trim() || void 0,
23351
- keyFields,
23352
- agentHints
23454
+ ...normalizeBookmarkMetadata({
23455
+ intent,
23456
+ expectedContent,
23457
+ keyFields,
23458
+ agentHints
23459
+ })
23353
23460
  }
23354
23461
  });
23462
+ if (!result.bookmark) {
23463
+ throw new Error("Bookmark save failed");
23464
+ }
23465
+ return result.bookmark;
23355
23466
  }
23356
23467
  );
23357
23468
  electron.ipcMain.handle(Channels.BOOKMARK_REMOVE, (_, id) => {