// Force strict mode and setup for ESM
"use strict";
import {
  init_esbuild_shims
} from "./chunk-A4BMJM77.js";
import {
  __name
} from "./chunk-J2S4EL5Y.js";

// packages/cli/src/serve/workspace-remember-errors.ts
init_esbuild_shims();
function errorCodeFromRecord(record) {
  if (typeof record["code"] === "string") return record["code"];
  const data = record["data"];
  if (data && typeof data === "object") {
    const dataRecord = data;
    if (typeof dataRecord["errorKind"] === "string") {
      return dataRecord["errorKind"];
    }
    if (typeof dataRecord["code"] === "string") return dataRecord["code"];
  }
  return void 0;
}
__name(errorCodeFromRecord, "errorCodeFromRecord");
function extractRememberErrorCode(err, fallback = "remember_failed") {
  if (err && typeof err === "object") {
    const record = err;
    const direct = errorCodeFromRecord(record);
    if (direct) return direct;
    const cause = record["cause"];
    if (cause && typeof cause === "object") {
      const causedBy = errorCodeFromRecord(cause);
      if (causedBy) return causedBy;
    }
  }
  return fallback;
}
__name(extractRememberErrorCode, "extractRememberErrorCode");

// packages/cli/src/serve/workspace-memory-remember-constants.ts
init_esbuild_shims();
var MAX_REMEMBER_CONTENT_BYTES = 64 * 1024;

// packages/cli/src/serve/workspace-memory-summaries.ts
init_esbuild_shims();
function formatWorkspaceMemoryForgetSummary(removedEntryCount) {
  return removedEntryCount > 0 ? `Forgot ${removedEntryCount} memory entr${removedEntryCount === 1 ? "y" : "ies"}.` : "No managed auto-memory entries matched.";
}
__name(formatWorkspaceMemoryForgetSummary, "formatWorkspaceMemoryForgetSummary");
function formatWorkspaceMemoryDreamSummary(touchedTopicCount) {
  return touchedTopicCount > 0 ? "Managed auto-memory dream completed." : "No managed auto-memory topics changed.";
}
__name(formatWorkspaceMemoryDreamSummary, "formatWorkspaceMemoryDreamSummary");

// packages/cli/src/serve/validate-server-name.ts
init_esbuild_shims();
var VALID_SERVER_NAME = /^[A-Za-z0-9_-]+$/;
var RESERVED_SERVER_NAMES = /* @__PURE__ */ new Set([
  "__proto__",
  "constructor",
  "prototype"
]);
function isValidServerName(name) {
  return typeof name === "string" && name.length > 0 && name.length <= 256 && VALID_SERVER_NAME.test(name) && !RESERVED_SERVER_NAMES.has(name);
}
__name(isValidServerName, "isValidServerName");

export {
  extractRememberErrorCode,
  MAX_REMEMBER_CONTENT_BYTES,
  formatWorkspaceMemoryForgetSummary,
  formatWorkspaceMemoryDreamSummary,
  isValidServerName
};
/**
 * @license
 * Copyright 2026 Qwen Team
 * SPDX-License-Identifier: Apache-2.0
 */
