create-expert 0.0.39 → 0.0.40

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-expert-Circ5eKU.js","names":["z.string","z.enum","z.object","z.literal","z.number","z.unknown","z.array","z.preprocess","z.coerce.number","z.null","z.boolean","z.record","z.discriminatedUnion","z.coerce.boolean","z.union","z.undefined","z.lazy"],"sources":["../../../node_modules/.pnpm/@perstack+api-client@0.0.56_@perstack+core@packages+core_zod@4.3.6/node_modules/@perstack/api-client/dist/index.mjs","../../../packages/runtime/src/helpers/resolve-expert.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { activityOrGroupSchema, instructionMessageSchema, messageSchema, toolCallSchema, toolMessageSchema, toolResultSchema, usageSchema, userMessageSchema } from \"@perstack/core\";\n\n//#region src/lib/api-key.ts\nfunction matchWildcard(value, pattern) {\n\tif (pattern === \"*\") return true;\n\tif (pattern.endsWith(\"*\")) return value.startsWith(pattern.slice(0, -1));\n\tif (pattern.startsWith(\"*\")) return value.endsWith(pattern.slice(1));\n\treturn value === pattern;\n}\nfunction matchOperations(operations, requiredOperation) {\n\treturn operations.some((pattern) => matchWildcard(requiredOperation, pattern));\n}\nfunction matchExperts(experts, expertId) {\n\tif (experts === void 0 || experts === \"*\") return true;\n\treturn experts.some((pattern) => matchWildcard(expertId, pattern));\n}\nfunction isApiKeyPermissions(parsed) {\n\treturn typeof parsed === \"object\" && parsed !== null && \"operations\" in parsed && Array.isArray(parsed.operations);\n}\nfunction parseApiKeyPermissions(permissionsJson) {\n\tif (!permissionsJson) return null;\n\ttry {\n\t\tconst parsed = JSON.parse(permissionsJson);\n\t\tif (!isApiKeyPermissions(parsed)) return null;\n\t\treturn parsed;\n\t} catch {\n\t\treturn null;\n\t}\n}\nfunction stringifyApiKeyPermissions(permissions) {\n\treturn JSON.stringify(permissions);\n}\n\n//#endregion\n//#region src/lib/auth.ts\nfunction buildAuthHeaders(auth) {\n\tif (auth.type === \"apiKey\") return { Authorization: `Bearer ${auth.apiKey}` };\n\treturn { Cookie: auth.cookie };\n}\n\n//#endregion\n//#region src/lib/errors.ts\nfunction createValidationError(error) {\n\treturn {\n\t\ttype: \"validation\",\n\t\tmessage: `Validation failed: ${error.issues.map((issue) => `${issue.path.join(\".\")}: ${issue.message}`).join(\"; \")}`,\n\t\treason: error.issues\n\t};\n}\nfunction validationErrorResult(error) {\n\treturn {\n\t\tok: false,\n\t\tstatus: 0,\n\t\theaders: new Headers(),\n\t\terror: createValidationError(error)\n\t};\n}\nfunction createAbortError() {\n\treturn {\n\t\ttype: \"abort\",\n\t\tmessage: \"Request aborted\"\n\t};\n}\nfunction createTimeoutError() {\n\treturn {\n\t\ttype: \"timeout\",\n\t\tmessage: \"Request timed out\"\n\t};\n}\nfunction createNetworkError(error) {\n\treturn {\n\t\ttype: \"network\",\n\t\tmessage: error instanceof Error ? error.message : \"Network error\",\n\t\treason: error,\n\t\tcause: error instanceof Error ? error : void 0\n\t};\n}\nasync function handleHttpError(response) {\n\tlet errorBody;\n\ttry {\n\t\terrorBody = await response.json();\n\t} catch {\n\t\terrorBody = void 0;\n\t}\n\treturn {\n\t\tok: false,\n\t\tstatus: response.status,\n\t\theaders: response.headers,\n\t\terror: createHttpError(response.statusText, errorBody)\n\t};\n}\nfunction createHttpError(statusText, body) {\n\tif (typeof body === \"object\" && body !== null) {\n\t\tconst hasReason = \"reason\" in body;\n\t\tif (\"error\" in body && typeof body.error === \"string\") return {\n\t\t\ttype: \"http\",\n\t\t\tmessage: body.error,\n\t\t\treason: hasReason ? body.reason : void 0\n\t\t};\n\t\tif (hasReason) return {\n\t\t\ttype: \"http\",\n\t\t\tmessage: statusText,\n\t\t\treason: body.reason\n\t\t};\n\t}\n\treturn {\n\t\ttype: \"http\",\n\t\tmessage: statusText\n\t};\n}\nfunction isHttpError(error) {\n\treturn error.type === \"http\";\n}\nfunction isNetworkError(error) {\n\treturn error.type === \"network\";\n}\nfunction isTimeoutError(error) {\n\treturn error.type === \"timeout\";\n}\nfunction isValidationError(error) {\n\treturn error.type === \"validation\";\n}\nfunction isAbortError(error) {\n\treturn error.type === \"abort\";\n}\nfunction isClientError(error) {\n\treturn error.type !== \"http\";\n}\n\n//#endregion\n//#region src/lib/fetcher.ts\nconst DEFAULT_BASE_URL = \"https://api.perstack.ai\";\nconst DEFAULT_TIMEOUT = 6e4;\nfunction createFetcher(config) {\n\tconst baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;\n\tconst timeout = config.timeout ?? DEFAULT_TIMEOUT;\n\tconst useCredentials = config.credentials === \"include\";\n\tconst apiKey = config.apiKey;\n\tfunction buildUrl(path) {\n\t\treturn `${baseUrl}${path}`;\n\t}\n\tfunction buildHeaders(options) {\n\t\tconst headers = {};\n\t\tif (options?.hasBody) headers[\"Content-Type\"] = \"application/json\";\n\t\tif (apiKey) headers.Authorization = `Bearer ${apiKey}`;\n\t\treturn headers;\n\t}\n\tfunction getCredentials() {\n\t\treturn useCredentials ? \"include\" : void 0;\n\t}\n\tfunction createTimeoutSignal(externalSignal) {\n\t\tconst controller = new AbortController();\n\t\tlet timedOut = false;\n\t\tconst timeoutId = setTimeout(() => {\n\t\t\ttimedOut = true;\n\t\t\tcontroller.abort();\n\t\t}, timeout);\n\t\tlet abortHandler;\n\t\tif (externalSignal) if (externalSignal.aborted) controller.abort();\n\t\telse {\n\t\t\tabortHandler = () => controller.abort();\n\t\t\texternalSignal.addEventListener(\"abort\", abortHandler);\n\t\t}\n\t\treturn {\n\t\t\tsignal: controller.signal,\n\t\t\tcleanup: () => {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t\tif (abortHandler && externalSignal) externalSignal.removeEventListener(\"abort\", abortHandler);\n\t\t\t},\n\t\t\tisTimeout: () => timedOut\n\t\t};\n\t}\n\tfunction wrapStreamWithIdleTimeout(stream, idleTimeoutMs, externalSignal) {\n\t\tconst reader = stream.getReader();\n\t\tconst controller = new AbortController();\n\t\tlet timeoutId;\n\t\tlet abortHandler;\n\t\tif (externalSignal) if (externalSignal.aborted) controller.abort();\n\t\telse {\n\t\t\tabortHandler = () => controller.abort();\n\t\t\texternalSignal.addEventListener(\"abort\", abortHandler);\n\t\t}\n\t\tfunction resetTimeout() {\n\t\t\tif (timeoutId) clearTimeout(timeoutId);\n\t\t\ttimeoutId = setTimeout(() => controller.abort(), idleTimeoutMs);\n\t\t}\n\t\tfunction cleanup() {\n\t\t\tif (timeoutId) clearTimeout(timeoutId);\n\t\t\tif (abortHandler && externalSignal) externalSignal.removeEventListener(\"abort\", abortHandler);\n\t\t}\n\t\treturn new ReadableStream({\n\t\t\tstart() {\n\t\t\t\tresetTimeout();\n\t\t\t},\n\t\t\tasync pull(streamController) {\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await Promise.race([reader.read(), new Promise((_, reject) => {\n\t\t\t\t\t\tif (controller.signal.aborted) reject(new DOMException(\"Stream idle timeout\", \"AbortError\"));\n\t\t\t\t\t\tcontroller.signal.addEventListener(\"abort\", () => {\n\t\t\t\t\t\t\treject(new DOMException(\"Stream idle timeout\", \"AbortError\"));\n\t\t\t\t\t\t});\n\t\t\t\t\t})]);\n\t\t\t\t\tif (result.done) {\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t\tstreamController.close();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tresetTimeout();\n\t\t\t\t\tstreamController.enqueue(result.value);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tcleanup();\n\t\t\t\t\treader.cancel().catch(() => {});\n\t\t\t\t\tif (error instanceof DOMException && error.name === \"AbortError\") streamController.error(new DOMException(\"Stream idle timeout\", \"AbortError\"));\n\t\t\t\t\telse streamController.error(error);\n\t\t\t\t}\n\t\t\t},\n\t\t\tcancel(reason) {\n\t\t\t\tcleanup();\n\t\t\t\treader.cancel(reason).catch(() => {});\n\t\t\t}\n\t\t});\n\t}\n\tasync function request(method, path, body, options) {\n\t\tconst { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);\n\t\ttry {\n\t\t\tconst response = await fetch(buildUrl(path), {\n\t\t\t\tmethod,\n\t\t\t\theaders: buildHeaders(body ? { hasBody: true } : void 0),\n\t\t\t\tbody: body ? JSON.stringify(body) : void 0,\n\t\t\t\tsignal,\n\t\t\t\tcredentials: getCredentials()\n\t\t\t});\n\t\t\tif (!response.ok) return handleHttpError(response);\n\t\t\tconst json = await response.json();\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tstatus: response.status,\n\t\t\t\theaders: response.headers,\n\t\t\t\tdata: json\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && error.name === \"AbortError\") {\n\t\t\t\tif (isTimeout()) return {\n\t\t\t\t\tok: false,\n\t\t\t\t\tstatus: 0,\n\t\t\t\t\theaders: new Headers(),\n\t\t\t\t\terror: createTimeoutError()\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\tok: false,\n\t\t\t\t\tstatus: 0,\n\t\t\t\t\theaders: new Headers(),\n\t\t\t\t\terror: createAbortError()\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tstatus: 0,\n\t\t\t\theaders: new Headers(),\n\t\t\t\terror: createNetworkError(error)\n\t\t\t};\n\t\t} finally {\n\t\t\tcleanup();\n\t\t}\n\t}\n\tasync function requestBlob(path, options) {\n\t\tconst { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);\n\t\ttry {\n\t\t\tconst response = await fetch(buildUrl(path), {\n\t\t\t\tmethod: \"GET\",\n\t\t\t\theaders: buildHeaders(),\n\t\t\t\tsignal,\n\t\t\t\tcredentials: getCredentials()\n\t\t\t});\n\t\t\tif (!response.ok) return handleHttpError(response);\n\t\t\tconst blob = await response.blob();\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tstatus: response.status,\n\t\t\t\theaders: response.headers,\n\t\t\t\tdata: blob\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && error.name === \"AbortError\") {\n\t\t\t\tif (isTimeout()) return {\n\t\t\t\t\tok: false,\n\t\t\t\t\tstatus: 0,\n\t\t\t\t\theaders: new Headers(),\n\t\t\t\t\terror: createTimeoutError()\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\tok: false,\n\t\t\t\t\tstatus: 0,\n\t\t\t\t\theaders: new Headers(),\n\t\t\t\t\terror: createAbortError()\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tstatus: 0,\n\t\t\t\theaders: new Headers(),\n\t\t\t\terror: createNetworkError(error)\n\t\t\t};\n\t\t} finally {\n\t\t\tcleanup();\n\t\t}\n\t}\n\tasync function requestStream(path, options) {\n\t\tconst { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);\n\t\ttry {\n\t\t\tconst response = await fetch(buildUrl(path), {\n\t\t\t\tmethod: \"GET\",\n\t\t\t\theaders: buildHeaders(),\n\t\t\t\tsignal,\n\t\t\t\tcredentials: getCredentials()\n\t\t\t});\n\t\t\tif (!response.ok) {\n\t\t\t\tcleanup();\n\t\t\t\treturn handleHttpError(response);\n\t\t\t}\n\t\t\tif (!response.body) {\n\t\t\t\tcleanup();\n\t\t\t\treturn {\n\t\t\t\t\tok: false,\n\t\t\t\t\tstatus: response.status,\n\t\t\t\t\theaders: response.headers,\n\t\t\t\t\terror: createNetworkError(/* @__PURE__ */ new Error(\"Response body is null\"))\n\t\t\t\t};\n\t\t\t}\n\t\t\tcleanup();\n\t\t\tconst idleTimeout = options?.streamIdleTimeout ?? timeout;\n\t\t\tconst wrappedStream = wrapStreamWithIdleTimeout(response.body, idleTimeout, options?.signal);\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tstatus: response.status,\n\t\t\t\theaders: response.headers,\n\t\t\t\tdata: wrappedStream\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tcleanup();\n\t\t\tif (error instanceof Error && error.name === \"AbortError\") {\n\t\t\t\tif (isTimeout()) return {\n\t\t\t\t\tok: false,\n\t\t\t\t\tstatus: 0,\n\t\t\t\t\theaders: new Headers(),\n\t\t\t\t\terror: createTimeoutError()\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\tok: false,\n\t\t\t\t\tstatus: 0,\n\t\t\t\t\theaders: new Headers(),\n\t\t\t\t\terror: createAbortError()\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tstatus: 0,\n\t\t\t\theaders: new Headers(),\n\t\t\t\terror: createNetworkError(error)\n\t\t\t};\n\t\t}\n\t}\n\tasync function requestNoContent(method, path, options) {\n\t\tconst { signal, cleanup, isTimeout } = createTimeoutSignal(options?.signal);\n\t\ttry {\n\t\t\tconst response = await fetch(buildUrl(path), {\n\t\t\t\tmethod,\n\t\t\t\theaders: buildHeaders(),\n\t\t\t\tsignal,\n\t\t\t\tcredentials: getCredentials()\n\t\t\t});\n\t\t\tif (!response.ok) return handleHttpError(response);\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tstatus: response.status,\n\t\t\t\theaders: response.headers,\n\t\t\t\tdata: void 0\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error && error.name === \"AbortError\") {\n\t\t\t\tif (isTimeout()) return {\n\t\t\t\t\tok: false,\n\t\t\t\t\tstatus: 0,\n\t\t\t\t\theaders: new Headers(),\n\t\t\t\t\terror: createTimeoutError()\n\t\t\t\t};\n\t\t\t\treturn {\n\t\t\t\t\tok: false,\n\t\t\t\t\tstatus: 0,\n\t\t\t\t\theaders: new Headers(),\n\t\t\t\t\terror: createAbortError()\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tstatus: 0,\n\t\t\t\theaders: new Headers(),\n\t\t\t\terror: createNetworkError(error)\n\t\t\t};\n\t\t} finally {\n\t\t\tcleanup();\n\t\t}\n\t}\n\treturn {\n\t\tget: (path, options) => request(\"GET\", path, void 0, options),\n\t\tpost: (path, body, options) => request(\"POST\", path, body, options),\n\t\tput: (path, body, options) => request(\"PUT\", path, body, options),\n\t\tdelete: (path, options) => request(\"DELETE\", path, void 0, options),\n\t\tdeleteNoContent: (path, options) => requestNoContent(\"DELETE\", path, options),\n\t\tgetBlob: (path, options) => requestBlob(path, options),\n\t\tgetStream: (path, options) => requestStream(path, options)\n\t};\n}\n\n//#endregion\n//#region src/lib/query-string.ts\nfunction buildQueryString(params) {\n\tif (!params) return \"\";\n\tconst searchParams = new URLSearchParams();\n\tfor (const [key, value] of Object.entries(params)) if (value !== void 0) searchParams.set(key, String(value));\n\tconst queryString = searchParams.toString();\n\treturn queryString ? `?${queryString}` : \"\";\n}\n\n//#endregion\n//#region src/lib/sse.ts\nasync function* parseSSEEvents(reader) {\n\tconst decoder = new TextDecoder();\n\tlet buffer = \"\";\n\twhile (true) {\n\t\tconst { value, done } = await reader.read();\n\t\tif (done) break;\n\t\tbuffer += decoder.decode(value, { stream: true });\n\t\tconst events = buffer.split(\"\\n\\n\");\n\t\tbuffer = events.pop() || \"\";\n\t\tfor (const event of events) {\n\t\t\tif (event.trim() === \"\") continue;\n\t\t\tconst lines = event.split(\"\\n\");\n\t\t\tconst eventType = lines.find((line) => line.startsWith(\"event:\"))?.slice(6).trim();\n\t\t\tconst data = lines.find((line) => line.startsWith(\"data:\"))?.slice(5).trim();\n\t\t\tif (!eventType || !data) continue;\n\t\t\tif (eventType !== \"message\" && eventType !== \"error\" && eventType !== \"complete\") continue;\n\t\t\ttry {\n\t\t\t\tyield {\n\t\t\t\t\tevent: eventType,\n\t\t\t\t\tdata: JSON.parse(data)\n\t\t\t\t};\n\t\t\t} catch {}\n\t\t}\n\t}\n}\nasync function* parseSSE(reader) {\n\tconst decoder = new TextDecoder();\n\tlet buffer = \"\";\n\twhile (true) {\n\t\tconst { value, done } = await reader.read();\n\t\tif (done) break;\n\t\tbuffer += decoder.decode(value, { stream: true });\n\t\tconst events = buffer.split(\"\\n\\n\");\n\t\tbuffer = events.pop() || \"\";\n\t\tfor (const event of events) {\n\t\t\tif (event.trim() === \"\") continue;\n\t\t\tconst lines = event.split(\"\\n\");\n\t\t\tconst eventType = lines.find((line) => line.startsWith(\"event:\"))?.slice(6).trim();\n\t\t\tconst data = lines.find((line) => line.startsWith(\"data:\"))?.slice(5).trim();\n\t\t\tif (eventType !== \"message\" || !data) continue;\n\t\t\ttry {\n\t\t\t\tyield JSON.parse(data);\n\t\t\t} catch {}\n\t\t}\n\t}\n}\n\n//#endregion\n//#region ../constants/index.ts\nconst organizationNameRegex = /^[a-z0-9][a-z0-9_.-]*$/;\nconst maxOrganizationNameLength = 128;\nconst applicationNameRegex = /^[a-z0-9][a-z0-9_.-]*$/;\nconst maxApplicationNameLength = 255;\nconst maxVariableValueLength = 65536;\nconst maxSecretValueLength = 65536;\nconst expertKeyRegex = /^((?:@[a-z0-9][a-z0-9_.-]*\\/)?[a-z0-9][a-z0-9_.-]*)(?:@((?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[\\w.-]+)?(?:\\+[\\w.-]+)?)|@([a-z0-9][a-z0-9_.-]*))?$/;\nconst expertNameRegex = /^(@[a-z0-9][a-z0-9_-]*\\/)?[a-z0-9][a-z0-9_-]*$/;\nconst scopeNameRegex = /^[a-z0-9][a-z0-9_-]*$/;\nconst scopeNameRefRegex = /^[a-z0-9][a-z0-9_-]*(?:@(?:(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[\\w.-]+)?(?:\\+[\\w.-]+)?|[a-z0-9][a-z0-9_-]*))?$/;\nconst expertVersionRegex = /^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[\\w.-]+)?(?:\\+[\\w.-]+)?$/;\nconst tagNameRegex = /^[a-z0-9][a-z0-9_-]*$/;\nconst maxExpertNameLength = 255;\nconst maxExpertVersionTagLength = 255;\nconst maxExpertKeyLength = 511;\nconst maxExpertDescriptionLength = 1024 * 2;\nconst maxExpertInstructionLength = 1024 * 20;\nconst maxExpertDelegateItems = 255;\nconst maxExpertTagItems = 8;\nconst maxExpertJobQueryLength = 1024 * 20;\nconst maxExpertJobFileNameLength = 1024 * 10;\nconst packageWithVersionRegex = /^(?:@[a-z0-9][a-z0-9_.-]*\\/)?[a-z0-9][a-z0-9_.-]*(?:@(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[\\w.-]+)?(?:\\+[\\w.-]+)?|@[a-z0-9][a-z0-9_.-]*)?$/;\nconst urlSafeRegex = /^[a-z0-9][a-z0-9_-]*$/;\nconst maxSkillNameLength = 255;\nconst maxSkillDescriptionLength = 1024 * 2;\nconst maxSkillRuleLength = 1024 * 2;\nconst maxSkillPickOmitItems = 255;\nconst maxSkillRequiredEnvItems = 255;\nconst maxSkillToolNameLength = 255;\nconst maxSkillEndpointLength = 1024 * 2;\nconst maxSkillInputJsonSchemaLength = 1024 * 20;\nconst maxCheckpointToolCallIdLength = 255;\nconst envNameRegex = /^[a-zA-Z0-9][a-zA-Z0-9_-]*$/;\nconst maxEnvNameLength = 255;\nconst maxProviderBaseUrlLength = 2048;\nconst maxProviderHeaderKeyLength = 255;\nconst maxProviderHeaderValueLength = 2048;\nconst maxProviderHeadersCount = 50;\n\n//#endregion\n//#region ../models/src/domain/common.ts\nconst cuidSchema = z.string().cuid2();\nconst cuidRequestSchema = z.string().min(24).cuid2();\nconst runtimeVersionSchema = z.enum([\"v1.0\"]);\nconst providerSchema = z.enum([\n\t\"anthropic\",\n\t\"google\",\n\t\"openai\",\n\t\"deepseek\",\n\t\"azure-openai\",\n\t\"amazon-bedrock\",\n\t\"google-vertex\"\n]);\nconst datetimeSchema = z.string().datetime({ offset: true });\nconst expertKeyFieldSchema = z.string().min(1).max(maxExpertKeyLength).regex(expertKeyRegex);\nconst expertNameFieldSchema = z.string().min(1).max(maxExpertNameLength).regex(expertNameRegex);\nconst expertVersionFieldSchema = z.string().min(1).max(maxExpertVersionTagLength).regex(expertVersionRegex);\nconst expertTagFieldSchema = z.string().min(1).max(maxExpertVersionTagLength).regex(tagNameRegex);\nconst expertCategoryFieldSchema = z.enum([\n\t\"general\",\n\t\"coding\",\n\t\"research\",\n\t\"writing\",\n\t\"data\",\n\t\"automation\"\n]);\nconst scopeNameSchema = z.string().min(1).max(maxExpertNameLength).regex(scopeNameRegex);\nconst scopeNameRefSchema = z.string().min(1).max(maxExpertNameLength + maxExpertVersionTagLength + 1).regex(scopeNameRefRegex);\nconst draftRefFieldSchema = z.string().min(1).max(30);\n\n//#endregion\n//#region ../models/src/domain/organization.ts\nconst organizationStatusSchema = z.enum([\n\t\"active\",\n\t\"inactive\",\n\t\"deleted\"\n]);\nconst organizationTypeSchema = z.enum([\n\t\"personal\",\n\t\"personalPlus\",\n\t\"team\",\n\t\"serviceAdmin\"\n]);\nconst organizationSchema = z.object({\n\ttype: z.literal(\"organization\"),\n\tid: cuidSchema,\n\tcreatedAt: datetimeSchema,\n\tupdatedAt: datetimeSchema,\n\tname: z.string().min(1).max(maxOrganizationNameLength).regex(organizationNameRegex).optional(),\n\tnameChangedAt: datetimeSchema.optional(),\n\tstatus: organizationStatusSchema,\n\torganizationType: organizationTypeSchema,\n\tmaxApplications: z.number().int().min(0),\n\tmaxApiKeys: z.number().int().min(0),\n\tmaxExperts: z.number().int().min(0)\n});\n\n//#endregion\n//#region ../models/src/lib/dedent.ts\n/**\n* Dedent function for multi-line template strings.\n* Adapted from ts-dedent (MIT License) to provide pure ESM support.\n*\n* Removes leading indentation from multi-line strings while preserving\n* relative indentation between lines.\n*/\nfunction dedent(templ, ...values) {\n\tlet strings = Array.from(typeof templ === \"string\" ? [templ] : templ);\n\tconst lastIndex = strings.length - 1;\n\tstrings[lastIndex] = (strings[lastIndex] ?? \"\").replace(/\\r?\\n([\\t ]*)$/, \"\");\n\tconst indentLengths = strings.reduce((arr, str) => {\n\t\tconst matches = str.match(/\\n([\\t ]+|(?!\\s).)/g);\n\t\tif (matches) return arr.concat(matches.map((match) => match.match(/[\\t ]/g)?.length ?? 0));\n\t\treturn arr;\n\t}, []);\n\tif (indentLengths.length) {\n\t\tconst pattern = new RegExp(`\\n[\\t ]{${Math.min(...indentLengths)}}`, \"g\");\n\t\tstrings = strings.map((str) => str.replace(pattern, \"\\n\"));\n\t}\n\tstrings[0] = (strings[0] ?? \"\").replace(/^\\r?\\n/, \"\");\n\tlet string = strings[0] ?? \"\";\n\tvalues.forEach((value, i) => {\n\t\tconst endentation = string.match(/(?:^|\\n)( *)$/)?.[1] ?? \"\";\n\t\tlet indentedValue = value;\n\t\tif (typeof value === \"string\" && value.includes(\"\\n\")) indentedValue = String(value).split(\"\\n\").map((str, j) => {\n\t\t\treturn j === 0 ? str : `${endentation}${str}`;\n\t\t}).join(\"\\n\");\n\t\tstring += String(indentedValue) + (strings[i + 1] ?? \"\");\n\t});\n\treturn string;\n}\n\n//#endregion\n//#region ../models/src/api/common.ts\nconst errorBadRequest = z.object({\n\tcode: z.literal(400),\n\terror: z.literal(\"Bad Request\"),\n\treason: z.string()\n}).describe(\"Bad Request\");\nconst errorUnauthorized = z.object({\n\tcode: z.literal(401),\n\terror: z.literal(\"Unauthorized\"),\n\treason: z.literal(\"Failed to authenticate\")\n}).describe(dedent`\n Authentication failed. Possible reasons:\n - Authorization header is not provided\n - Invalid API key\n - Session expired\n `);\nconst errorForbidden = z.object({\n\tcode: z.literal(403),\n\terror: z.literal(\"Forbidden\"),\n\treason: z.string()\n}).describe(\"Access denied. The authenticated user does not have permission to perform this action.\");\nconst errorUsageLimitExceeded = z.object({\n\tcode: z.literal(403),\n\terror: z.literal(\"Forbidden\"),\n\treason: z.string(),\n\tdetails: z.object({\n\t\tminutesUsed: z.number(),\n\t\tlimitMinutes: z.number(),\n\t\tupgradeUrl: z.string()\n\t})\n}).describe(\"Usage limit exceeded. Upgrade your plan to continue.\");\nconst errorNotFound = z.object({\n\tcode: z.literal(404),\n\terror: z.literal(\"Not Found\"),\n\treason: z.string()\n}).describe(\"Resource not found.\");\nconst errorConflict = z.object({\n\tcode: z.literal(409),\n\terror: z.literal(\"Conflict\"),\n\treason: z.string()\n}).describe(\"Request conflicts with current state of the resource.\");\nconst errorServiceUnavailable = z.object({\n\tcode: z.literal(503),\n\terror: z.literal(\"Service Unavailable\"),\n\treason: z.string()\n}).describe(\"Service temporarily unavailable. Retry with exponential backoff.\");\nconst errorValidationFailed = z.object({\n\tcode: z.literal(422),\n\terror: z.literal(\"Validation Failed\"),\n\treason: z.unknown()\n}).describe(\"Request validation failed. Check the request body, query parameters, or path parameters.\");\nconst paginationMeta = z.object({\n\ttotal: z.number().int().min(0),\n\ttake: z.number().int().min(1),\n\tskip: z.number().int().min(0)\n});\nconst errorUnauthorizedFlexible = z.object({\n\tcode: z.literal(401),\n\terror: z.literal(\"Unauthorized\"),\n\treason: z.string()\n}).describe(\"Unauthorized\");\n\n//#endregion\n//#region ../models/src/domain/application.ts\nconst applicationNameSchema = z.string().min(1).max(maxApplicationNameLength).regex(applicationNameRegex);\nconst applicationStatusSchema = z.enum([\n\t\"active\",\n\t\"inactive\",\n\t\"deleted\"\n]);\nconst applicationSchema = z.object({\n\ttype: z.literal(\"application\"),\n\tid: cuidSchema,\n\torganizationId: cuidSchema,\n\torganization: organizationSchema,\n\tcreatedAt: datetimeSchema,\n\tupdatedAt: datetimeSchema,\n\tname: applicationNameSchema,\n\tstatus: applicationStatusSchema,\n\texpertCount: z.number().describe(\"Number of expert draft scopes associated with this application\").optional(),\n\tproviders: z.array(providerSchema).describe(\"List of configured providers for this application\").optional(),\n\ttotalJobs: z.number().describe(\"Total number of jobs executed for this application\").optional(),\n\tlastJobExecutionAt: z.string().datetime({ offset: true }).nullable().describe(\"Timestamp of the most recent job execution\").optional()\n});\n\n//#endregion\n//#region ../models/src/api/applications/create.ts\nconst request$21 = { body: z.object({\n\tname: applicationNameSchema,\n\tapplicationGroupId: cuidSchema.optional()\n}) };\nconst response$21 = z.object({ data: z.object({ application: applicationSchema }) });\n\n//#endregion\n//#region ../models/src/api/applications/getAll.ts\nconst request$20 = { query: z.object({\n\tname: z.preprocess((val) => Array.isArray(val) ? val.join(\",\") : val, z.string().optional()),\n\tsort: z.enum([\n\t\t\"name\",\n\t\t\"createdAt\",\n\t\t\"updatedAt\"\n\t]).optional(),\n\torder: z.enum([\"asc\", \"desc\"]).optional(),\n\ttake: z.coerce.number().min(1).max(100).default(20),\n\tskip: z.coerce.number().min(0).default(0)\n}) };\nconst response$20 = z.object({\n\tdata: z.object({ applications: z.array(applicationSchema) }),\n\tmeta: paginationMeta\n});\n\n//#endregion\n//#region ../models/src/api/applications/update.ts\nconst request$19 = {\n\tparams: z.object({ applicationId: cuidSchema }),\n\tbody: z.object({\n\t\tname: applicationNameSchema.optional(),\n\t\tstatus: applicationStatusSchema.exclude([\"deleted\"]).optional()\n\t}).refine((data) => data.name !== void 0 || data.status !== void 0, { message: \"At least one field must be provided\" })\n};\nconst response$19 = z.object({ data: z.object({ application: applicationSchema }) });\n\n//#endregion\n//#region ../models/src/domain/secret.ts\nconst secretNameSchema = z.string().min(1, \"Secret name is required\").max(255, \"Secret name must be 255 characters or less\").regex(/^[A-Z][A-Z0-9_]*$/, \"Secret name must start with uppercase letter and contain only uppercase letters, numbers, and underscores\");\nconst secretValueSchema = z.string().min(1, \"Secret value is required\").max(maxSecretValueLength);\nconst secretMetadataSchema = z.object({\n\tname: z.string(),\n\tcreatedAt: datetimeSchema,\n\tupdatedAt: datetimeSchema\n});\nconst secretSchema = z.object({\n\ttype: z.literal(\"secret\"),\n\tid: cuidSchema,\n\tname: secretNameSchema,\n\tapplicationId: cuidSchema,\n\tcreatedAt: datetimeSchema,\n\tupdatedAt: datetimeSchema\n});\n\n//#endregion\n//#region ../models/src/api/env/secrets/create.ts\nconst request$18 = { body: z.object({\n\tapplicationId: cuidSchema,\n\tname: secretNameSchema,\n\tvalue: secretValueSchema\n}) };\nconst response$18 = z.object({ data: z.object({ secret: secretMetadataSchema }) });\n\n//#endregion\n//#region ../models/src/api/env/secrets/delete.ts\nconst request$17 = {\n\tparams: z.object({ name: z.string().min(1) }),\n\tquery: z.object({ applicationId: cuidSchema })\n};\nconst response$17 = z.null();\n\n//#endregion\n//#region ../models/src/api/env/secrets/get.ts\nconst request$16 = {\n\tparams: z.object({ name: z.string().min(1) }),\n\tquery: z.object({ applicationId: cuidSchema })\n};\nconst response$16 = z.object({ data: z.object({ secret: secretMetadataSchema }) });\n\n//#endregion\n//#region ../models/src/api/env/secrets/getAll.ts\nconst request$15 = { query: z.object({ applicationId: cuidSchema.optional() }) };\nconst response$15 = z.object({ data: z.object({ secrets: z.array(secretMetadataSchema) }) });\n\n//#endregion\n//#region ../models/src/api/env/secrets/update.ts\nconst request$14 = {\n\tparams: z.object({ name: z.string().min(1) }),\n\tbody: z.object({\n\t\tapplicationId: cuidSchema,\n\t\tvalue: secretValueSchema\n\t})\n};\nconst response$14 = z.object({ data: z.object({ secret: secretMetadataSchema }) });\n\n//#endregion\n//#region ../models/src/domain/variable.ts\nconst variableNameSchema = z.string().min(1).max(255).regex(/^[A-Z][A-Z0-9_]*$/, \"Variable name must start with uppercase letter and contain only uppercase letters, digits, and underscores\");\nconst variableValueSchema = z.string().max(maxVariableValueLength);\nconst variableSchema = z.object({\n\ttype: z.literal(\"variable\"),\n\tid: cuidSchema,\n\tapplicationId: cuidSchema,\n\tcreatedAt: datetimeSchema,\n\tupdatedAt: datetimeSchema,\n\tname: variableNameSchema,\n\tvalue: variableValueSchema\n});\nconst variableResponseSchema = z.object({\n\tname: variableNameSchema,\n\tvalue: variableValueSchema,\n\tcreatedAt: datetimeSchema,\n\tupdatedAt: datetimeSchema\n});\n\n//#endregion\n//#region ../models/src/api/env/variables/create.ts\nconst request$13 = { body: z.object({\n\tapplicationId: cuidSchema,\n\tname: variableNameSchema,\n\tvalue: variableValueSchema\n}) };\nconst response$13 = z.object({ data: z.object({ variable: variableResponseSchema }) });\n\n//#endregion\n//#region ../models/src/api/env/variables/delete.ts\nconst request$12 = {\n\tparams: z.object({ name: z.string().min(1) }),\n\tquery: z.object({ applicationId: cuidSchema })\n};\nconst response$12 = z.null();\n\n//#endregion\n//#region ../models/src/api/env/variables/get.ts\nconst request$11 = {\n\tparams: z.object({ name: z.string().min(1) }),\n\tquery: z.object({ applicationId: cuidSchema })\n};\nconst response$11 = z.object({ data: z.object({ variable: variableResponseSchema }) });\n\n//#endregion\n//#region ../models/src/api/env/variables/getAll.ts\nconst request$10 = { query: z.object({ applicationId: cuidSchema }) };\nconst response$10 = z.object({ data: z.object({ variables: z.array(variableResponseSchema) }) });\n\n//#endregion\n//#region ../models/src/api/env/variables/update.ts\nconst request$9 = {\n\tparams: z.object({ name: z.string().min(1) }),\n\tbody: z.object({\n\t\tapplicationId: cuidSchema,\n\t\tvalue: variableValueSchema\n\t})\n};\nconst response$9 = z.object({ data: z.object({ variable: variableResponseSchema }) });\n\n//#endregion\n//#region ../models/src/domain/expertScope.ts\nconst expertScopeSchema = z.object({\n\tid: cuidSchema,\n\tname: scopeNameSchema,\n\torganizationId: cuidSchema,\n\texpertDraftScopeId: cuidSchema,\n\tpublished: z.boolean(),\n\tpublishedAt: datetimeSchema.nullable(),\n\tcategory: expertCategoryFieldSchema,\n\ttotalRuns: z.number().int().min(0),\n\ttotalJobs: z.number().int().min(0),\n\ttotalStars: z.number().int().min(0),\n\tcreatedAt: datetimeSchema,\n\tupdatedAt: datetimeSchema,\n\tcreatedBy: cuidSchema,\n\tupdatedBy: cuidSchema\n});\nconst expertVersionSchema = z.object({\n\tid: cuidSchema,\n\texpertScopeId: cuidSchema,\n\tversion: expertVersionFieldSchema,\n\tpublic: z.boolean(),\n\tyanked: z.boolean(),\n\ttotalRuns: z.number().int().min(0),\n\ttotalJobs: z.number().int().min(0),\n\tcreatedAt: datetimeSchema,\n\tupdatedAt: datetimeSchema,\n\tcreatedBy: cuidSchema,\n\tupdatedBy: cuidSchema,\n\ttags: z.array(expertTagFieldSchema),\n\treadmeUrl: z.string().optional()\n});\nconst expertScopeWithVersionsSchema = expertScopeSchema.extend({ versions: z.array(expertVersionSchema) });\n\n//#endregion\n//#region ../models/src/domain/skill.ts\nfunction isPrivateOrLocalIP(hostname) {\n\tif (hostname === \"localhost\" || hostname === \"127.0.0.1\" || hostname === \"::1\" || hostname === \"0.0.0.0\") return true;\n\tconst ipv4Match = hostname.match(/^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$/);\n\tif (ipv4Match) {\n\t\tconst a = Number(ipv4Match[1]);\n\t\tconst b = Number(ipv4Match[2]);\n\t\tif (a === 10) return true;\n\t\tif (a === 172 && b >= 16 && b <= 31) return true;\n\t\tif (a === 192 && b === 168) return true;\n\t\tif (a === 169 && b === 254) return true;\n\t\tif (a === 127) return true;\n\t}\n\tif (hostname.includes(\":\")) {\n\t\tif (hostname.startsWith(\"fe80:\") || hostname.startsWith(\"fc\") || hostname.startsWith(\"fd\")) return true;\n\t}\n\tif (hostname.startsWith(\"::ffff:\")) {\n\t\tif (isPrivateOrLocalIP(hostname.slice(7))) return true;\n\t}\n\treturn false;\n}\nconst sseEndpointSchema = z.string().max(maxSkillEndpointLength).url().refine((url) => {\n\ttry {\n\t\tconst parsed = new URL(url);\n\t\tif (parsed.protocol !== \"https:\") return false;\n\t\tif (isPrivateOrLocalIP(parsed.hostname)) return false;\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}, { message: \"Endpoint must be a public HTTPS URL\" });\nconst skillNameSchema = z.string().min(1).max(maxSkillNameLength).regex(packageWithVersionRegex);\nconst mcpStdioSkillCommandSchema = z.enum([\"npx\", \"uvx\"]);\nconst mcpStdioSkillSchema = z.object({\n\ttype: z.literal(\"mcpStdioSkill\"),\n\tname: z.string().min(1),\n\tdescription: z.string().min(1).max(maxSkillDescriptionLength),\n\trule: z.string().min(1).max(maxSkillRuleLength).optional(),\n\tpick: z.array(z.string().min(1).max(maxSkillToolNameLength)).max(maxSkillPickOmitItems).optional().default([]),\n\tomit: z.array(z.string().min(1).max(maxSkillToolNameLength)).max(maxSkillPickOmitItems).optional().default([]),\n\tcommand: mcpStdioSkillCommandSchema,\n\tpackageName: z.string().min(1).max(maxSkillNameLength).regex(packageWithVersionRegex),\n\trequiredEnv: z.array(z.string().min(1).max(maxEnvNameLength).regex(envNameRegex)).max(maxSkillRequiredEnvItems).optional().default([])\n});\nconst mcpSseSkillSchema = z.object({\n\ttype: z.literal(\"mcpSseSkill\"),\n\tname: z.string().min(1),\n\tdescription: z.string().min(1).max(maxSkillDescriptionLength),\n\trule: z.string().min(1).max(maxSkillRuleLength).optional(),\n\tpick: z.array(z.string().min(1).max(maxSkillToolNameLength)).max(maxSkillPickOmitItems).optional().default([]),\n\tomit: z.array(z.string().min(1).max(maxSkillToolNameLength)).max(maxSkillPickOmitItems).optional().default([]),\n\tendpoint: sseEndpointSchema\n});\nconst interactiveSkillSchema = z.object({\n\ttype: z.literal(\"interactiveSkill\"),\n\tname: z.string().min(1),\n\tdescription: z.string().min(1).max(maxSkillDescriptionLength),\n\trule: z.string().min(1).max(maxSkillRuleLength).optional(),\n\ttools: z.record(z.string().min(1).max(maxSkillToolNameLength).regex(urlSafeRegex), z.object({\n\t\tdescription: z.string().min(1).max(maxSkillDescriptionLength),\n\t\tinputJsonSchema: z.string().min(1).max(maxSkillInputJsonSchemaLength)\n\t}))\n});\nconst skillSchema = z.discriminatedUnion(\"type\", [\n\tmcpStdioSkillSchema,\n\tmcpSseSkillSchema,\n\tinteractiveSkillSchema\n]);\n\n//#endregion\n//#region ../models/src/domain/expert.ts\nconst expertSchema = z.object({\n\tkey: expertKeyFieldSchema,\n\tname: expertNameFieldSchema,\n\tversion: expertVersionFieldSchema,\n\tdescription: z.string().max(maxExpertDescriptionLength).optional(),\n\tinstruction: z.string().min(1).max(maxExpertInstructionLength),\n\tskills: z.record(skillNameSchema, skillSchema).optional().default({}),\n\tdelegates: z.array(expertKeyFieldSchema).min(0).max(maxExpertDelegateItems).optional().default([]),\n\ttags: z.array(expertTagFieldSchema).min(0).max(maxExpertTagItems).optional().default([]),\n\tminRuntimeVersion: runtimeVersionSchema.optional().default(\"v1.0\")\n});\nconst expertMetadataSchema = z.object({\n\tscope: expertScopeSchema,\n\tversion: expertVersionSchema\n});\nconst expertWithMetadataSchema = expertSchema.extend({\n\tscope: expertScopeSchema,\n\tversion: expertVersionSchema\n});\n\n//#endregion\n//#region ../models/src/api/experts/getAll.ts\nconst request$8 = { query: z.object({\n\tfilter: z.string().describe(\"Filter by scope name (partial match)\").optional(),\n\tcategory: expertCategoryFieldSchema.describe(\"Filter by category\").optional(),\n\tincludeDrafts: z.coerce.boolean().default(false).describe(\"Include unpublished scopes (owner only)\").optional(),\n\ttake: z.coerce.number().min(1).max(100).default(20),\n\tskip: z.coerce.number().min(0).default(0)\n}) };\nconst response$8 = z.object({\n\tdata: z.object({ experts: z.array(expertScopeSchema.extend({ currentVersion: expertVersionSchema.nullable() })) }),\n\tmeta: paginationMeta\n});\n\n//#endregion\n//#region ../support-models/src/index.ts\nconst anthropicSupportModels = [\n\t{\n\t\tmodelId: \"claude-opus-4-6\",\n\t\tdefault: false,\n\t\tprovider: \"anthropic\",\n\t\tcontextWindow: 2e5\n\t},\n\t{\n\t\tmodelId: \"claude-opus-4-5\",\n\t\tdefault: false,\n\t\tprovider: \"anthropic\",\n\t\tcontextWindow: 2e5\n\t},\n\t{\n\t\tmodelId: \"claude-opus-4-1\",\n\t\tdefault: false,\n\t\tprovider: \"anthropic\",\n\t\tcontextWindow: 2e5\n\t},\n\t{\n\t\tmodelId: \"claude-opus-4-20250514\",\n\t\tdefault: false,\n\t\tprovider: \"anthropic\",\n\t\tcontextWindow: 2e5\n\t},\n\t{\n\t\tmodelId: \"claude-sonnet-4-5\",\n\t\tdefault: true,\n\t\tprovider: \"anthropic\",\n\t\tcontextWindow: 2e5\n\t},\n\t{\n\t\tmodelId: \"claude-sonnet-4-20250514\",\n\t\tdefault: false,\n\t\tprovider: \"anthropic\",\n\t\tcontextWindow: 2e5\n\t},\n\t{\n\t\tmodelId: \"claude-3-7-sonnet-20250219\",\n\t\tdefault: false,\n\t\tprovider: \"anthropic\",\n\t\tcontextWindow: 2e5\n\t},\n\t{\n\t\tmodelId: \"claude-haiku-4-5\",\n\t\tdefault: false,\n\t\tprovider: \"anthropic\",\n\t\tcontextWindow: 2e5\n\t},\n\t{\n\t\tmodelId: \"claude-3-5-haiku-latest\",\n\t\tdefault: false,\n\t\tprovider: \"anthropic\",\n\t\tcontextWindow: 2e5\n\t}\n];\nconst googleSupportModels = [\n\t{\n\t\tmodelId: \"gemini-3-pro-preview\",\n\t\tdefault: false,\n\t\tprovider: \"google\",\n\t\tcontextWindow: 1e6\n\t},\n\t{\n\t\tmodelId: \"gemini-2.5-pro\",\n\t\tdefault: true,\n\t\tprovider: \"google\",\n\t\tcontextWindow: 1e6\n\t},\n\t{\n\t\tmodelId: \"gemini-2.5-flash\",\n\t\tdefault: false,\n\t\tprovider: \"google\",\n\t\tcontextWindow: 1e6\n\t},\n\t{\n\t\tmodelId: \"gemini-2.5-flash-lite\",\n\t\tdefault: false,\n\t\tprovider: \"google\",\n\t\tcontextWindow: 1e6\n\t},\n\t{\n\t\tmodelId: \"gemini-3-flash-preview\",\n\t\tdefault: false,\n\t\tprovider: \"google\",\n\t\tcontextWindow: 1e6\n\t}\n];\nconst openAiSupportModels = [\n\t{\n\t\tmodelId: \"gpt-5\",\n\t\tdefault: true,\n\t\tprovider: \"openai\",\n\t\tcontextWindow: 4e5\n\t},\n\t{\n\t\tmodelId: \"gpt-5-mini\",\n\t\tdefault: false,\n\t\tprovider: \"openai\",\n\t\tcontextWindow: 4e5\n\t},\n\t{\n\t\tmodelId: \"gpt-5-nano\",\n\t\tdefault: false,\n\t\tprovider: \"openai\",\n\t\tcontextWindow: 4e5\n\t},\n\t{\n\t\tmodelId: \"gpt-5-chat-latest\",\n\t\tdefault: false,\n\t\tprovider: \"openai\",\n\t\tcontextWindow: 128e3\n\t},\n\t{\n\t\tmodelId: \"o4-mini\",\n\t\tdefault: false,\n\t\tprovider: \"openai\",\n\t\tcontextWindow: 2e5\n\t},\n\t{\n\t\tmodelId: \"o3\",\n\t\tdefault: false,\n\t\tprovider: \"openai\",\n\t\tcontextWindow: 2e5\n\t},\n\t{\n\t\tmodelId: \"o3-mini\",\n\t\tdefault: false,\n\t\tprovider: \"openai\",\n\t\tcontextWindow: 2e5\n\t},\n\t{\n\t\tmodelId: \"gpt-4.1\",\n\t\tdefault: false,\n\t\tprovider: \"openai\",\n\t\tcontextWindow: 1e6\n\t},\n\t{\n\t\tmodelId: \"gpt-5.1\",\n\t\tdefault: false,\n\t\tprovider: \"openai\",\n\t\tcontextWindow: 4e5\n\t},\n\t{\n\t\tmodelId: \"gpt-5.2\",\n\t\tdefault: false,\n\t\tprovider: \"openai\",\n\t\tcontextWindow: 4e5\n\t},\n\t{\n\t\tmodelId: \"gpt-5.2-pro\",\n\t\tdefault: false,\n\t\tprovider: \"openai\",\n\t\tcontextWindow: 4e5\n\t}\n];\nconst deepseekSupportModels = [{\n\tmodelId: \"deepseek-chat\",\n\tdefault: true,\n\tprovider: \"deepseek\",\n\tcontextWindow: 128e3\n}, {\n\tmodelId: \"deepseek-reasoner\",\n\tdefault: false,\n\tprovider: \"deepseek\",\n\tcontextWindow: 128e3\n}];\nconst allSupportModels = [\n\t...anthropicSupportModels,\n\t...googleSupportModels,\n\t...openAiSupportModels,\n\t...deepseekSupportModels\n];\nconst supportModels = Object.fromEntries(allSupportModels.map((model) => [model.modelId, model]));\nfunction getSupportModelNames() {\n\treturn Object.keys(supportModels);\n}\n\n//#endregion\n//#region ../models/src/domain/job.ts\nconst reasoningBudgetSchema = z.union([z.enum([\n\t\"none\",\n\t\"minimal\",\n\t\"low\",\n\t\"medium\",\n\t\"high\"\n]), z.number().int().min(0)]);\nconst jobStatusSchema = z.enum([\n\t\"queued\",\n\t\"processing\",\n\t\"completed\",\n\t\"requestInteractiveToolResult\",\n\t\"requestDelegateResult\",\n\t\"exceededMaxSteps\",\n\t\"failed\",\n\t\"canceling\",\n\t\"canceled\",\n\t\"expired\"\n]);\nconst modelNames = getSupportModelNames();\nconst firstModel = modelNames[0];\nif (firstModel === void 0) throw new Error(\"No support models available\");\nconst jobModelSchema = z.enum([firstModel, ...modelNames.slice(1)]);\nconst jobBaseSchema = z.object({\n\ttype: z.literal(\"job\"),\n\tid: cuidSchema,\n\torganizationId: cuidSchema,\n\tapplicationId: cuidSchema,\n\tcreatedAt: datetimeSchema,\n\tupdatedAt: datetimeSchema,\n\tstatus: jobStatusSchema,\n\tcurrentExecutionId: cuidSchema.optional(),\n\tmachineId: cuidSchema.nullable(),\n\tcoordinatorExpertKey: expertKeyFieldSchema,\n\tquery: z.string().min(1).max(maxExpertJobQueryLength).optional(),\n\texpert: expertWithMetadataSchema,\n\tprovider: providerSchema,\n\tmodel: jobModelSchema,\n\treasoningBudget: reasoningBudgetSchema,\n\truntimeVersion: runtimeVersionSchema,\n\tmaxSteps: z.number().int().min(1),\n\tmaxRetries: z.number().int().min(0),\n\tcurrentStep: z.number().int().min(0),\n\ttotalSteps: z.number().int().min(0),\n\ttotalDuration: z.number().int().min(0),\n\tusage: usageSchema,\n\tlastActivity: activityOrGroupSchema.nullable().optional()\n});\nconst publishedJobSchema = jobBaseSchema.extend({\n\texpertVersionId: cuidSchema,\n\texpertDraftRefId: z.undefined()\n});\nconst draftJobSchema = jobBaseSchema.extend({\n\texpertVersionId: z.undefined(),\n\texpertDraftRefId: cuidSchema\n});\nconst jobSchema = z.union([publishedJobSchema, draftJobSchema]);\n\n//#endregion\n//#region ../models/src/api/jobs/continue.ts\nconst request$7 = {\n\tparams: z.object({ jobId: cuidSchema }),\n\tbody: z.object({\n\t\tquery: z.string().min(1).max(maxExpertJobQueryLength),\n\t\tprovider: providerSchema.optional(),\n\t\tmodel: jobModelSchema.optional(),\n\t\treasoningBudget: reasoningBudgetSchema.optional(),\n\t\tmaxSteps: z.coerce.number().optional(),\n\t\tmaxRetries: z.coerce.number().optional()\n\t})\n};\nconst response$7 = z.object({ data: z.object({ job: jobSchema }) });\n\n//#endregion\n//#region ../models/src/api/jobs/create.ts\nconst baseBodySchema = z.object({\n\tapplicationId: cuidSchema.describe(\"Application ID to create the job in\"),\n\tquery: z.string().min(1).max(maxExpertJobQueryLength),\n\tprovider: providerSchema,\n\tmodel: jobModelSchema.optional(),\n\treasoningBudget: reasoningBudgetSchema.optional(),\n\tmaxSteps: z.coerce.number().optional(),\n\tmaxRetries: z.coerce.number().optional()\n});\nconst request$6 = { body: baseBodySchema.extend({\n\texpertKey: expertKeyFieldSchema.optional(),\n\tdraftRefId: cuidSchema.describe(\"Draft ref ID to run the job with\").optional()\n}).refine((data) => {\n\tconst hasExpertKey = data.expertKey !== void 0;\n\tconst hasDraftRefId = data.draftRefId !== void 0;\n\treturn hasExpertKey && !hasDraftRefId || !hasExpertKey && hasDraftRefId;\n}, { message: \"Either expertKey or draftRefId must be provided, but not both\" }) };\nconst response$6 = z.object({ data: z.object({ job: jobSchema }) });\n\n//#endregion\n//#region ../models/src/api/jobs/getAll.ts\nconst request$5 = { query: z.object({\n\tsort: z.enum([\"createdAt\", \"updatedAt\"]).optional(),\n\torder: z.enum([\"asc\", \"desc\"]).optional(),\n\ttake: z.coerce.number().min(1).max(100).default(20),\n\tskip: z.coerce.number().min(0).default(0),\n\texpertScopeId: cuidSchema.optional(),\n\texpertDraftScopeId: cuidSchema.optional(),\n\tapplicationId: cuidSchema.optional(),\n\tstatuses: z.preprocess((val) => typeof val === \"string\" ? val.split(\",\") : val, z.array(jobStatusSchema)).optional(),\n\texpertKeyFilter: z.string().max(100).optional()\n}) };\nconst response$5 = z.object({\n\tdata: z.object({ jobs: z.array(jobSchema) }),\n\tmeta: paginationMeta\n});\n\n//#endregion\n//#region ../models/src/domain/checkpoint.ts\nconst delegationTargetSchema = z.object({\n\texpert: expertSchema,\n\ttoolCallId: z.string().min(1).max(maxCheckpointToolCallIdLength),\n\ttoolName: z.string().min(1).max(maxSkillToolNameLength),\n\tquery: z.string().min(1)\n});\n/**\n* API Checkpoint schema - extended checkpoint format for API responses.\n* Includes additional fields computed from runtime checkpoint and step data:\n* - activities: computed via getActivities() from @perstack/core\n* - inputMessages, newMessages, toolCalls, toolResults: step-related data\n* - expert: full Expert type (with instruction, skills, etc.)\n* - startedAt/finishedAt: ISO string format (runtime uses Unix timestamps)\n*/\nconst apiCheckpointSchema = z.object({\n\ttype: z.literal(\"checkpoint\"),\n\tid: cuidSchema,\n\tjobId: cuidSchema,\n\trunId: cuidSchema,\n\tactivities: z.array(activityOrGroupSchema),\n\tstepNumber: z.number().int().min(1),\n\tstatus: z.enum([\n\t\t\"init\",\n\t\t\"proceeding\",\n\t\t\"completed\",\n\t\t\"stoppedByInteractiveTool\",\n\t\t\"stoppedByDelegate\",\n\t\t\"stoppedByExceededMaxSteps\",\n\t\t\"stoppedByError\",\n\t\t\"stoppedByCancellation\"\n\t]),\n\texpert: expertSchema,\n\tdelegateTo: z.array(delegationTargetSchema).optional(),\n\tdelegatedBy: z.object({\n\t\texpert: expertSchema,\n\t\ttoolCallId: z.string().min(1).max(maxCheckpointToolCallIdLength),\n\t\ttoolName: z.string().min(1).max(maxSkillToolNameLength),\n\t\tcheckpointId: cuidSchema,\n\t\trunId: cuidSchema\n\t}).optional(),\n\tinputMessages: z.array(z.union([\n\t\tinstructionMessageSchema,\n\t\tuserMessageSchema,\n\t\ttoolMessageSchema\n\t])).optional(),\n\tmessages: z.array(messageSchema),\n\tnewMessages: z.array(messageSchema),\n\ttoolCalls: z.array(toolCallSchema).optional(),\n\ttoolResults: z.array(toolResultSchema).optional(),\n\tpendingToolCalls: z.array(toolCallSchema).optional(),\n\tpartialToolResults: z.array(toolResultSchema).optional(),\n\tusage: usageSchema,\n\tcontextWindow: z.number().int().min(0).optional(),\n\tcontextWindowUsage: z.number().int().min(0).optional(),\n\terror: z.object({\n\t\tname: z.string().min(1),\n\t\tmessage: z.string().min(1),\n\t\tstatusCode: z.number().int().min(100).max(599).optional(),\n\t\tisRetryable: z.boolean()\n\t}).optional(),\n\tretryCount: z.number().int().min(0).optional(),\n\tstartedAt: datetimeSchema,\n\tfinishedAt: datetimeSchema.optional()\n});\n\n//#endregion\n//#region ../models/src/api/jobs/runs/checkpoints/getAll.ts\nconst request$4 = {\n\tparams: z.object({\n\t\tjobId: cuidSchema,\n\t\trunId: cuidSchema\n\t}),\n\tquery: z.object({\n\t\tfilter: z.string().min(1).max(256).optional(),\n\t\tsort: z.enum([\"createdAt\", \"updatedAt\"]).optional(),\n\t\torder: z.enum([\"asc\", \"desc\"]).optional(),\n\t\ttake: z.coerce.number().min(1).max(100).default(20),\n\t\tskip: z.coerce.number().min(0).default(0)\n\t})\n};\nconst response$4 = z.object({\n\tdata: z.object({ checkpoints: z.array(apiCheckpointSchema) }),\n\tmeta: paginationMeta\n});\n\n//#endregion\n//#region ../models/src/domain/run.ts\nconst runSchema = z.object({\n\ttype: z.literal(\"run\"),\n\tid: cuidSchema,\n\tjobId: cuidSchema,\n\texecutionId: cuidSchema.optional(),\n\tparentRunId: cuidSchema.optional(),\n\torganizationId: cuidSchema,\n\tcreatedAt: datetimeSchema,\n\tupdatedAt: datetimeSchema,\n\texpertKey: expertKeyFieldSchema,\n\texpert: expertWithMetadataSchema,\n\tstepNumber: z.number().int().min(0),\n\tusage: usageSchema\n});\nconst runTreeNodeSchema = runSchema.extend({\n\tlastCheckpointId: cuidSchema.nullable(),\n\tcheckpointIds: z.array(cuidSchema),\n\tchildRuns: z.lazy(() => z.array(runTreeNodeSchema))\n});\n\n//#endregion\n//#region ../models/src/api/jobs/runs/getAll.ts\nconst request$3 = {\n\tparams: z.object({ jobId: cuidSchema }),\n\tquery: z.object({\n\t\tsort: z.enum([\"createdAt\", \"updatedAt\"]).optional(),\n\t\torder: z.enum([\"asc\", \"desc\"]).optional(),\n\t\ttake: z.coerce.number().min(1).max(100).default(20),\n\t\tskip: z.coerce.number().min(0).default(0),\n\t\tdepth: z.coerce.number().int().min(0).max(10).default(0)\n\t})\n};\nconst response$3 = z.object({\n\tdata: z.object({ runs: z.array(runTreeNodeSchema) }),\n\tmeta: paginationMeta\n});\n\n//#endregion\n//#region ../models/src/domain/providerSetting.ts\nconst baseUrlSchema = z.string().url().max(maxProviderBaseUrlLength).optional();\nconst headersSchema = z.record(z.string().min(1).max(maxProviderHeaderKeyLength), z.string().max(maxProviderHeaderValueLength)).refine((headers) => Object.keys(headers).length <= maxProviderHeadersCount, { message: `Headers must have at most ${maxProviderHeadersCount} entries` }).optional();\nconst anthropicProviderSettingsSchema = z.object({\n\tbaseUrl: baseUrlSchema,\n\theaders: headersSchema\n});\nconst googleProviderSettingsSchema = z.object({\n\tbaseUrl: baseUrlSchema,\n\theaders: headersSchema\n});\nconst openaiProviderSettingsSchema = z.object({\n\tbaseUrl: baseUrlSchema,\n\theaders: headersSchema,\n\torganization: z.string().min(1).optional(),\n\tproject: z.string().min(1).optional(),\n\tname: z.string().min(1).optional()\n});\nconst deepseekProviderSettingsSchema = z.object({\n\tbaseUrl: baseUrlSchema,\n\theaders: headersSchema\n});\nconst azureOpenaiProviderSettingsSchema = z.object({\n\tbaseUrl: baseUrlSchema,\n\theaders: headersSchema,\n\tresourceName: z.string().min(1).optional(),\n\tapiVersion: z.string().min(1).optional(),\n\tuseDeploymentBasedUrls: z.boolean().optional()\n});\nconst amazonBedrockProviderSettingsSchema = z.object({ region: z.string().min(1).optional() });\nconst googleVertexProviderSettingsSchema = z.object({\n\tbaseUrl: baseUrlSchema,\n\theaders: headersSchema,\n\tproject: z.string().min(1).optional(),\n\tlocation: z.string().min(1).optional()\n});\nconst providerSettingsSchema = z.union([\n\tanthropicProviderSettingsSchema,\n\tgoogleProviderSettingsSchema,\n\topenaiProviderSettingsSchema,\n\tdeepseekProviderSettingsSchema,\n\tazureOpenaiProviderSettingsSchema,\n\tamazonBedrockProviderSettingsSchema,\n\tgoogleVertexProviderSettingsSchema\n]);\nconst providerSettingSchema = z.object({\n\ttype: z.literal(\"providerSetting\"),\n\tid: cuidSchema,\n\tapplicationId: cuidSchema,\n\tprovider: providerSchema,\n\tsettings: providerSettingsSchema.optional(),\n\tapplication: applicationSchema,\n\tcreatedAt: datetimeSchema,\n\tupdatedAt: datetimeSchema\n});\nconst providerSettingResponseSchema = z.object({\n\ttype: z.literal(\"providerSetting\"),\n\tid: cuidSchema,\n\tprovider: providerSchema,\n\tsettings: providerSettingsSchema.optional(),\n\tcreatedAt: datetimeSchema,\n\tupdatedAt: datetimeSchema\n});\nconst providerApiKeyMetadataSchema = z.object({\n\tid: cuidSchema,\n\tname: z.string(),\n\tcreatedAt: datetimeSchema,\n\tupdatedAt: datetimeSchema,\n\tlastUsedAt: datetimeSchema.nullable(),\n\texpiresAt: datetimeSchema.nullable()\n});\n\n//#endregion\n//#region ../models/src/api/provider-settings/api-keys/create.ts\nconst request$2 = {\n\tparams: z.object({\n\t\tapplicationId: cuidSchema,\n\t\tprovider: providerSchema\n\t}),\n\tbody: z.object({\n\t\tname: z.string().min(1).max(255),\n\t\tvalue: z.string().min(1)\n\t})\n};\nconst response$2 = z.object({ data: z.object({ apiKey: providerApiKeyMetadataSchema }) });\n\n//#endregion\n//#region ../models/src/api/provider-settings/create.ts\nconst request$1 = {\n\tparams: z.object({ applicationId: cuidSchema }),\n\tbody: z.object({\n\t\tprovider: providerSchema,\n\t\tsettings: providerSettingsSchema.optional()\n\t})\n};\nconst response$1 = z.object({ data: z.object({ providerSetting: providerSettingResponseSchema }) });\n\n//#endregion\n//#region ../models/src/api/provider-settings/update.ts\nconst request = {\n\tparams: z.object({\n\t\tapplicationId: cuidSchema,\n\t\tprovider: providerSchema\n\t}),\n\tbody: z.object({ settings: providerSettingsSchema.optional() })\n};\nconst response = z.object({ data: z.object({ providerSetting: providerSettingResponseSchema }) });\n\n//#endregion\n//#region src/endpoints/jobs-runs-checkpoints.ts\nfunction createRunCheckpointsApi(fetcher, basePath) {\n\treturn {\n\t\tasync list(jobId, runId, params, options) {\n\t\t\tif (params) {\n\t\t\t\tconst result = request$4.query.safeParse(params);\n\t\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\t}\n\t\t\tconst queryString = buildQueryString(params);\n\t\t\treturn fetcher.get(`${basePath}/${jobId}/runs/${runId}/checkpoints${queryString}`, options);\n\t\t},\n\t\tasync get(jobId, runId, checkpointId, options) {\n\t\t\treturn fetcher.get(`${basePath}/${jobId}/runs/${runId}/checkpoints/${checkpointId}`, options);\n\t\t}\n\t};\n}\n\n//#endregion\n//#region src/endpoints/jobs-runs.ts\nfunction createListFn(fetcher, basePath) {\n\treturn async function list(jobId, params, options) {\n\t\tif (params) {\n\t\t\tconst result = request$3.query.safeParse(params);\n\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t}\n\t\tconst queryString = buildQueryString(params);\n\t\treturn fetcher.get(`${basePath}/${jobId}/runs${queryString}`, options);\n\t};\n}\nfunction createRunsApi(fetcher, basePath) {\n\treturn {\n\t\tlist: createListFn(fetcher, basePath),\n\t\tasync get(jobId, runId, options) {\n\t\t\treturn fetcher.get(`${basePath}/${jobId}/runs/${runId}`, options);\n\t\t},\n\t\tcheckpoints: createRunCheckpointsApi(fetcher, basePath)\n\t};\n}\n\n//#endregion\n//#region src/endpoints/jobs.ts\nconst BASE_PATH$6 = \"/api/v1/jobs\";\n/**\n* Error thrown when stream ends abnormally.\n*/\nvar StreamError = class extends Error {\n\tconstructor(type, jobId, message) {\n\t\tsuper(message ?? `Stream error: ${type}`);\n\t\tthis.type = type;\n\t\tthis.jobId = jobId;\n\t\tthis.name = \"StreamError\";\n\t}\n};\n/**\n* Error thrown when stream connection or reading fails.\n*/\nvar StreamConnectionError = class extends Error {\n\tconstructor(message) {\n\t\tsuper(message);\n\t\tthis.name = \"StreamConnectionError\";\n\t}\n};\nfunction isErrorEventData(data) {\n\treturn typeof data === \"object\" && data !== null && \"type\" in data && typeof data.type === \"string\" && \"jobId\" in data && typeof data.jobId === \"string\";\n}\nfunction isCompleteEventData(data) {\n\treturn typeof data === \"object\" && data !== null && \"status\" in data && typeof data.status === \"string\" && \"jobId\" in data && typeof data.jobId === \"string\";\n}\nfunction createJobsApi(fetcher) {\n\treturn {\n\t\tasync list(params, options) {\n\t\t\tif (params) {\n\t\t\t\tconst result = request$5.query.safeParse(params);\n\t\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\t}\n\t\t\tconst queryString = buildQueryString(params);\n\t\t\treturn fetcher.get(`${BASE_PATH$6}${queryString}`, options);\n\t\t},\n\t\tasync get(id, options) {\n\t\t\treturn fetcher.get(`${BASE_PATH$6}/${id}`, options);\n\t\t},\n\t\tasync start(input, options) {\n\t\t\tconst result = request$6.body.safeParse(input);\n\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\treturn fetcher.post(BASE_PATH$6, input, options);\n\t\t},\n\t\tasync continue(id, input, options) {\n\t\t\tconst result = request$7.body.safeParse(input);\n\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\treturn fetcher.post(`${BASE_PATH$6}/${id}/continue`, input, options);\n\t\t},\n\t\tasync cancel(id, options) {\n\t\t\treturn fetcher.post(`${BASE_PATH$6}/${id}/cancel`, {}, options);\n\t\t},\n\t\tasync stream(id, options) {\n\t\t\tconst result = await fetcher.getStream(`${BASE_PATH$6}/${id}/stream`, options);\n\t\t\tif (!result.ok) return result;\n\t\t\tasync function* createEventGenerator(reader) {\n\t\t\t\ttry {\n\t\t\t\t\tfor await (const sseEvent of parseSSEEvents(reader)) if (sseEvent.event === \"message\") yield sseEvent.data;\n\t\t\t\t\telse if (sseEvent.event === \"error\" && isErrorEventData(sseEvent.data)) throw new StreamError(sseEvent.data.type, sseEvent.data.jobId, sseEvent.data.message);\n\t\t\t\t\telse if (sseEvent.event === \"complete\" && isCompleteEventData(sseEvent.data)) return;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof StreamError || error instanceof StreamConnectionError) throw error;\n\t\t\t\t\tif (error instanceof DOMException && error.name === \"AbortError\") throw error;\n\t\t\t\t\tthrow new StreamConnectionError(error instanceof Error ? error.message : \"Stream read error\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst reader = result.data.getReader();\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tstatus: result.status,\n\t\t\t\theaders: result.headers,\n\t\t\t\tdata: { events: createEventGenerator(reader) }\n\t\t\t};\n\t\t},\n\t\truns: createRunsApi(fetcher, BASE_PATH$6)\n\t};\n}\n\n//#endregion\n//#region src/endpoints/applications.ts\nconst BASE_PATH$5 = \"/api/v1/applications\";\nfunction createApplicationsApi(fetcher) {\n\treturn {\n\t\tasync list(params, options) {\n\t\t\tif (params) {\n\t\t\t\tconst result = request$20.query.safeParse(params);\n\t\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\t}\n\t\t\tconst queryString = buildQueryString(params);\n\t\t\treturn fetcher.get(`${BASE_PATH$5}${queryString}`, options);\n\t\t},\n\t\tasync get(id, options) {\n\t\t\treturn fetcher.get(`${BASE_PATH$5}/${id}`, options);\n\t\t},\n\t\tasync create(input, options) {\n\t\t\tconst result = request$21.body.safeParse(input);\n\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\treturn fetcher.post(BASE_PATH$5, input, options);\n\t\t},\n\t\tasync update(id, input, options) {\n\t\t\tconst result = request$19.body.safeParse(input);\n\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\treturn fetcher.post(`${BASE_PATH$5}/${id}`, input, options);\n\t\t},\n\t\tasync delete(id, options) {\n\t\t\treturn fetcher.delete(`${BASE_PATH$5}/${id}`, options);\n\t\t}\n\t};\n}\n\n//#endregion\n//#region src/endpoints/env-secrets.ts\nconst BASE_PATH$4 = \"/api/v1/env/secrets\";\nfunction createSecretsApi(fetcher) {\n\treturn {\n\t\tasync list(params, options) {\n\t\t\tif (params) {\n\t\t\t\tconst result = request$15.query.safeParse(params);\n\t\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\t}\n\t\t\tconst queryString = buildQueryString(params);\n\t\t\treturn fetcher.get(`${BASE_PATH$4}${queryString}`, options);\n\t\t},\n\t\tasync get(name, params, options) {\n\t\t\tconst result = request$16.query.safeParse(params);\n\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\tconst encodedName = encodeURIComponent(name);\n\t\t\tconst queryString = buildQueryString(params);\n\t\t\treturn fetcher.get(`${BASE_PATH$4}/${encodedName}${queryString}`, options);\n\t\t},\n\t\tasync create(input, options) {\n\t\t\tconst result = request$18.body.safeParse(input);\n\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\treturn fetcher.post(BASE_PATH$4, input, options);\n\t\t},\n\t\tasync update(name, input, options) {\n\t\t\tconst result = request$14.body.safeParse(input);\n\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\tconst encodedName = encodeURIComponent(name);\n\t\t\treturn fetcher.post(`${BASE_PATH$4}/${encodedName}`, input, options);\n\t\t},\n\t\tasync delete(name, params, options) {\n\t\t\tconst result = request$17.query.safeParse(params);\n\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\tconst encodedName = encodeURIComponent(name);\n\t\t\tconst queryString = buildQueryString(params);\n\t\t\treturn fetcher.deleteNoContent(`${BASE_PATH$4}/${encodedName}${queryString}`, options);\n\t\t}\n\t};\n}\n\n//#endregion\n//#region src/endpoints/env-variables.ts\nconst BASE_PATH$3 = \"/api/v1/env/variables\";\nfunction createVariablesApi(fetcher) {\n\treturn {\n\t\tasync list(params, options) {\n\t\t\tconst result = request$10.query.safeParse(params);\n\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\tconst queryString = buildQueryString(params);\n\t\t\treturn fetcher.get(`${BASE_PATH$3}${queryString}`, options);\n\t\t},\n\t\tasync get(name, params, options) {\n\t\t\tconst result = request$11.query.safeParse(params);\n\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\tconst encodedName = encodeURIComponent(name);\n\t\t\tconst queryString = buildQueryString(params);\n\t\t\treturn fetcher.get(`${BASE_PATH$3}/${encodedName}${queryString}`, options);\n\t\t},\n\t\tasync create(input, options) {\n\t\t\tconst result = request$13.body.safeParse(input);\n\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\treturn fetcher.post(BASE_PATH$3, input, options);\n\t\t},\n\t\tasync update(name, input, options) {\n\t\t\tconst result = request$9.body.safeParse(input);\n\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\tconst encodedName = encodeURIComponent(name);\n\t\t\treturn fetcher.post(`${BASE_PATH$3}/${encodedName}`, input, options);\n\t\t},\n\t\tasync delete(name, params, options) {\n\t\t\tconst result = request$12.query.safeParse(params);\n\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\tconst encodedName = encodeURIComponent(name);\n\t\t\tconst queryString = buildQueryString(params);\n\t\t\treturn fetcher.deleteNoContent(`${BASE_PATH$3}/${encodedName}${queryString}`, options);\n\t\t}\n\t};\n}\n\n//#endregion\n//#region src/endpoints/env.ts\nfunction createEnvApi(fetcher) {\n\treturn {\n\t\tsecrets: createSecretsApi(fetcher),\n\t\tvariables: createVariablesApi(fetcher)\n\t};\n}\n\n//#endregion\n//#region src/endpoints/experts-versions.ts\nfunction createVersionsApi(fetcher, basePath) {\n\treturn { async list(scopeName, options) {\n\t\tconst encodedScopeName = encodeURIComponent(scopeName);\n\t\treturn fetcher.get(`${basePath}/${encodedScopeName}/versions`, options);\n\t} };\n}\n\n//#endregion\n//#region src/endpoints/experts.ts\nconst BASE_PATH$2 = \"/api/v1/experts\";\nfunction createExpertsApi(fetcher) {\n\treturn {\n\t\tasync list(params, options) {\n\t\t\tif (params) {\n\t\t\t\tconst result = request$8.query.safeParse(params);\n\t\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\t}\n\t\t\tconst queryString = buildQueryString(params);\n\t\t\treturn fetcher.get(`${BASE_PATH$2}${queryString}`, options);\n\t\t},\n\t\tasync get(key, options) {\n\t\t\tconst encodedKey = encodeURIComponent(key);\n\t\t\treturn fetcher.get(`${BASE_PATH$2}/${encodedKey}`, options);\n\t\t},\n\t\tasync getFeatured(options) {\n\t\t\treturn fetcher.get(`${BASE_PATH$2}/featured`, options);\n\t\t},\n\t\tasync getMeta(key, options) {\n\t\t\tconst encodedKey = encodeURIComponent(key);\n\t\t\treturn fetcher.get(`${BASE_PATH$2}/${encodedKey}/meta`, options);\n\t\t},\n\t\tasync publish(scopeName, options) {\n\t\t\tconst encodedScopeName = encodeURIComponent(scopeName);\n\t\t\treturn fetcher.post(`${BASE_PATH$2}/${encodedScopeName}/publish`, {}, options);\n\t\t},\n\t\tasync unpublish(scopeName, options) {\n\t\t\tconst encodedScopeName = encodeURIComponent(scopeName);\n\t\t\treturn fetcher.post(`${BASE_PATH$2}/${encodedScopeName}/unpublish`, {}, options);\n\t\t},\n\t\tasync yank(key, options) {\n\t\t\tconst encodedKey = encodeURIComponent(key);\n\t\t\treturn fetcher.delete(`${BASE_PATH$2}/${encodedKey}`, options);\n\t\t},\n\t\tversions: createVersionsApi(fetcher, BASE_PATH$2)\n\t};\n}\n\n//#endregion\n//#region src/endpoints/organizations.ts\nconst BASE_PATH$1 = \"/api/v1/organizations\";\nfunction createOrganizationsApi(fetcher) {\n\treturn { async getCurrent(options) {\n\t\treturn fetcher.get(`${BASE_PATH$1}/current`, options);\n\t} };\n}\n\n//#endregion\n//#region src/endpoints/provider-settings.ts\nconst BASE_PATH = \"/api/v1/applications\";\nfunction createProviderSettingsApi(fetcher) {\n\treturn {\n\t\tasync list(applicationId, options) {\n\t\t\treturn fetcher.get(`${BASE_PATH}/${applicationId}/provider_settings`, options);\n\t\t},\n\t\tasync get(applicationId, provider, options) {\n\t\t\tconst encodedProvider = encodeURIComponent(provider);\n\t\t\treturn fetcher.get(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}`, options);\n\t\t},\n\t\tasync create(applicationId, input, options) {\n\t\t\tconst result = request$1.body.safeParse(input);\n\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\treturn fetcher.post(`${BASE_PATH}/${applicationId}/provider_settings`, input, options);\n\t\t},\n\t\tasync update(applicationId, provider, input, options) {\n\t\t\tconst result = request.body.safeParse(input);\n\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\tconst encodedProvider = encodeURIComponent(provider);\n\t\t\treturn fetcher.post(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}`, input, options);\n\t\t},\n\t\tasync delete(applicationId, provider, options) {\n\t\t\tconst encodedProvider = encodeURIComponent(provider);\n\t\t\treturn fetcher.deleteNoContent(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}`, options);\n\t\t},\n\t\tasync listApiKeys(applicationId, provider, options) {\n\t\t\tconst encodedProvider = encodeURIComponent(provider);\n\t\t\treturn fetcher.get(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}/api_keys`, options);\n\t\t},\n\t\tasync createApiKey(applicationId, provider, input, options) {\n\t\t\tconst result = request$2.body.safeParse(input);\n\t\t\tif (!result.success) return validationErrorResult(result.error);\n\t\t\tconst encodedProvider = encodeURIComponent(provider);\n\t\t\treturn fetcher.post(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}/api_keys`, input, options);\n\t\t},\n\t\tasync deleteApiKey(applicationId, provider, apiKeyId, options) {\n\t\t\tconst encodedProvider = encodeURIComponent(provider);\n\t\t\tconst encodedApiKeyId = encodeURIComponent(apiKeyId);\n\t\t\treturn fetcher.deleteNoContent(`${BASE_PATH}/${applicationId}/provider_settings/${encodedProvider}/api_keys/${encodedApiKeyId}`, options);\n\t\t}\n\t};\n}\n\n//#endregion\n//#region src/public/client.ts\nfunction createApiClient(config) {\n\tconst fetcher = createFetcher(config);\n\treturn {\n\t\tapplications: createApplicationsApi(fetcher),\n\t\tenv: createEnvApi(fetcher),\n\t\tjobs: createJobsApi(fetcher),\n\t\texperts: createExpertsApi(fetcher),\n\t\torganizations: createOrganizationsApi(fetcher),\n\t\tproviderSettings: createProviderSettingsApi(fetcher)\n\t};\n}\n\n//#endregion\nexport { StreamConnectionError, StreamError, buildAuthHeaders, buildQueryString, createAbortError, createApiClient, createFetcher, createHttpError, createNetworkError, createTimeoutError, createValidationError, handleHttpError, isAbortError, isClientError, isHttpError, isNetworkError, isTimeoutError, isValidationError, matchExperts, matchOperations, matchWildcard, parseApiKeyPermissions, parseSSE, parseSSEEvents, stringifyApiKeyPermissions, validationErrorResult };\n//# sourceMappingURL=index.mjs.map","import { createApiClient } from \"@perstack/api-client\"\nimport { type Expert, PerstackError, type RuntimeVersion, type Skill } from \"@perstack/core\"\n\nexport async function resolveExpertToRun(\n expertKey: string,\n experts: Record<string, Expert>,\n clientOptions: {\n perstackApiBaseUrl: string\n perstackApiKey?: string\n },\n): Promise<Expert> {\n if (experts[expertKey]) {\n return experts[expertKey]\n }\n if (!clientOptions.perstackApiKey) {\n throw new PerstackError(\n `PERSTACK_API_KEY is required to resolve published expert \"${expertKey}\"`,\n )\n }\n const client = createApiClient({\n baseUrl: clientOptions.perstackApiBaseUrl,\n apiKey: clientOptions.perstackApiKey,\n })\n const result = await client.experts.get(expertKey)\n if (!result.ok) {\n throw new PerstackError(`Failed to resolve expert \"${expertKey}\": ${result.error.message}`)\n }\n const publishedExpert = result.data.data.definition.experts[expertKey]\n if (!publishedExpert) {\n throw new PerstackError(`Expert \"${expertKey}\" not found in API response`)\n }\n return toRuntimeExpert(expertKey, publishedExpert)\n}\n\nfunction toRuntimeExpert(\n key: string,\n expert: {\n name: string\n version: string\n minRuntimeVersion?: RuntimeVersion\n description?: string\n instruction: string\n skills?: Record<\n string,\n | {\n type: \"mcpStdioSkill\"\n name: string\n description: string\n rule?: string\n pick?: string[]\n omit?: string[]\n command: \"npx\" | \"uvx\"\n packageName: string\n requiredEnv?: string[]\n }\n | {\n type: \"mcpSseSkill\"\n name: string\n description: string\n rule?: string\n pick?: string[]\n omit?: string[]\n endpoint: string\n }\n | {\n type: \"interactiveSkill\"\n name: string\n description: string\n rule?: string\n tools: Record<string, { description: string; inputJsonSchema: string }>\n }\n >\n delegates?: string[]\n tags?: string[]\n },\n): Expert {\n const skills: Record<string, Skill> = Object.fromEntries(\n Object.entries(expert.skills ?? {}).map(([name, skill]) => {\n switch (skill.type) {\n case \"mcpStdioSkill\":\n return [\n name,\n {\n type: skill.type,\n name,\n description: skill.description,\n rule: skill.rule,\n pick: skill.pick ?? [],\n omit: skill.omit ?? [],\n command: skill.command,\n packageName: skill.packageName,\n requiredEnv: skill.requiredEnv ?? [],\n },\n ]\n case \"mcpSseSkill\":\n return [\n name,\n {\n type: skill.type,\n name,\n description: skill.description,\n rule: skill.rule,\n pick: skill.pick ?? [],\n omit: skill.omit ?? [],\n endpoint: skill.endpoint,\n },\n ]\n case \"interactiveSkill\":\n return [\n name,\n {\n type: skill.type,\n name,\n description: skill.description,\n rule: skill.rule,\n tools: Object.fromEntries(\n Object.entries(skill.tools).map(([toolName, tool]) => [\n toolName,\n {\n name: toolName,\n description: tool.description,\n inputSchema: JSON.parse(tool.inputJsonSchema),\n },\n ]),\n ),\n },\n ]\n default: {\n throw new PerstackError(`Unknown skill type: ${(skill as { type: string }).type}`)\n }\n }\n }),\n )\n return {\n key,\n name: expert.name,\n version: expert.version,\n minRuntimeVersion: expert.minRuntimeVersion ?? \"v1.0\",\n description: expert.description ?? \"\",\n instruction: expert.instruction,\n skills,\n delegates: expert.delegates ?? [],\n tags: expert.tags ?? [],\n }\n}\n"],"x_google_ignoreList":[0],"mappings":";;;AA2CA,SAAS,sBAAsB,OAAO;AACrC,QAAO;EACN,MAAM;EACN,SAAS,sBAAsB,MAAM,OAAO,KAAK,UAAU,GAAG,MAAM,KAAK,KAAK,IAAI,CAAC,IAAI,MAAM,UAAU,CAAC,KAAK,KAAK;EAClH,QAAQ,MAAM;EACd;;AAEF,SAAS,sBAAsB,OAAO;AACrC,QAAO;EACN,IAAI;EACJ,QAAQ;EACR,SAAS,IAAI,SAAS;EACtB,OAAO,sBAAsB,MAAM;EACnC;;AAEF,SAAS,mBAAmB;AAC3B,QAAO;EACN,MAAM;EACN,SAA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AAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;AACD,MAAM,sBAAsB;CAC3B;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;AACD,MAAM,sBAAsB;CAC3B;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS;EACT,UAAU;EACV,eAAe;EACf;CACD;EACC,SAAS;EACT,SAAS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c,uBAAwB,MAA2B,OAAO;;GAGtF,CACH;AACD,QAAO;EACL;EACA,MAAM,OAAO;EACb,SAAS,OAAO;EAChB,mBAAmB,OAAO,qBAAqB;EAC/C,aAAa,OAAO,eAAe;EACnC,aAAa,OAAO;EACpB;EACA,WAAW,OAAO,aAAa,EAAE;EACjC,MAAM,OAAO,QAAQ,EAAE;EACxB"}
@@ -1577,7 +1577,6 @@ const expertNameRegex = /^(@[a-z0-9][a-z0-9_-]*\/)?[a-z0-9][a-z0-9_-]*$/;
1577
1577
  const expertVersionRegex = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\w.-]+)?(?:\+[\w.-]+)?$/;
