v1.2.2 - Fix network error on background, auto-retry streaming with reconnect

This commit is contained in:
admin
2026-05-19 15:50:45 +04:00
Unverified
parent 2e327317e4
commit 1026259a20
3831 changed files with 384316 additions and 39 deletions

133
node_modules/@nicepkg/gpt-runner-shared/dist/common.mjs generated vendored Normal file
View File

@@ -0,0 +1,133 @@
import { C as ChatModelType, E as EnvConfig, g as getProcessCwd, D as DEFAULT_EXCLUDE_FILES, A as AnthropicModelConfigSchema, a as AnthropicSecretsSchema, H as HuggingFaceModelConfigSchema, b as HuggingFaceSecretsSchema, O as OpenaiModelConfigSchema, c as OpenaiSecretsSchema } from './shared/gpt-runner-shared.15a86815.mjs';
export { Y as BaseModelConfigSchema, X as BaseSecretsSchema, L as ChatMessageStatus, ae as ChatMessageStatusSchema, _ as ChatModelSchema, C as ChatModelType, ac as ChatModelTypeSchema, K as ChatRole, ad as ChatRoleSchema, aj as ChatStreamReqParamsSchema, N as ClientEventName, af as ClientEventNameSchema, av as CreateFilePathReqParamsSchema, p as DEFAULT_API_BASE_PATH, D as DEFAULT_EXCLUDE_FILES, v as DEFAULT_EXCLUDE_FILE_EXTS, q as DEFAULT_MODEL_NAMES_FOR_CHOOSE, y as Debug, ax as DeleteFilePathReqParamsSchema, E as EnvConfig, Z as FilterPatternSchema, a8 as FormCheckboxGroupConfigSchema, a4 as FormFieldBaseConfigSchema, a5 as FormInputConfigSchema, aa as FormItemConfigSchema, a3 as FormOptionSchema, a9 as FormRadioGroupConfigSchema, a7 as FormSelectConfigSchema, a6 as FormTextareaConfigSchema, G as GPT_RUNNER_OFFICIAL_FOLDER, aA as GetAppConfigReqParamsSchema, at as GetCommonFilesReqParamsSchema, ay as GetFileInfoReqParamsSchema, am as GetGptFileInfoReqParamsSchema, al as GetGptFilesReqParamsSchema, ak as GetModelNamesForChooseReqParamsSchema, ao as GetUserConfigReqParamsSchema, P as GptFileTreeItemType, ag as GptFileTreeItemTypeSchema, an as InitGptFilesReqParamsSchema, T as LocaleLang, ai as LocaleLangSchema, M as MIN_NODE_VERSION, aB as MarkAsVisitedAppConfigReqParamsSchema, au as OpenEditorReqParamsSchema, O as OpenaiModelConfigSchema, c as OpenaiSecretsSchema, $ as PartialChatModelTypeMapSchema, aw as RenameFilePathReqParamsSchema, S as SECRET_KEY_PLACEHOLDER, n as STREAM_DONE_FLAG, az as SaveFileContentReqParamsSchema, U as SecretStorageKey, Q as ServerStorageName, ah as ServerStorageNameSchema, a2 as SingleChatMessageSchema, ab as SingleFileConfigSchema, as as StorageClearReqParamsSchema, ap as StorageGetItemReqParamsSchema, ar as StorageRemoveItemReqParamsSchema, aq as StorageSetItemReqParamsSchema, a1 as UserConfigForUserSchema, a0 as UserConfigSchema, V as VendorTag, R as WssActionName, W as WssUtils, B as buildFailResponse, z as buildSuccessResponse, x as createFilterByPattern, j as debounce, f as formatSourceValue, l as getErrorMsg, g as getProcessCwd, h as hasOwn, m as isChineseCharacter, o as objectToQueryString, r as runOnceByKey, J as singleFileJsonSchema, s as sleep, k as toUnixPath, t as travelTree, d as travelTreeDeepFirst, e as tryParseJson, i as tryStringifyJson, u as urlRemoveLocalhost, I as userConfigJsonSchema, F as verifyZod, w as waitForCondition } from './shared/gpt-runner-shared.15a86815.mjs';
import 'minimatch';
import 'debug';
import 'zod-to-json-schema';
import 'zod';
import 'axios';
import 'jsonc-parser';
function singleFileConfigWithDefault(singleFileConfig) {
return {
...singleFileConfig
};
}
function userConfigWithDefault(userConfig) {
return {
model: {
type: ChatModelType.Openai,
modelName: "gpt-3.5-turbo-16k",
temperature: 0.9,
maxTokens: 2e3
},
rootPath: EnvConfig.get("GPTR_DEFAULT_ROOT_PATH") || getProcessCwd(),
includes: null,
excludes: DEFAULT_EXCLUDE_FILES,
exts: [".gpt.md"],
respectGitIgnore: true,
urlConfig: {},
...userConfig
};
}
function resolveSingleFileConfig(params, withDefault = true) {
let userConfig = withDefault ? userConfigWithDefault(params.userConfig) : params.userConfig;
const singleFileConfig = withDefault ? singleFileConfigWithDefault(params.singleFileConfig) : params.singleFileConfig;
userConfig = removeUserConfigUnsafeKey(userConfig);
const resolvedConfig = {
...singleFileConfig,
model: {
...userConfig.model,
...singleFileConfig.model
}
};
return resolvedConfig;
}
function removeUserConfigUnsafeKey(userConfig) {
const userConfigClone = {
...userConfig,
model: {
...userConfig.model
}
};
if (userConfigClone.model?.secrets)
delete userConfigClone.model.secrets;
return userConfigClone;
}
function isNumber(value) {
return Object.prototype.toString.call(value) === "[object Number]";
}
function isString(value) {
return Object.prototype.toString.call(value) === "[object String]";
}
function isNotEmptyString(value) {
return typeof value === "string" && value.length > 0;
}
function isBoolean(value) {
return Object.prototype.toString.call(value) === "[object Boolean]";
}
function isFunction(value) {
return Object.prototype.toString.call(value) === "[object Function]";
}
function isObject(value) {
return Object.prototype.toString.call(value) === "[object Object]";
}
function isShallowEqual(objA, objB, compare, compareContext) {
let ret = compare ? compare.call(compareContext, objA, objB) : void 0;
if (ret !== void 0)
return !!ret;
if (Object.is(objA, objB))
return true;
if (typeof objA !== "object" || !objA || typeof objB !== "object" || !objB)
return false;
const keysA = Object.keys(objA);
const keysB = Object.keys(objB);
if (keysA.length !== keysB.length)
return false;
const bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
for (let idx = 0; idx < keysA.length; idx++) {
const key = keysA[idx];
if (!bHasOwnProperty(key))
return false;
const valueA = objA[key];
const valueB = objB[key];
ret = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
if (ret === false || ret === void 0 && !Object.is(valueA, valueB))
return false;
}
return true;
}
function isDeepEqual(objA, objB, maxDepth = 20, visited = [], depth = 0) {
if (depth > maxDepth) {
return true;
}
if (visited.includes(objA) || visited.includes(objB))
return true;
const compare = (a, b) => {
if (typeof a === "object" && a !== null && typeof b === "object" && b !== null) {
return isDeepEqual(a, b, maxDepth, [...visited, a, b], depth + 1);
}
return Object.is(a, b);
};
return isShallowEqual(objA, objB, compare);
}
function getModelConfig(modelType, key) {
const chatModelConfigMap = {
[ChatModelType.Anthropic]: {
config: AnthropicModelConfigSchema,
secrets: AnthropicSecretsSchema
},
[ChatModelType.HuggingFace]: {
config: HuggingFaceModelConfigSchema,
secrets: HuggingFaceSecretsSchema
},
[ChatModelType.Openai]: {
config: OpenaiModelConfigSchema,
secrets: OpenaiSecretsSchema
}
};
return chatModelConfigMap[modelType][key];
}
export { getModelConfig, isBoolean, isDeepEqual, isFunction, isNotEmptyString, isNumber, isObject, isShallowEqual, isString, removeUserConfigUnsafeKey, resolveSingleFileConfig, singleFileConfigWithDefault, userConfigWithDefault };