Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');

//#region src/errors/index.ts
var errors_exports = /* @__PURE__ */ require_runtime.__exportAll({
	ContextOverflowError: () => ContextOverflowError,
	ModelAbortError: () => ModelAbortError,
	addLangChainErrorFields: () => addLangChainErrorFields
});
function addLangChainErrorFields(error, lc_error_code) {
	error.lc_error_code = lc_error_code;
	error.message = `${error.message}\n\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${lc_error_code}/\n`;
	return error;
}
/**
* Error thrown when a model invocation is aborted via an AbortSignal.
* Contains any partial output that was generated before the abort.
*/
var ModelAbortError = class ModelAbortError extends Error {
	name = "ModelAbortError";
	lc_error_code = "MODEL_ABORTED";
	/**
	* The partial message output that was accumulated before the abort.
	* This allows callers to access whatever content was generated
	* before the operation was cancelled.
	*/
	partialOutput;
	constructor(message, partialOutput) {
		super(message);
		this.partialOutput = partialOutput;
		if (Error.captureStackTrace) Error.captureStackTrace(this, ModelAbortError);
	}
	/**
	* Type guard to check if an error is a ModelAbortError
	*/
	static isInstance(error) {
		return typeof error === "object" && error !== null && "name" in error && error.name === "ModelAbortError" && "lc_error_code" in error && error.lc_error_code === "MODEL_ABORTED";
	}
};
/**
* Error thrown when input exceeds the model's context limit.
*
* This exception is raised by chat models when the input tokens exceed
* the maximum context window supported by the model.
*/
var ContextOverflowError = class ContextOverflowError extends Error {
	name = "ContextOverflowError";
	lc_error_code = "CONTEXT_OVERFLOW";
	constructor(message, options) {
		super(message, options);
		if (Error.captureStackTrace) Error.captureStackTrace(this, ContextOverflowError);
	}
	/**
	* Type guard to check if an error is a ContextOverflowError
	*/
	static isInstance(error) {
		return typeof error === "object" && error !== null && "name" in error && error.name === "ContextOverflowError" && "lc_error_code" in error && error.lc_error_code === "CONTEXT_OVERFLOW";
	}
};

//#endregion
exports.ContextOverflowError = ContextOverflowError;
exports.ModelAbortError = ModelAbortError;
exports.addLangChainErrorFields = addLangChainErrorFields;
Object.defineProperty(exports, 'errors_exports', {
  enumerable: true,
  get: function () {
    return errors_exports;
  }
});
//# sourceMappingURL=index.cjs.map