1578
1578
  const tagNameRegex = /^[a-z0-9][a-z0-9_-]*$/;
1579
1579
  const maxExpertNameLength = 255;
1580
- const defaultMaxSteps = 100;
1581
1580
  const defaultMaxRetries = 5;
1582
1581
  const defaultTimeout = 5 * 1e3 * 60;
1583
1582
  const maxSkillNameLength = 255;
@@ -6246,6 +6245,26 @@ function preprocess(fn, schema) {
6246
6245
  return pipe(transform(fn), schema);
6247
6246
  }
6248
6247
 
6248
+ //#endregion
6249
+ //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/compat.js
6250
+ /** @deprecated Use the raw string literal codes instead, e.g. "invalid_type". */
6251
+ const ZodIssueCode = {
6252
+ invalid_type: "invalid_type",
6253
+ too_big: "too_big",
6254
+ too_small: "too_small",
6255
+ invalid_format: "invalid_format",
6256
+ not_multiple_of: "not_multiple_of",
6257
+ unrecognized_keys: "unrecognized_keys",
6258
+ invalid_union: "invalid_union",
6259
+ invalid_key: "invalid_key",
6260
+ invalid_element: "invalid_element",
6261
+ invalid_value: "invalid_value",
6262
+ custom: "custom"
6263
+ };
6264
+ /** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
6265
+ var ZodFirstPartyTypeKind;
6266
+ (function(ZodFirstPartyTypeKind) {})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
6267
+
6249
6268
  //#endregion
6250
6269
  //#region ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/coerce.js
6251
6270
  function number(params) {
@@ -6296,7 +6315,7 @@ const toolCallPartSchema = basePartSchema.extend({
6296
6315
  type: literal("toolCallPart"),
6297
6316
  toolCallId: string(),
6298
6317
  toolName: string(),
6299
- args: unknown()
6318
+ args: record(string(), unknown())
6300
6319
  });
6301
6320
  const thinkingPartSchema = basePartSchema.extend({
6302
6321
  type: literal("thinkingPart"),
@@ -6593,7 +6612,6 @@ const checkpointStatusSchema = _enum([
6593
6612
  "completed",
6594
6613
  "stoppedByInteractiveTool",
6595
6614
  "stoppedByDelegate",
6596
- "stoppedByExceededMaxSteps",
6597
6615
  "stoppedByError",
6598
6616
  "stoppedByCancellation"
6599
6617
  ]);
@@ -6646,6 +6664,61 @@ const checkpointSchema = object({
6646
6664
  retryCount: number$1().optional()
6647
6665
  });
6648
6666
 
6667
+ //#endregion
6668
+ //#region ../../packages/core/src/utils/expert-type.ts
6669
+ function getExpertType(expertName) {
6670
+ return expertName.startsWith("@") ? "delegate" : "coordinator";
6671
+ }
6672
+ function isCoordinatorExpert(expertName) {
6673
+ return getExpertType(expertName) === "coordinator";
6674
+ }
6675
+ function isDelegateExpert(expertName) {
6676
+ return getExpertType(expertName) === "delegate";
6677
+ }
6678
+ /**
6679
+ * Returns the scope of an expert.
6680
+ * - Coordinator "game-producer" -> "game-producer"
6681
+ * - Delegate "@game-producer/designer" -> "game-producer"
6682
+ */
6683
+ function getExpertScope(expertName) {
6684
+ if (isDelegateExpert(expertName)) {
6685
+ const withoutAt = expertName.slice(1);
6686
+ const slashIndex = withoutAt.indexOf("/");
6687
+ return slashIndex === -1 ? withoutAt : withoutAt.slice(0, slashIndex);
6688
+ }
6689
+ return expertName;
6690
+ }
6691
+ /**
6692
+ * Validates whether a delegation from source to target is allowed.
6693
+ * Returns null if valid, an error message string if invalid.
6694
+ *
6695
+ * Rules:
6696
+ * - No self-delegation
6697
+ * - If target is a delegate (@scope/name), source must be in the same scope
6698
+ * - A delegate cannot delegate to its own coordinator
6699
+ */
6700
+ function validateDelegation(source, target) {
6701
+ if (source === target) return `Expert "${source}" cannot delegate to itself`;
6702
+ const sourceScope = getExpertScope(source);
6703
+ if (isDelegateExpert(target)) {
6704
+ if (sourceScope !== getExpertScope(target)) return `Expert "${source}" cannot delegate to out-of-scope delegate "${target}"`;
6705
+ }
6706
+ if (isDelegateExpert(source) && isCoordinatorExpert(target) && target === sourceScope) return `Delegate "${source}" cannot delegate to its own coordinator "${target}"`;
6707
+ return null;
6708
+ }
6709
+ /**
6710
+ * Validates all delegations for an expert.
6711
+ * Returns an array of error messages (empty if all valid).
6712
+ */
6713
+ function validateAllDelegations(expertName, delegates) {
6714
+ const errors = [];
6715
+ for (const delegate of delegates) {
6716
+ const error = validateDelegation(expertName, delegate);
6717
+ if (error) errors.push(error);
6718
+ }
6719
+ return errors;
6720
+ }
6721
+
6649
6722
  //#endregion
