@hiai-gg/docsmint 2.1.4 → 2.1.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.
@@ -3,6 +3,7 @@ var __create = Object.create;
3
3
  var __getProtoOf = Object.getPrototypeOf;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  function __accessProp(key) {
8
9
  return this[key];
@@ -31,6 +32,23 @@ var __toESM = (mod, isNodeMode, target) => {
31
32
  cache.set(mod, to);
32
33
  return to;
33
34
  };
35
+ var __toCommonJS = (from) => {
36
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
37
+ if (entry)
38
+ return entry;
39
+ entry = __defProp({}, "__esModule", { value: true });
40
+ if (from && typeof from === "object" || typeof from === "function") {
41
+ for (var key of __getOwnPropNames(from))
42
+ if (!__hasOwnProp.call(entry, key))
43
+ __defProp(entry, key, {
44
+ get: __accessProp.bind(from, key),
45
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
46
+ });
47
+ }
48
+ __moduleCache.set(from, entry);
49
+ return entry;
50
+ };
51
+ var __moduleCache;
34
52
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
35
53
  var __returnValue = (v) => v;
36
54
  function __exportSetter(name, newValue) {
@@ -34846,6 +34864,153 @@ var require_browser = __commonJS(function(exports2, module2) {
34846
34864
  };
34847
34865
  });
34848
34866
 
34867
+ // ../../node_modules/.bun/supports-color@10.2.2/node_modules/supports-color/index.js
34868
+ var exports_supports_color = {};
34869
+ __export(exports_supports_color, {
34870
+ createSupportsColor: () => createSupportsColor,
34871
+ default: () => supports_color_default
34872
+ });
34873
+ import process2 from "process";
34874
+ import os2 from "os";
34875
+ import tty from "tty";
34876
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
34877
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
34878
+ const position = argv.indexOf(prefix + flag);
34879
+ const terminatorPosition = argv.indexOf("--");
34880
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
34881
+ }
34882
+ function envForceColor() {
34883
+ if (!("FORCE_COLOR" in env3)) {
34884
+ return;
34885
+ }
34886
+ if (env3.FORCE_COLOR === "true") {
34887
+ return 1;
34888
+ }
34889
+ if (env3.FORCE_COLOR === "false") {
34890
+ return 0;
34891
+ }
34892
+ if (env3.FORCE_COLOR.length === 0) {
34893
+ return 1;
34894
+ }
34895
+ const level = Math.min(Number.parseInt(env3.FORCE_COLOR, 10), 3);
34896
+ if (![0, 1, 2, 3].includes(level)) {
34897
+ return;
34898
+ }
34899
+ return level;
34900
+ }
34901
+ function translateLevel(level) {
34902
+ if (level === 0) {
34903
+ return false;
34904
+ }
34905
+ return {
34906
+ level,
34907
+ hasBasic: true,
34908
+ has256: level >= 2,
34909
+ has16m: level >= 3
34910
+ };
34911
+ }
34912
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
34913
+ const noFlagForceColor = envForceColor();
34914
+ if (noFlagForceColor !== undefined) {
34915
+ flagForceColor = noFlagForceColor;
34916
+ }
34917
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
34918
+ if (forceColor === 0) {
34919
+ return 0;
34920
+ }
34921
+ if (sniffFlags) {
34922
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
34923
+ return 3;
34924
+ }
34925
+ if (hasFlag("color=256")) {
34926
+ return 2;
34927
+ }
34928
+ }
34929
+ if ("TF_BUILD" in env3 && "AGENT_NAME" in env3) {
34930
+ return 1;
34931
+ }
34932
+ if (haveStream && !streamIsTTY && forceColor === undefined) {
34933
+ return 0;
34934
+ }
34935
+ const min = forceColor || 0;
34936
+ if (env3.TERM === "dumb") {
34937
+ return min;
34938
+ }
34939
+ if (process2.platform === "win32") {
34940
+ const osRelease = os2.release().split(".");
34941
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
34942
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
34943
+ }
34944
+ return 1;
34945
+ }
34946
+ if ("CI" in env3) {
34947
+ if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => (key in env3))) {
34948
+ return 3;
34949
+ }
34950
+ if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => (sign in env3)) || env3.CI_NAME === "codeship") {
34951
+ return 1;
34952
+ }
34953
+ return min;
34954
+ }
34955
+ if ("TEAMCITY_VERSION" in env3) {
34956
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env3.TEAMCITY_VERSION) ? 1 : 0;
34957
+ }
34958
+ if (env3.COLORTERM === "truecolor") {
34959
+ return 3;
34960
+ }
34961
+ if (env3.TERM === "xterm-kitty") {
34962
+ return 3;
34963
+ }
34964
+ if (env3.TERM === "xterm-ghostty") {
34965
+ return 3;
34966
+ }
34967
+ if (env3.TERM === "wezterm") {
34968
+ return 3;
34969
+ }
34970
+ if ("TERM_PROGRAM" in env3) {
34971
+ const version = Number.parseInt((env3.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
34972
+ switch (env3.TERM_PROGRAM) {
34973
+ case "iTerm.app": {
34974
+ return version >= 3 ? 3 : 2;
34975
+ }
34976
+ case "Apple_Terminal": {
34977
+ return 2;
34978
+ }
34979
+ }
34980
+ }
34981
+ if (/-256(color)?$/i.test(env3.TERM)) {
34982
+ return 2;
34983
+ }
34984
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env3.TERM)) {
34985
+ return 1;
34986
+ }
34987
+ if ("COLORTERM" in env3) {
34988
+ return 1;
34989
+ }
34990
+ return min;
34991
+ }
34992
+ function createSupportsColor(stream, options = {}) {
34993
+ const level = _supportsColor(stream, {
34994
+ streamIsTTY: stream && stream.isTTY,
34995
+ ...options
34996
+ });
34997
+ return translateLevel(level);
34998
+ }
34999
+ var env3, flagForceColor, supportsColor, supports_color_default;
35000
+ var init_supports_color = __esm(() => {
35001
+ ({ env: env3 } = process2);
35002
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
35003
+ flagForceColor = 0;
35004
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
35005
+ flagForceColor = 1;
35006
+ }
35007
+ supportsColor = {
35008
+ stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
35009
+ stderr: createSupportsColor({ isTTY: tty.isatty(2) })
35010
+ };
35011
+ supports_color_default = supportsColor;
35012
+ });
35013
+
34849
35014
  // ../../node_modules/.bun/debug@4.4.3/node_modules/debug/src/node.js
34850
35015
  var require_node = __commonJS(function(exports2, module2) {
34851
35016
  var tty = __require("tty");
@@ -34859,7 +35024,7 @@ var require_node = __commonJS(function(exports2, module2) {
34859
35024
  exports2.destroy = util.deprecate(() => {}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
34860
35025
  exports2.colors = [6, 2, 3, 4, 5, 1];
34861
35026
  try {
34862
- const supportsColor = (()=>{throw new Error("Cannot require module "+"supports-color");})();
35027
+ const supportsColor = (init_supports_color(), __toCommonJS(exports_supports_color));
34863
35028
  if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
34864
35029
  exports2.colors = [
34865
35030
  20,
@@ -43940,6 +44105,7 @@ __export(exports_schema, {
43940
44105
  documentVisibilityEnum: () => documentVisibilityEnum,
43941
44106
  documents: () => documents,
43942
44107
  embeddingStatusEnum: () => embeddingStatusEnum,
44108
+ folderCreateOperations: () => folderCreateOperations,
43943
44109
  folderRelations: () => folderRelations,
43944
44110
  folders: () => folders,
43945
44111
  guestAccess: () => guestAccess,
@@ -43965,7 +44131,7 @@ __export(exports_schema, {
43965
44131
  versionRelations: () => versionRelations,
43966
44132
  versions: () => versions
43967
44133
  });
43968
- var vector4, tsvector, documentVisibilityEnum, shareRoleEnum, shareAccessModeEnum, shareGrantStatusEnum, embeddingStatusEnum, pipelineStageEnum, pipelineStatusEnum, lifecycleOperationKindEnum, lifecycleOperationStatusEnum, users, sessions, accounts, verifications, folders, folderRelations, documents, documentRelations, documentPipelineRuns, documentPipelineBatches, metadataReembedOutbox, documentKnowledgeSummaries, tags, tagRelations, categories, categoryRelations, documentTags, documentTagRelations, shareLinks, shareLinkRelations, guestAccess, guestAccessRelations, attachments, pendingAttachmentUploads, attachmentStorageCleanupOutbox, pendingAttachmentCleanupAuthorizations, attachmentRelations, versions, documentEmbeddings, documentEmbeddingRelations, apiKeys, apiKeyRelations, auditLog, lifecycleOperations, documentCreateOperations, versionRelations;
44134
+ var vector4, tsvector, documentVisibilityEnum, shareRoleEnum, shareAccessModeEnum, shareGrantStatusEnum, embeddingStatusEnum, pipelineStageEnum, pipelineStatusEnum, lifecycleOperationKindEnum, lifecycleOperationStatusEnum, users, sessions, accounts, verifications, folders, folderRelations, documents, documentRelations, documentPipelineRuns, documentPipelineBatches, metadataReembedOutbox, documentKnowledgeSummaries, tags, tagRelations, categories, categoryRelations, documentTags, documentTagRelations, shareLinks, shareLinkRelations, guestAccess, guestAccessRelations, attachments, pendingAttachmentUploads, attachmentStorageCleanupOutbox, pendingAttachmentCleanupAuthorizations, attachmentRelations, versions, documentEmbeddings, documentEmbeddingRelations, apiKeys, apiKeyRelations, auditLog, lifecycleOperations, documentCreateOperations, folderCreateOperations, versionRelations;
43969
44135
  var init_schema2 = __esm(() => {
43970
44136
  init_pg_core();
43971
44137
  init_drizzle_orm();
@@ -44590,6 +44756,18 @@ var init_schema2 = __esm(() => {
44590
44756
  uniqueIndex("document_create_operations_workspace_actor_key_idx").on(table.workspaceId, table.actorUserId, table.idempotencyKey),
44591
44757
  uniqueIndex("document_create_operations_document_idx").on(table.documentId)
44592
44758
  ]);
44759
+ folderCreateOperations = pgTable("folder_create_operations", {
44760
+ id: uuid("id").primaryKey().defaultRandom(),
44761
+ workspaceId: text("workspace_id").notNull(),
44762
+ actorUserId: uuid("actor_user_id").notNull().references(() => users.id, { onDelete: "cascade" }),
44763
+ idempotencyKey: text("idempotency_key").notNull(),
44764
+ folderId: uuid("folder_id").notNull(),
44765
+ requestFingerprint: text("request_fingerprint").notNull(),
44766
+ createdAt: timestamp("created_at").defaultNow().notNull()
44767
+ }, (table) => [
44768
+ uniqueIndex("folder_create_operations_workspace_actor_key_unique").on(table.workspaceId, table.actorUserId, table.idempotencyKey),
44769
+ uniqueIndex("folder_create_operations_folder_idx").on(table.folderId)
44770
+ ]);
44593
44771
  versionRelations = relations(versions, ({ one }) => ({
44594
44772
  document: one(documents, {
44595
44773
  fields: [versions.documentId],
@@ -50310,6 +50488,9 @@ function ipv42(params) {
50310
50488
  function ipv62(params) {
50311
50489
  return _ipv6(ZodIPv6, params);
50312
50490
  }
50491
+ function base642(params) {
50492
+ return _base64(ZodBase64, params);
50493
+ }
50313
50494
  function number2(params) {
50314
50495
  return _number(ZodNumber, params);
50315
50496
  }
@@ -51473,10 +51654,10 @@ function getBooleanEnvVar(key, fallback = true) {
51473
51654
  return fallback;
51474
51655
  return value !== "0" && value.toLowerCase() !== "false" && value !== "";
51475
51656
  }
51476
- var _envShim, _getEnv = (useShim) => globalThis.process?.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (useShim ? _envShim : globalThis), env4, nodeENV, isProduction2, isDevelopment = () => nodeENV === "dev" || nodeENV === "development", isTest = () => nodeENV === "test" || toBoolean(env4.TEST), ENV;
51657
+ var _envShim, _getEnv = (useShim) => globalThis.process?.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (useShim ? _envShim : globalThis), env5, nodeENV, isProduction2, isDevelopment = () => nodeENV === "dev" || nodeENV === "development", isTest = () => nodeENV === "test" || toBoolean(env5.TEST), ENV;
51477
51658
  var init_env_impl = __esm(() => {
51478
51659
  _envShim = Object.create(null);
51479
- env4 = new Proxy(_envShim, {
51660
+ env5 = new Proxy(_envShim, {
51480
51661
  get(_, prop) {
51481
51662
  return _getEnv()[prop] ?? _envShim[prop];
51482
51663
  },
@@ -51500,7 +51681,7 @@ var init_env_impl = __esm(() => {
51500
51681
  return Object.keys(env2);
51501
51682
  }
51502
51683
  });
51503
- nodeENV = env4.NODE_ENV ?? "";
51684
+ nodeENV = env5.NODE_ENV ?? "";
51504
51685
  isProduction2 = nodeENV === "production";
51505
51686
  ENV = Object.freeze({
51506
51687
  get BETTER_AUTH_SECRET() {
@@ -51546,17 +51727,17 @@ function getColorDepth() {
51546
51727
  return COLORS_2;
51547
51728
  if (getEnvVar("TMUX"))
51548
51729
  return COLORS_16m;
51549
- if ("TF_BUILD" in env4 && "AGENT_NAME" in env4)
51730
+ if ("TF_BUILD" in env5 && "AGENT_NAME" in env5)
51550
51731
  return COLORS_16;
51551
- if ("CI" in env4) {
51732
+ if ("CI" in env5) {
51552
51733
  for (const { 0: envName, 1: colors } of CI_ENVS_MAP)
51553
- if (envName in env4)
51734
+ if (envName in env5)
51554
51735
  return colors;
51555
51736
  if (getEnvVar("CI_NAME") === "codeship")
51556
51737
  return COLORS_256;
51557
51738
  return COLORS_2;
51558
51739
  }
51559
- if ("TEAMCITY_VERSION" in env4)
51740
+ if ("TEAMCITY_VERSION" in env5)
51560
51741
  return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(getEnvVar("TEAMCITY_VERSION")) !== null ? COLORS_16 : COLORS_2;
51561
51742
  switch (getEnvVar("TERM_PROGRAM")) {
51562
51743
  case "iTerm.app":
@@ -52674,10 +52855,10 @@ function base64Decode(data, alphabet) {
52674
52855
  }
52675
52856
  return Uint8Array.from(result);
52676
52857
  }
52677
- var base642, base64Url;
52858
+ var base643, base64Url;
52678
52859
  var init_base64 = __esm(() => {
52679
52860
  init_bytes();
52680
- base642 = {
52861
+ base643 = {
52681
52862
  encode(data, options = {}) {
52682
52863
  const alphabet = getAlphabet(false);
52683
52864
  return base64Encode(toUint8Array3(data), alphabet, options.padding ?? true);
@@ -152225,7 +152406,7 @@ for(const [k,v] of c.request.headers.entries())c.headers[k]=v
152225
152406
  };
152226
152407
 
152227
152408
  // ../../node_modules/.bun/elysia@1.4.30+867b8e1835835193/node_modules/elysia/dist/universal/env.mjs
152228
- var env3 = isBun ? Bun.env : typeof process < "u" && process?.env ? process.env : {};
152409
+ var env4 = isBun ? Bun.env : typeof process < "u" && process?.env ? process.env : {};
152229
152410
 
152230
152411
  // ../../node_modules/.bun/elysia@1.4.30+867b8e1835835193/node_modules/elysia/dist/dynamic-handle.mjs
152231
152412
  var ARRAY_INDEX_REGEX = /^(.+)\[(\d+)\]$/;
@@ -152787,7 +152968,7 @@ var _Elysia = class _Elysia {
152787
152968
  config.tags && (config.detail ? config.detail.tags = config.tags : config.detail = {
152788
152969
  tags: config.tags
152789
152970
  }), this.config = {
152790
- aot: env3.ELYSIA_AOT !== "false",
152971
+ aot: env4.ELYSIA_AOT !== "false",
152791
152972
  nativeStaticResponse: true,
152792
152973
  encodeSchema: true,
152793
152974
  normalize: true,
@@ -152827,7 +153008,7 @@ var _Elysia = class _Elysia {
152827
153008
  get promisedModules() {
152828
153009
  return this._promisedModules || (this._promisedModules = new PromiseGroup(console.error, () => {})), this._promisedModules;
152829
153010
  }
152830
- env(model, _env = env3) {
153011
+ env(model, _env = env4) {
152831
153012
  if (getSchemaValidator(model, {
152832
153013
  modules: this.definitions.typebox,
152833
153014
  dynamic: true,
@@ -156309,7 +156490,7 @@ init_drizzle_orm();
156309
156490
  init_schema2();
156310
156491
 
156311
156492
  // ../../node_modules/.bun/postgres@3.4.9/node_modules/postgres/src/index.js
156312
- import os2 from "os";
156493
+ import os3 from "os";
156313
156494
  import fs3 from "fs";
156314
156495
 
156315
156496
  // ../../node_modules/.bun/postgres@3.4.9/node_modules/postgres/src/query.js
@@ -158272,7 +158453,7 @@ function parseUrl4(url) {
158272
158453
  }
158273
158454
  function osUsername() {
158274
158455
  try {
158275
- return os2.userInfo().username;
158456
+ return os3.userInfo().username;
158276
158457
  } catch (_) {
158277
158458
  return process.env.USERNAME || process.env.USER || process.env.LOGNAME;
158278
158459
  }
@@ -160595,7 +160776,7 @@ function getBaseURL(url, path, request, loadEnv, trustedProxyHeaders) {
160595
160776
  if (url)
160596
160777
  return withPath(url, path);
160597
160778
  if (loadEnv !== false) {
160598
- const fromEnv = env4.BETTER_AUTH_URL || env4.NEXT_PUBLIC_BETTER_AUTH_URL || env4.PUBLIC_BETTER_AUTH_URL || env4.NUXT_PUBLIC_BETTER_AUTH_URL || env4.NUXT_PUBLIC_AUTH_URL || (env4.BASE_URL !== "/" ? env4.BASE_URL : undefined);
160779
+ const fromEnv = env5.BETTER_AUTH_URL || env5.NEXT_PUBLIC_BETTER_AUTH_URL || env5.PUBLIC_BETTER_AUTH_URL || env5.NUXT_PUBLIC_BETTER_AUTH_URL || env5.NUXT_PUBLIC_AUTH_URL || (env5.BASE_URL !== "/" ? env5.BASE_URL : undefined);
160599
160780
  if (fromEnv)
160600
160781
  return withPath(fromEnv, path);
160601
160782
  }
@@ -165772,7 +165953,7 @@ var createHMAC = (algorithm = "SHA-256", encoding = "none") => {
165772
165953
  if (encoding === "hex")
165773
165954
  return hex.encode(signature);
165774
165955
  if (encoding === "base64")
165775
- return base642.encode(signature);
165956
+ return base643.encode(signature);
165776
165957
  if (encoding === "base64url" || encoding === "base64urlnopad")
165777
165958
  return base64Url.encode(signature, { padding: encoding !== "base64urlnopad" });
165778
165959
  return signature;
@@ -165783,7 +165964,7 @@ var createHMAC = (algorithm = "SHA-256", encoding = "none") => {
165783
165964
  if (encoding === "hex")
165784
165965
  signature = typeof signature === "string" ? hex.toBytes(signature) : signature;
165785
165966
  if (encoding === "base64" || encoding === "base64url" || encoding === "base64urlnopad")
165786
- signature = await base642.decode(signature);
165967
+ signature = await base643.decode(signature);
165787
165968
  return getWebcryptoSubtle().verify("HMAC", hmacKey, toBufferSource(signature), toBufferSource(data));
165788
165969
  }
165789
165970
  };
@@ -166509,7 +166690,7 @@ function createHash4(algorithm, encoding) {
166509
166690
  if (encoding === "base64" || encoding === "base64url" || encoding === "base64urlnopad") {
166510
166691
  if (encoding.includes("url"))
166511
166692
  return base64Url.encode(hashBuffer, { padding: encoding !== "base64urlnopad" });
166512
- return base642.encode(hashBuffer);
166693
+ return base643.encode(hashBuffer);
166513
166694
  }
166514
166695
  return hashBuffer;
166515
166696
  } };
@@ -168118,7 +168299,7 @@ async function getTrustedOrigins(options, request) {
168118
168299
  trustedOrigins.push(...validOrigins);
168119
168300
  }
168120
168301
  }
168121
- const envTrustedOrigins = env4.BETTER_AUTH_TRUSTED_ORIGINS;
168302
+ const envTrustedOrigins = env5.BETTER_AUTH_TRUSTED_ORIGINS;
168122
168303
  if (envTrustedOrigins)
168123
168304
  trustedOrigins.push(...envTrustedOrigins.split(","));
168124
168305
  return trustedOrigins.filter((v) => Boolean(v));
@@ -169700,7 +169881,7 @@ function formUrlEncode(value) {
169700
169881
  }
169701
169882
  function encodeBasicCredentials(clientId, clientSecret) {
169702
169883
  const payload = `${formUrlEncode(clientId)}:${formUrlEncode(clientSecret)}`;
169703
- return `Basic ${base642.encode(payload)}`;
169884
+ return `Basic ${base643.encode(payload)}`;
169704
169885
  }
169705
169886
 
169706
169887
  // ../../node_modules/.bun/@better-auth+core@1.7.15+1bcdd7fa41f3b4db/node_modules/@better-auth/core/dist/oauth2/client-assertion.mjs
@@ -172883,7 +173064,7 @@ var microsoft = (options) => {
172883
173064
  return;
172884
173065
  try {
172885
173066
  const pictureBuffer = await context.response.clone().arrayBuffer();
172886
- const pictureBase64 = base642.encode(pictureBuffer);
173067
+ const pictureBase64 = base643.encode(pictureBuffer);
172887
173068
  user.picture = `data:image/jpeg;base64, ${pictureBase64}`;
172888
173069
  } catch (e) {
172889
173070
  logger2.error(e && typeof e === "object" && "name" in e ? e.name : "", e);
@@ -178431,7 +178612,7 @@ init_internal();
178431
178612
  init_env();
178432
178613
  import fs4 from "fs";
178433
178614
  import fsPromises2 from "fs/promises";
178434
- import os3 from "os";
178615
+ import os4 from "os";
178435
178616
  import path from "path";
178436
178617
  init_base64();
178437
178618
  init_random();
@@ -178623,7 +178804,7 @@ async function getTelemetryAuthConfig(options, context) {
178623
178804
  };
178624
178805
  }
178625
178806
  function detectPackageManager() {
178626
- const userAgent = env4.npm_config_user_agent;
178807
+ const userAgent = env5.npm_config_user_agent;
178627
178808
  if (!userAgent)
178628
178809
  return;
178629
178810
  const pmSpec = userAgent.split(" ")[0];
@@ -178635,7 +178816,7 @@ function detectPackageManager() {
178635
178816
  };
178636
178817
  }
178637
178818
  function isCI() {
178638
- return env4.CI !== "false" && (("BUILD_ID" in env4) || ("BUILD_NUMBER" in env4) || ("CI" in env4) || ("CI_APP_ID" in env4) || ("CI_BUILD_ID" in env4) || ("CI_BUILD_NUMBER" in env4) || ("CI_NAME" in env4) || ("CONTINUOUS_INTEGRATION" in env4) || ("RUN_ID" in env4));
178819
+ return env5.CI !== "false" && (("BUILD_ID" in env5) || ("BUILD_NUMBER" in env5) || ("CI" in env5) || ("CI_APP_ID" in env5) || ("CI_BUILD_ID" in env5) || ("CI_BUILD_NUMBER" in env5) || ("CI_NAME" in env5) || ("CONTINUOUS_INTEGRATION" in env5) || ("RUN_ID" in env5));
178639
178820
  }
178640
178821
  function detectRuntime() {
178641
178822
  if (typeof Deno !== "undefined")
@@ -178663,7 +178844,7 @@ function detectEnvironment() {
178663
178844
  }
178664
178845
  async function hashToBase64(data) {
178665
178846
  const buffer = await createHash4("SHA-256").digest(data);
178666
- return base642.encode(buffer);
178847
+ return base643.encode(buffer);
178667
178848
  }
178668
178849
  var generateId2 = (size) => {
178669
178850
  return createRandomStringGenerator("a-z", "A-Z", "0-9")(size || 32);
@@ -178709,16 +178890,16 @@ async function getNameFromLocalPackageJson() {
178709
178890
  }
178710
178891
  async function detectSystemInfo() {
178711
178892
  try {
178712
- const cpus = os3.cpus();
178893
+ const cpus = os4.cpus();
178713
178894
  return {
178714
178895
  deploymentVendor: getVendor(),
178715
- systemPlatform: os3.platform(),
178716
- systemRelease: os3.release(),
178717
- systemArchitecture: os3.arch(),
178896
+ systemPlatform: os4.platform(),
178897
+ systemRelease: os4.release(),
178898
+ systemArchitecture: os4.arch(),
178718
178899
  cpuCount: cpus.length,
178719
178900
  cpuModel: cpus.length ? cpus[0].model : null,
178720
178901
  cpuSpeed: cpus.length ? cpus[0].speed : null,
178721
- memory: os3.totalmem(),
178902
+ memory: os4.totalmem(),
178722
178903
  isWSL: await isWsl(),
178723
178904
  isDocker: await isDocker(),
178724
178905
  isTTY: process.stdout ? process.stdout.isTTY : null
@@ -178808,7 +178989,7 @@ async function isWsl() {
178808
178989
  try {
178809
178990
  if (process.platform !== "linux")
178810
178991
  return false;
178811
- if (os3.release().toLowerCase().includes("microsoft")) {
178992
+ if (os4.release().toLowerCase().includes("microsoft")) {
178812
178993
  if (await isInsideContainer())
178813
178994
  return false;
178814
178995
  return true;
@@ -178978,8 +179159,8 @@ async function createAuthContext(adapter, options, getDatabaseType) {
178978
179159
  You are using the memory DB with generateId: false.
178979
179160
  This will cause no id to be generated for any model.
178980
179161
  Most of the features of Better Auth will not work correctly.`);
178981
- const secretsArray = options.secrets ?? parseSecretsEnv(env4.BETTER_AUTH_SECRETS);
178982
- const legacySecret = options.secret || env4.BETTER_AUTH_SECRET || env4.AUTH_SECRET || "";
179162
+ const secretsArray = options.secrets ?? parseSecretsEnv(env5.BETTER_AUTH_SECRETS);
179163
+ const legacySecret = options.secret || env5.BETTER_AUTH_SECRET || env5.AUTH_SECRET || "";
178983
179164
  let secret;
178984
179165
  let secretConfig;
178985
179166
  if (secretsArray) {
@@ -186589,7 +186770,7 @@ var getVariable = (name) => isNode2 ? undefinedToNull(process.env[name.toUpperCa
186589
186770
  var hasConf = (name) => hasParam("--" + name) || getVariable(name) !== null;
186590
186771
  var production = hasConf("production");
186591
186772
  var forceColor = isNode2 && isOneOf(process.env.FORCE_COLOR, ["true", "1", "2"]);
186592
- var supportsColor = forceColor || !hasParam("--no-colors") && !hasConf("no-color") && (!isNode2 || process.stdout.isTTY) && (!isNode2 || hasParam("--color") || getVariable("COLORTERM") !== null || (getVariable("TERM") || "").includes("color"));
186773
+ var supportsColor2 = forceColor || !hasParam("--no-colors") && !hasConf("no-color") && (!isNode2 || process.stdout.isTTY) && (!isNode2 || hasParam("--color") || getVariable("COLORTERM") !== null || (getVariable("TERM") || "").includes("color"));
186593
186774
 
186594
186775
  // ../../node_modules/.bun/lib0@0.2.117/node_modules/lib0/buffer.js
186595
186776
  var createUint8ArrayFromLen = (len) => new Uint8Array(len);
@@ -187187,7 +187368,7 @@ var computeBrowserLoggingArgs = (args) => {
187187
187368
  }
187188
187369
  return logArgs;
187189
187370
  };
187190
- var computeLoggingArgs = supportsColor ? computeBrowserLoggingArgs : computeNoColorLoggingArgs;
187371
+ var computeLoggingArgs = supportsColor2 ? computeBrowserLoggingArgs : computeNoColorLoggingArgs;
187191
187372
  var print = (...args) => {
187192
187373
  console.log(...computeLoggingArgs(args));
187193
187374
  vconsoles.forEach((vc) => vc.print(args));
@@ -213665,6 +213846,8 @@ var listQuerySchema2 = documentListQuerySchema;
213665
213846
  var cursorListQuerySchema = object({
213666
213847
  ...documentListQueryFields,
213667
213848
  cursor: string2().min(1).optional(),
213849
+ view: _enum(["catalog"]).optional(),
213850
+ includeTotal: _enum(["true", "false"]).optional(),
213668
213851
  limit: exports_coerce.number().int().min(1).max(100).default(50),
213669
213852
  sortBy: _enum([
213670
213853
  "title",
@@ -213995,28 +214178,49 @@ var documentRoutes = new Elysia({ prefix: "/api" }).get("/documents", async ({ q
213995
214178
  }
213996
214179
  }
213997
214180
  try {
213998
- const [countResult, rows] = await withTenant(ctx, (tx) => Promise.all([
213999
- tx.select({ total: count() }).from(documents).where(and(...filteredConditions)),
214000
- tx.select({
214181
+ const includeTotal = parsed.data.includeTotal !== "false";
214182
+ const joinedSort = sortBy === "category" || sortBy === "folder";
214183
+ const [countResult, rows] = await withTenant(ctx, (tx) => {
214184
+ const projection = {
214001
214185
  id: documents.id,
214002
214186
  title: documents.title,
214003
214187
  content: sql`LEFT(${documents.content}, 200)`.as("content"),
214004
214188
  folderId: documents.folderId,
214005
- folderName: folders.name,
214006
214189
  categoryId: documents.categoryId,
214007
- effectiveCategoryId: effectiveDocumentCategoryValue(documents.categoryId, documents.folderId, ctx).as("effective_category_id"),
214008
- categoryName: categories.name,
214190
+ effectiveCategoryId: (effectiveCategoryId ? sql`${effectiveCategoryId}::uuid` : effectiveDocumentCategoryValue(documents.categoryId, documents.folderId, ctx)).as("effective_category_id"),
214009
214191
  createdAt: documents.createdAt,
214010
214192
  updatedAt: documents.updatedAt
214011
- }).from(documents).leftJoin(folders, eq(folders.id, documents.folderId)).leftJoin(categories, eq(categories.id, documents.categoryId)).where(and(...conditions)).orderBy(sortOrder === "asc" ? sql`${sortValue} asc nulls last` : sql`${sortValue} desc nulls last`, sortOrder === "asc" ? asc(documents.id) : desc(documents.id)).limit(limit + 1)
214012
- ]));
214193
+ };
214194
+ const order = [
214195
+ sortOrder === "asc" ? sql`${sortValue} asc nulls last` : sql`${sortValue} desc nulls last`,
214196
+ sortOrder === "asc" ? asc(documents.id) : desc(documents.id)
214197
+ ];
214198
+ const selected = tx.select(projection).from(documents).where(and(...conditions)).orderBy(...order).limit(limit + 1);
214199
+ const pageQuery = joinedSort ? tx.select({
214200
+ ...projection,
214201
+ folderName: folders.name,
214202
+ categoryName: categories.name
214203
+ }).from(documents).leftJoin(folders, eq(folders.id, documents.folderId)).leftJoin(categories, eq(categories.id, documents.categoryId)).where(and(...conditions)).orderBy(...order).limit(limit + 1) : selected;
214204
+ return Promise.all([
214205
+ includeTotal ? tx.select({ total: count() }).from(documents).where(and(...filteredConditions)) : Promise.resolve([]),
214206
+ pageQuery
214207
+ ]);
214208
+ });
214013
214209
  const hasMore = rows.length > limit;
214014
214210
  const page = rows.slice(0, limit);
214015
214211
  const last = page.at(-1);
214016
- const lastValue = last ? sortBy === "title" ? last.title.toLocaleLowerCase() : sortBy === "category" ? last.categoryName?.toLocaleLowerCase() ?? null : sortBy === "folder" ? last.folderName?.toLocaleLowerCase() ?? null : new Date(sortBy === "createdAt" ? last.createdAt : last.updatedAt).toISOString() : null;
214212
+ const lastValue = last ? sortBy === "title" ? last.title.toLocaleLowerCase() : sortBy === "category" ? ("categoryName" in last ? last.categoryName : null)?.toLocaleLowerCase() ?? null : sortBy === "folder" ? ("folderName" in last ? last.folderName : null)?.toLocaleLowerCase() ?? null : new Date(sortBy === "createdAt" ? last.createdAt : last.updatedAt).toISOString() : null;
214213
+ const compact = parsed.data.view === "catalog";
214214
+ const items = (await withDocumentLocationNames(ctx, compact ? page : await withTags(ctx, page))).map((row) => withDocumentPreview(row, ctx.workspaceId, config3.PUBLIC_APP_URL));
214017
214215
  return {
214018
- total: countResult[0]?.total ?? 0,
214019
- items: (await withDocumentLocationNames(ctx, await withTags(ctx, page))).map((row) => withDocumentPreview(row, ctx.workspaceId, config3.PUBLIC_APP_URL)),
214216
+ ...includeTotal ? { total: countResult[0]?.total ?? 0 } : {},
214217
+ items: compact ? items.map(({ id, title, preview, folderId, folderName }) => ({
214218
+ id,
214219
+ title,
214220
+ preview,
214221
+ folderId,
214222
+ folderName
214223
+ })) : items,
214020
214224
  nextCursor: hasMore && last ? encodeDocumentCursor({
214021
214225
  v: 2,
214022
214226
  sortBy,
@@ -215850,6 +216054,7 @@ var documentRoutes = new Elysia({ prefix: "/api" }).get("/documents", async ({ q
215850
216054
  // ../../backend/src/api/routes/folders.ts
215851
216055
  init_schema2();
215852
216056
  init_drizzle_orm();
216057
+ import { createHash as createHash8 } from "crypto";
215853
216058
  init_zod();
215854
216059
 
215855
216060
  // ../../backend/src/lib/folder-name.ts
@@ -216115,6 +216320,12 @@ var folderRoutes = new Elysia({ prefix: "/api/folders" }).get("/:id", async ({ p
216115
216320
  set.status = 400;
216116
216321
  return { error: "Invalid input", details: parsed.error.flatten() };
216117
216322
  }
216323
+ const idempotencyKey = documentCreateIdempotencyKey(request);
216324
+ if (idempotencyKey === "invalid") {
216325
+ set.status = 400;
216326
+ return { error: "Invalid Idempotency-Key" };
216327
+ }
216328
+ const workspaceIdentity = documentCreateWorkspaceIdentity(userId, ctx.workspaceId);
216118
216329
  try {
216119
216330
  const created = await withTenant(ctx, async (tx) => {
216120
216331
  await acquireTenantTopologyLock(tx, ctx);
@@ -216136,6 +216347,23 @@ var folderRoutes = new Elysia({ prefix: "/api/folders" }).get("/:id", async ({ p
216136
216347
  return { categoryNotFound: true };
216137
216348
  }
216138
216349
  }
216350
+ const requestFingerprint = createHash8("sha256").update(JSON.stringify([parsed.data.name, parentId, categoryId])).digest("hex");
216351
+ if (idempotencyKey) {
216352
+ const [operation] = await tx.select().from(folderCreateOperations).where(and(eq(folderCreateOperations.workspaceId, workspaceIdentity), eq(folderCreateOperations.actorUserId, userId), eq(folderCreateOperations.idempotencyKey, idempotencyKey))).limit(1);
216353
+ if (operation) {
216354
+ if (operation.requestFingerprint !== requestFingerprint) {
216355
+ return { idempotencyConflict: true };
216356
+ }
216357
+ const [row] = await tx.select().from(folders).where(and(eq(folders.id, operation.folderId), tenantOwnerCondition(folders.ownerId, folders.workspaceId, ctx))).limit(1);
216358
+ if (!row)
216359
+ return { idempotencyConflict: true };
216360
+ const currentCategory = await resolveFolderEffectiveCategory(tx, ctx, row.id);
216361
+ if (!isAuthorizedCategory(access, currentCategory ?? null)) {
216362
+ return { forbidden: true };
216363
+ }
216364
+ return { row, replay: true };
216365
+ }
216366
+ }
216139
216367
  const scopeKey = parentId ? `${userId}:parent:${parentId}` : `${userId}:category:${categoryId ?? "none"}`;
216140
216368
  await tx.execute(sql`SELECT pg_advisory_xact_lock(hashtextextended(${scopeKey}, 0))`);
216141
216369
  const scopeConditions = [
@@ -216155,8 +216383,25 @@ var folderRoutes = new Elysia({ prefix: "/api/folders" }).get("/:id", async ({ p
216155
216383
  parentId,
216156
216384
  categoryId
216157
216385
  }).returning();
216386
+ if (!row)
216387
+ throw new Error("Folder insert returned no row");
216388
+ if (idempotencyKey) {
216389
+ await tx.insert(folderCreateOperations).values({
216390
+ workspaceId: workspaceIdentity,
216391
+ actorUserId: userId,
216392
+ idempotencyKey,
216393
+ folderId: row.id,
216394
+ requestFingerprint
216395
+ });
216396
+ }
216158
216397
  return { row };
216159
216398
  });
216399
+ if ("idempotencyConflict" in created) {
216400
+ set.status = 409;
216401
+ return {
216402
+ error: "Folder creation request conflicts with a previous operation"
216403
+ };
216404
+ }
216160
216405
  if ("notFound" in created) {
216161
216406
  set.status = 404;
216162
216407
  return { error: "Parent folder not found" };
@@ -216169,7 +216414,7 @@ var folderRoutes = new Elysia({ prefix: "/api/folders" }).get("/:id", async ({ p
216169
216414
  set.status = 404;
216170
216415
  return { error: "Category not found" };
216171
216416
  }
216172
- set.status = 201;
216417
+ set.status = "replay" in created ? 200 : 201;
216173
216418
  return created.row;
216174
216419
  } catch (err) {
216175
216420
  const purgeFence = translateAccountPurgeFencedError(err, set);
@@ -217075,6 +217320,12 @@ class DocsClient {
217075
217320
  }, context);
217076
217321
  }
217077
217322
  async listDocuments(options = {}, context) {
217323
+ return this.listDocumentCursor(options, context);
217324
+ }
217325
+ async listCatalogDocuments(options = {}, context) {
217326
+ return this.listDocumentCursor(options, context, "catalog");
217327
+ }
217328
+ async listDocumentCursor(options, context, view) {
217078
217329
  return this.request("GET", "/api/documents/cursor", {
217079
217330
  query: this.cleanQuery({
217080
217331
  categoryId: options.categoryId,
@@ -217089,6 +217340,8 @@ class DocsClient {
217089
217340
  updatedTo: options.updatedTo,
217090
217341
  cursor: options.cursor,
217091
217342
  limit: options.limit,
217343
+ view,
217344
+ includeTotal: options.includeTotal === undefined ? undefined : String(options.includeTotal),
217092
217345
  sortBy: options.sortBy,
217093
217346
  sortOrder: options.sortOrder
217094
217347
  })
@@ -217299,6 +217552,12 @@ class DocsClient {
217299
217552
  async listAttachments(documentId, context) {
217300
217553
  return this.request("GET", `/api/documents/${encodeURIComponent(documentId)}/attachments`, undefined, context);
217301
217554
  }
217555
+ async fetchAttachment(id, context) {
217556
+ const response = await this.fetchRaw("GET", `/api/attachments/${encodeURIComponent(id)}/raw`, {}, context);
217557
+ if (!response.ok)
217558
+ throw await this.toApiError(response);
217559
+ return response;
217560
+ }
217302
217561
  async deleteAttachment(id, context) {
217303
217562
  await this.request("DELETE", `/api/attachments/${encodeURIComponent(id)}`, undefined, context);
217304
217563
  }
@@ -217569,7 +217828,7 @@ var RESOURCE_PERMISSIONS2 = new Set([
217569
217828
  // ../../node_modules/.bun/@modelcontextprotocol+server@2.3.0/node_modules/@modelcontextprotocol/server/dist/chunk-Br0eD_fh.mjs
217570
217829
  var __create2 = Object.create;
217571
217830
  var __defProp3 = Object.defineProperty;
217572
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
217831
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
217573
217832
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
217574
217833
  var __getProtoOf2 = Object.getPrototypeOf;
217575
217834
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
@@ -217594,7 +217853,7 @@ var __copyProps = (to, from, except, desc) => {
217594
217853
  if (!__hasOwnProp2.call(to, key) && key !== except) {
217595
217854
  __defProp3(to, key, {
217596
217855
  get: ((k) => from[k]).bind(null, key),
217597
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
217856
+ enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable
217598
217857
  });
217599
217858
  }
217600
217859
  }
@@ -234297,6 +234556,12 @@ class DocsClient2 {
234297
234556
  }, context);
234298
234557
  }
234299
234558
  async listDocuments(options = {}, context) {
234559
+ return this.listDocumentCursor(options, context);
234560
+ }
234561
+ async listCatalogDocuments(options = {}, context) {
234562
+ return this.listDocumentCursor(options, context, "catalog");
234563
+ }
234564
+ async listDocumentCursor(options, context, view) {
234300
234565
  return this.request("GET", "/api/documents/cursor", {
234301
234566
  query: this.cleanQuery({
234302
234567
  categoryId: options.categoryId,
@@ -234311,6 +234576,8 @@ class DocsClient2 {
234311
234576
  updatedTo: options.updatedTo,
234312
234577
  cursor: options.cursor,
234313
234578
  limit: options.limit,
234579
+ view,
234580
+ includeTotal: options.includeTotal === undefined ? undefined : String(options.includeTotal),
234314
234581
  sortBy: options.sortBy,
234315
234582
  sortOrder: options.sortOrder
234316
234583
  })
@@ -234521,6 +234788,12 @@ class DocsClient2 {
234521
234788
  async listAttachments(documentId, context) {
234522
234789
  return this.request("GET", `/api/documents/${encodeURIComponent(documentId)}/attachments`, undefined, context);
234523
234790
  }
234791
+ async fetchAttachment(id, context) {
234792
+ const response = await this.fetchRaw("GET", `/api/attachments/${encodeURIComponent(id)}/raw`, {}, context);
234793
+ if (!response.ok)
234794
+ throw await this.toApiError(response);
234795
+ return response;
234796
+ }
234524
234797
  async deleteAttachment(id, context) {
234525
234798
  await this.request("DELETE", `/api/attachments/${encodeURIComponent(id)}`, undefined, context);
234526
234799
  }
@@ -235019,6 +235292,13 @@ var operationOutputSchemas = {
235019
235292
  permanently_delete_document: deleteAcknowledgmentSchema
235020
235293
  };
235021
235294
  var variant = (operation, result) => object({ operation: literal(operation), result });
235295
+ var attachment = object({
235296
+ id: string2().uuid(),
235297
+ filename: string2(),
235298
+ mimeType: string2(),
235299
+ size: number2().int().nonnegative(),
235300
+ url: string2()
235301
+ });
235022
235302
  var singleToolOutputSchemas = {
235023
235303
  delete_document: operationOutputSchemas.delete_document,
235024
235304
  delete_folder: operationOutputSchemas.delete_folder,
@@ -235040,6 +235320,11 @@ var singleToolOutputSchemas = {
235040
235320
  variant("markdown", operationOutputSchemas.export_document),
235041
235321
  variant("versions", operationOutputSchemas.get_version_history)
235042
235322
  ]),
235323
+ upload_document_image: attachment,
235324
+ check_document_attachments: strictObject({
235325
+ items: array2(attachment),
235326
+ verifiedAttachmentId: string2().uuid().optional()
235327
+ }),
235043
235328
  save_document: union2([
235044
235329
  variant("create", operationOutputSchemas.create_document),
235045
235330
  variant("update", operationOutputSchemas.update_document)
@@ -235141,6 +235426,40 @@ function sanitizeMcpRequestContext(context) {
235141
235426
  function createMcpDocsClient(docsClient, requestContext) {
235142
235427
  const context = sanitizeMcpRequestContext(requestContext);
235143
235428
  return {
235429
+ uploadDocumentImage: async (id, filename, mimeType, bytes) => {
235430
+ const descriptor = { filename, contentType: mimeType, size: bytes.byteLength };
235431
+ const upload = await docsClient.presignAttachment(id, descriptor, context);
235432
+ const response = await fetch(upload.url, {
235433
+ method: "PUT",
235434
+ body: new Blob([Uint8Array.from(bytes)], { type: mimeType }),
235435
+ redirect: "error",
235436
+ signal: context?.signal
235437
+ }).catch(() => {
235438
+ throw new Error("Could not send image bytes to DocsMint storage.");
235439
+ });
235440
+ await response.body?.cancel();
235441
+ if (!response.ok)
235442
+ throw new Error(`DocsMint storage rejected the image (${response.status}).`);
235443
+ return docsClient.confirmAttachment(id, {
235444
+ ...descriptor,
235445
+ key: upload.key,
235446
+ uploadToken: upload.uploadToken,
235447
+ quotaReservationId: upload.quotaReservationId
235448
+ }, context);
235449
+ },
235450
+ listAttachments: (id) => docsClient.listAttachments(id, context),
235451
+ verifyAttachment: async (id) => {
235452
+ const response = await docsClient.fetchAttachment(id, context);
235453
+ const reader = response.body?.getReader();
235454
+ if (!reader)
235455
+ throw new Error("The attachment response has no body.");
235456
+ try {
235457
+ if (!(await reader.read()).value?.byteLength)
235458
+ throw new Error("The attachment is empty.");
235459
+ } finally {
235460
+ await reader.cancel();
235461
+ }
235462
+ },
235144
235463
  getFolder: (id) => docsClient.getFolder(id, context),
235145
235464
  createTag: (input) => docsClient.createTag(input, context),
235146
235465
  updateTag: (id, input) => docsClient.updateTag(id, input, context),
@@ -235399,6 +235718,18 @@ var content50 = string2().describe("Markdown document content; an empty string c
235399
235718
  var read2 = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
235400
235719
  var write2 = { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false };
235401
235720
  var destructive = { ...write2, destructiveHint: true };
235721
+ function matchesImageType(bytes, mimeType) {
235722
+ switch (mimeType) {
235723
+ case "image/png":
235724
+ return bytes.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]));
235725
+ case "image/jpeg":
235726
+ return bytes[0] === 255 && bytes[1] === 216 && bytes[2] === 255;
235727
+ case "image/webp":
235728
+ return bytes.toString("ascii", 0, 4) === "RIFF" && bytes.toString("ascii", 8, 12) === "WEBP";
235729
+ default:
235730
+ return false;
235731
+ }
235732
+ }
235402
235733
  function required22(value, name) {
235403
235734
  if (!value)
235404
235735
  throw new Error(`The injected legacy MCP client does not support ${name}; use a public DocsClient.`);
@@ -235434,6 +235765,32 @@ function registerCompactCapabilities(server, client, wrap) {
235434
235765
  const { action: _action, id, ...data } = input;
235435
235766
  return { operation: "update", result: await client.updateDocument(id, data) };
235436
235767
  });
235768
+ const maxImageBytes = 2 * 1024 * 1024;
235769
+ register("upload_document_image", "Upload one PNG, JPEG or WebP image to an existing editable document. Send the file bytes as base64, up to 2 MiB before encoding. Insert the returned url as an image using save_document. If the result is lost, check attachments before uploading again.", strictObject({
235770
+ documentId: uuid22,
235771
+ filename: string2().min(1).max(255).regex(/^[^/\\\u0000-\u001f\u007f]+$/).describe("Image file name with extension and without path segments."),
235772
+ mimeType: _enum(["image/png", "image/jpeg", "image/webp"]).describe("MIME type of the source image."),
235773
+ contentBase64: base642().min(4).max(Math.ceil(maxImageBytes / 3) * 4).describe("Base64 file bytes without a data: prefix.")
235774
+ }), write2, async ({ documentId, filename, mimeType, contentBase64 }) => {
235775
+ const bytes = Buffer.from(contentBase64, "base64");
235776
+ if (!bytes.length || bytes.length > maxImageBytes)
235777
+ throw new Error("Image must be between 1 byte and 2 MiB.");
235778
+ if (!matchesImageType(bytes, mimeType))
235779
+ throw new Error("Image bytes do not match the declared MIME type.");
235780
+ return required22(client.uploadDocumentImage, "upload_document_image")(documentId, filename, mimeType, bytes);
235781
+ });
235782
+ register("check_document_attachments", "List attachments on a readable document. Supply attachmentId to verify that this attachment belongs to the document and that its stored bytes can be opened with the current access.", strictObject({
235783
+ documentId: uuid22,
235784
+ attachmentId: uuid22.optional()
235785
+ }), read2, async ({ documentId, attachmentId }) => {
235786
+ const { items } = await required22(client.listAttachments, "check_document_attachments")(documentId);
235787
+ if (!attachmentId)
235788
+ return { items };
235789
+ if (!items.some((item) => item.id === attachmentId))
235790
+ throw new Error("Attachment not found in this document.");
235791
+ await required22(client.verifyAttachment, "check_document_attachments")(attachmentId);
235792
+ return { items, verifiedAttachmentId: attachmentId };
235793
+ });
235437
235794
  register("delete_document", "Move one document to trash without purging content or versions. Use batch_documents(action=trash) for multiple explicit IDs. Requires write access and an explicit delete request; permanently_delete_document is a separate irreversible action.", strictObject({ id: uuid22 }), destructive, async ({ id }) => {
235438
235795
  await required22(client.deleteDocument, "delete_document")(id);
235439
235796
  return { id, deleted: true };
@@ -235710,7 +236067,7 @@ function registerDocsmintMcpCapabilities(server, client, workspaceRouting, decor
235710
236067
  registerPromptsAndResources(server, client);
235711
236068
  }
235712
236069
  function createDocsmintMcpServer(options = {}) {
235713
- const server = new DocsMintMcpServer({ name: "docsmint", version: "2.1.4" });
236070
+ const server = new DocsMintMcpServer({ name: "docsmint", version: "2.1.9" });
235714
236071
  const client = options.docsClient ? createMcpDocsClient(options.docsClient, options.requestContext) : options.client ?? createMcpDocsClient(createDefaultDocsClient(), options.requestContext);
235715
236072
  registerDocsmintMcpCapabilities(server, client, options.workspaceRouting, options.decorateResult);
235716
236073
  return server;
@@ -242304,7 +242661,7 @@ var swaggerConfig = {
242304
242661
  },
242305
242662
  info: {
242306
242663
  title: "DocsMint API",
242307
- version: "2.1.4",
242664
+ version: "2.1.9",
242308
242665
  description: "Self-hosted AI-native knowledge workspace and installable PWA with hybrid search, GraphRAG, REST, SDK, CLI, and MCP access for people and AI agents.",
242309
242666
  contact: { name: "HiAi-gg", url: "https://github.com/HiAi-gg/docsmint" },
242310
242667
  license: {
@@ -242336,7 +242693,15 @@ var swaggerConfig = {
242336
242693
  }
242337
242694
  };
242338
242695
  var integrationOrigins = integrationAllowedOrigins(config3);
242339
- var app = new Elysia().use(bodySizeLimit).onRequest(({ request }) => rejectIntegrationOrigin(request, integrationOrigins)).onError(({ error, set }) => {
242696
+ var app = new Elysia().use(bodySizeLimit).onRequest(({ request, set }) => {
242697
+ const rejected = rejectIntegrationOrigin(request, integrationOrigins);
242698
+ if (rejected) {
242699
+ rejected.headers.set("X-Request-ID", crypto.randomUUID());
242700
+ return rejected;
242701
+ }
242702
+ set.headers["X-Request-ID"] = crypto.randomUUID();
242703
+ }).onError(({ error, set }) => {
242704
+ set.headers["X-Request-ID"] ??= crypto.randomUUID();
242340
242705
  const purgeFence = translateAccountPurgeFencedError(error, set);
242341
242706
  if (purgeFence)
242342
242707
  return purgeFence;
@@ -242344,7 +242709,12 @@ var app = new Elysia().use(bodySizeLimit).onRequest(({ request }) => rejectInteg
242344
242709
  set.status = error.status;
242345
242710
  return { error: error.message };
242346
242711
  }
242347
- }).onAfterHandle(({ set }) => {
242712
+ }).onAfterHandle(({ set, responseValue }) => {
242713
+ if (responseValue instanceof Response && responseValue.headers.has("X-Request-ID")) {
242714
+ delete set.headers["X-Request-ID"];
242715
+ } else {
242716
+ set.headers["X-Request-ID"] ??= crypto.randomUUID();
242717
+ }
242348
242718
  set.headers["Content-Security-Policy"] = CSP_POLICY;
242349
242719
  set.headers["Strict-Transport-Security"] = HSTS_POLICY;
242350
242720
  set.headers["X-Content-Type-Options"] = "nosniff";