6650
6723
  //#region ../../packages/core/src/schemas/provider-tools.ts
6651
6724
  const anthropicProviderToolNameSchema = _enum([
@@ -6791,7 +6864,11 @@ const skillSchema = discriminatedUnion("type", [
6791
6864
 
6792
6865
  //#endregion
6793
6866
  //#region ../../packages/core/src/schemas/expert.ts
6794
- const expertSchema = object({
6867
+ /**
6868
+ * Base object schema for Expert. Use this for `.omit()` / `.pick()` operations.
6869
+ * For parsing with delegation validation, use `expertSchema` instead.
6870
+ */
6871
+ const expertBaseSchema = object({
6795
6872
  key: string().regex(expertKeyRegex).min(1),
6796
6873
  name: string().regex(expertNameRegex).min(1).max(maxExpertNameLength),
6797
6874
  version: string().regex(expertVersionRegex),
@@ -6826,13 +6903,24 @@ const expertSchema = object({
6826
6903
  providerSkills: array(anthropicProviderSkillSchema).optional(),
6827
6904
  providerToolOptions: providerToolOptionsSchema
6828
6905
  });
6906
+ /**
6907
+ * Expert schema with delegation rule validation.
6908
+ * Rejects self-delegation, out-of-scope delegates, and delegate-to-own-coordinator.
6909
+ */
6910
+ const expertSchema = expertBaseSchema.superRefine((data, ctx) => {
6911
+ const errors = validateAllDelegations(data.key, data.delegates);
6912
+ for (const error of errors) ctx.addIssue({
6913
+ code: ZodIssueCode.custom,
6914
+ message: error,
6915
+ path: ["delegates"]
6916
+ });
6917
+ });
6829
6918
 
6830
6919
  //#endregion
6831
6920
  //#region ../../packages/core/src/schemas/job.ts
6832
6921
  const jobStatusSchema = _enum([
6833
6922
  "running",
6834
6923
  "completed",
6835
- "stoppedByMaxSteps",
6836
6924
  "stoppedByInteractiveTool",
6837
6925
  "stoppedByError",
6838
6926
  "stoppedByCancellation"
@@ -6843,7 +6931,6 @@ const jobSchema = object({
6843
6931
  coordinatorExpertKey: string(),
6844
6932
  runtimeVersion: runtimeVersionSchema,
6845
6933
  totalSteps: number$1(),
6846
- maxSteps: number$1().optional(),
6847
6934
  usage: usageSchema,
6848
6935
  startedAt: number$1(),
6849
6936
  finishedAt: number$1().optional()
@@ -7054,7 +7141,6 @@ const perstackConfigSchema = object({
7054
7141
  provider: providerTableSchema.optional(),
7055
7142
  model: string().optional(),
7056
7143
  reasoningBudget: reasoningBudgetSchema.optional(),
7057
- maxSteps: number$1().optional(),
7058
7144
  maxRetries: number$1().optional(),
7059
7145
  timeout: number$1().optional(),
7060
7146
  experts: record(string(), object({
@@ -7124,12 +7210,6 @@ const commandOptionsSchema = object({
7124
7210
  if (Number.isNaN(parsedValue)) return void 0;
7125
7211
  return parsedValue;
7126
7212
  }).pipe(reasoningBudgetSchema.optional()),
7127
- maxSteps: string().optional().transform((value) => {
7128
- if (value === void 0) return void 0;
7129
- const parsedValue = Number.parseInt(value, 10);
7130
- if (Number.isNaN(parsedValue)) return void 0;
7131
- return parsedValue;
7132
- }),
7133
7213
  maxRetries: string().optional().transform((value) => {
7134
7214
  if (value === void 0) return void 0;
7135
7215
  const parsedValue = Number.parseInt(value, 10);
@@ -7168,6 +7248,19 @@ const startCommandInputSchema = object({
7168
7248
 
7169
7249
  //#endregion
7170
7250
  //#region ../../packages/core/src/schemas/runtime.ts
7251
+ /** Parse an expert key into its components */
7252
+ function parseExpertKey(expertKey) {
7253
+ const match = expertKey.match(expertKeyRegex);
7254
+ if (!match) throw new PerstackError(`Invalid expert key format: ${expertKey}`);
7255
+ const [key, name, version, tag] = match;
7256
+ if (!name) throw new PerstackError(`Invalid expert key format: ${expertKey}`);
7257
+ return {
7258
+ key,
7259
+ name,
7260
+ version,
7261
+ tag
7262
+ };
7263
+ }
7171
7264
  const runSettingSchema = object({
7172
7265
  model: string(),
7173
7266
  providerConfig: providerConfigSchema,
@@ -7185,7 +7278,6 @@ const runSettingSchema = object({
7185
7278
  }),
7186
7279
  experts: record(string(), expertSchema),
7187
7280
  reasoningBudget: reasoningBudgetSchema.default(defaultReasoningBudget),
7188
- maxSteps: number$1().min(1).optional().default(defaultMaxSteps),
7189
7281
  maxRetries: number$1().min(0),
7190
7282
  timeout: number$1().min(0),
7191
7283
  startedAt: number$1(),
@@ -7213,12 +7305,11 @@ const runParamsSchema = object({
7213
7305
  text: string()
7214
7306
  }).optional()
7215
7307
  }),
7216
- experts: record(string().min(1).regex(expertKeyRegex), expertSchema.omit({ key: true })).optional().default({}).transform((experts) => Object.fromEntries(Object.entries(experts).map(([key, expertWithoutKey]) => [key, expertSchema.parse({
7308
+ experts: record(string().min(1).regex(expertKeyRegex), expertBaseSchema.omit({ key: true })).optional().default({}).transform((experts) => Object.fromEntries(Object.entries(experts).map(([key, expertWithoutKey]) => [key, expertSchema.parse({
7217
7309
  ...expertWithoutKey,
7218
7310
  key
7219
7311
  })]))),
7220
7312
  reasoningBudget: reasoningBudgetSchema.optional().default(defaultReasoningBudget),
7221
- maxSteps: number$1().min(1).optional().default(defaultMaxSteps),
7222
7313
  maxRetries: number$1().min(0).optional().default(defaultMaxRetries),
7223
7314
  timeout: number$1().min(0).optional().default(defaultTimeout),
7224
7315
  startedAt: number$1().optional().default(Date.now()),
@@ -7269,13 +7360,11 @@ const callTools = createEvent("callTools");
7269
7360
  const finishMcpTools = createEvent("finishMcpTools");
7270
7361
  const skipDelegates = createEvent("skipDelegates");
7271
7362
  const resolveToolResults = createEvent("resolveToolResults");
7272
- const attemptCompletion = createEvent("attemptCompletion");
7273
7363
  const finishToolCall = createEvent("finishToolCall");
7274
7364
  const resumeToolCalls = createEvent("resumeToolCalls");
7275
7365
  const completeRun = createEvent("completeRun");
7276
7366
  const stopRunByInteractiveTool = createEvent("stopRunByInteractiveTool");
7277
7367
  const stopRunByDelegate = createEvent("stopRunByDelegate");
7278
- const stopRunByExceededMaxSteps = createEvent("stopRunByExceededMaxSteps");
7279
7368
  const stopRunByError = createEvent("stopRunByError");
7280
7369
  const continueToNextStep = createEvent("continueToNextStep");
7281
7370
  /** Factory function to create runtime events */
@@ -7302,13 +7391,11 @@ const EXPERT_STATE_EVENT_TYPES = new Set([
7302
7391
  "finishMcpTools",
7303
7392
  "skipDelegates",
7304
7393
  "resolveToolResults",
7305
- "attemptCompletion",
7306
7394
  "finishToolCall",
7307
7395
  "resumeToolCalls",
7308
7396
  "continueToNextStep",
7309
7397
  "stopRunByInteractiveTool",
7310
7398
  "stopRunByDelegate",
7311
- "stopRunByExceededMaxSteps",
7312
7399
  "stopRunByError",
7313
7400
  "completeRun"
7314
7401
  ]);
@@ -7649,5 +7736,5 @@ function parseWithFriendlyError(schema, data, context) {
7649
7736
  }
7650
7737
 
7651
7738
  //#endregion
7652
- export { boolean$1 as $, startCommandInputSchema as A, defineLazy as At, messageSchema as B, startGeneration as C, $ZodObject as Ct, stopRunByExceededMaxSteps as D, safeParse$1 as Dt, stopRunByError as E, parseAsync$1 as Et, checkpointSchema as F, PerstackError as Ft, number as G, userMessageSchema as H, usageSchema as I, defaultMaxRetries as It, _instanceof as J, ZodOptional as K, toolResultSchema as L, defaultTimeout as Lt, lockfileSchema as M, $constructor as Mt, jobSchema as N, NEVER as Nt, stopRunByInteractiveTool as O, safeParseAsync$1 as Ot, expertSchema as P, knownModels as Pt, array as Q, toolCallSchema as R, createId as Rt, skipDelegates as S, meta$1 as St, stopRunByDelegate as T, parse$1 as Tt, activityOrGroupSchema as U, toolMessageSchema as V, boolean as W, _undefined as X, _null as Y, any as Z, resolveToolResults as _, url as _t, BASE_SKILL_PREFIX as a, looseObject as at, runParamsSchema as b, toJSONSchema as bt, attemptCompletion as c, object as ct, continueToNextStep as d, record as dt, custom as et, createRuntimeEvent as f, strictObject as ft, proceedToInteractiveTools as g, unknown as gt, finishToolCall as h, union as ht, getFilteredEnv as i, literal as it, perstackConfigSchema as j, normalizeParams as jt, runCommandInputSchema as k, clone as kt, callTools as l, optional as lt, finishMcpTools as m, tuple as mt, createFilteredEventListener as n, intersection as nt, createBaseToolActivity as o, never as ot, createStreamingEvent as p, string as pt, _enum as q, validateEventFilter as r, lazy as rt, createGeneralToolActivity as s, number$1 as st, parseWithFriendlyError as t, discriminatedUnion as tt, completeRun as u, preprocess as ut, resumeFromStop as v, safeParseAsync as vt, startRun as w, $ZodType as wt, runSettingSchema as x, describe$1 as xt, retry as y, datetime as yt, instructionMessageSchema as z };
7653
- //# sourceMappingURL=src-C0pz_C3h.js.map
7739
+ export { any as $, perstackConfigSchema as A, safeParseAsync$1 as At, instructionMessageSchema as B, createId as Bt, startGeneration as C, describe$1 as Ct, stopRunByInteractiveTool as D, parse$1 as Dt, stopRunByError as E, $ZodType as Et, validateDelegation as F, NEVER as Ft, boolean as G, toolMessageSchema as H, checkpointSchema as I, knownModels as It, ZodOptional as J, number as K, usageSchema as L, PerstackError as Lt, jobSchema as M, defineLazy as Mt, expertSchema as N, normalizeParams as Nt, runCommandInputSchema as O, parseAsync$1 as Ot, isCoordinatorExpert as P, $constructor as Pt, _undefined as Q, toolResultSchema as R, defaultMaxRetries as Rt, skipDelegates as S, toJSONSchema as St, stopRunByDelegate as T, $ZodObject as Tt, userMessageSchema as U, messageSchema as V, activityOrGroupSchema as W, _instanceof as X, _enum as Y, _null as Z, resolveToolResults as _, union as _t, BASE_SKILL_PREFIX as a, lazy as at, runParamsSchema as b, safeParseAsync as bt, callTools as c, never as ct, createRuntimeEvent as d, optional as dt, array as et, createStreamingEvent as f, preprocess as ft, proceedToInteractiveTools as g, tuple as gt, parseExpertKey as h, string as ht, getFilteredEnv as i, intersection as it, lockfileSchema as j, clone as jt, startCommandInputSchema as k, safeParse$1 as kt, completeRun as l, number$1 as lt, finishToolCall as m, strictObject as mt, createFilteredEventListener as n, custom as nt, createBaseToolActivity as o, literal as ot, finishMcpTools as p, record as pt, ZodIssueCode as q, validateEventFilter as r, discriminatedUnion as rt, createGeneralToolActivity as s, looseObject as st, parseWithFriendlyError as t, boolean$1 as tt, continueToNextStep as u, object as ut, resumeFromStop as v, unknown as vt, startRun as w, meta$1 as wt, runSettingSchema as x, datetime as xt, retry as y, url as yt, toolCallSchema as z, defaultTimeout as zt };
7740
+ //# sourceMappingURL=src-Ct-kpNVU.js.map