promptgun 0.20.1 → 0.20.2
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.
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"{\"version\":3,\"names\":[\"Flux\",\"_Flux\",\"generator\",\"upstream\",\"handleCancel\",\"_closed\",\"constructor\",\"thiss\",\"this\",\"async\",\"e\",\"ignorableValue\",\"Symbol\",\"asyncIterator\",\"next\",\"args\",\"value\",\"return\",\"throw\",\"cancel\",\"closed\",\"then\",\"onfulfilled\",\"onrejected\",\"result\",\"asList\",\"onfinally\",\"promise\",\"toStringTag\",\"subscribe\",\"callback\",\"flux\",\"doOnEach\",\"recur\",\"done\",\"catch\",\"err\",\"console\",\"error\",\"unsubscribe\",\"filter\",\"predicate\",\"constructFromGeneratorFunction\",\"untilExcl\",\"doAfterLast\",\"events\",\"push\",\"map\",\"mapper\",\"take\",\"n\",\"i\",\"flatMap\",\"Array\",\"isArray\",\"r\",\"transform\",\"defineGenerator\",\"definedGenerator\",\"reduce\",\"reducer\",\"initialValue\",\"reduction\",\"whenComplete\",\"ignored\",\"create\",\"creator\",\"values\",\"resolvers\",\"isDone\",\"Error\",\"length\",\"shift\",\"resolve\",\"complete\",\"reject\",\"fromGenerator\",\"Promise\",\"fromArray\",\"array\",\"fromGeneratorFunction\",\"fn\",\"fromReadableStream\",\"stream\",\"reader\",\"getReader\",\"excerpt\",\"read\",\"exports\",\"D\",\"We\",\"oe\",\"Object\",\"defineProperty\",\"Flux_1\",\"Ye\",\"enumerable\",\"get\",\"import_monoflux\",\"re\",\"promptOpenai\",\"model\",\"prompt\",\"apiToken\",\"temperature\",\"topP\",\"requireJsonResponse\",\"serviceTier\",\"tools\",\"_e\",\"abortController\",\"AbortController\",\"response\",\"fetch\",\"headers\",\"Accept\",\"Authorization\",\"method\",\"signal\",\"body\",\"JSON\",\"stringify\",\"messages\",\"top_p\",\"response_format\",\"type\",\"service_tier\",\"status\",\"message\",\"bodyText\",\"parse\",\"errorMessage\",\"text\",\"jsonBuffer\",\"accumulatedToolCalls\",\"abort\",\"textDecoder\",\"decode\",\"replaceAll\",\"replace\",\"split\",\"trim\",\"json\",\"chunk\",\"choices\",\"choice\",\"delta\",\"tool_calls\",\"toolCall\",\"id\",\"function\",\"name\",\"arguments\",\"index\",\"existingEntry\",\"finish_reason\",\"toolCalls\",\"content\",\"item\",\"TextDecoder\",\"ComplexTypeError\",\"data\",\"httpStatus\",\"problems\",\"problem\",\"expectedProp\",\"path\",\"expectedType\",\"typeToString\",\"join\",\"insteadGot\",\"unknownProp\",\"super\",\"requireThat\",\"TypeSpec\",\"checkIsOneOf\",\"types\",\"opts\",\"problemsPerType\",\"ignoreUnknownProps\",\"elementType\",\"key\",\"props\",\"prop\",\"optional\",\"typeAccountingOptionality\",\"Number\",\"isNaN\",\"checkIs\",\"some\",\"list\",\"typeProblemsOnThisPath\",\"t\",\"promptGridApiUrl\",\"_TypeSpec\",\"canBeArray\",\"assertTypeOfArray\",\"elementSpec\",\"arraySpec\",\"canBeObject\",\"assertTypeOfObject\",\"objectSpec\",\"hasString\",\"propertyName\",\"hasProperty\",\"canBeString\",\"canHaveProperty\",\"assertTypeOfProperty\",\"old\",\"propertyType\",\"canBeNumber\",\"canBeBoolean\",\"canBeConstant\",\"canBeNull\",\"canBeUndefined\",\"andNothingElse\",\"orDefaultTo\",\"describe\",\"indentLevel\",\"keys\",\"indent\",\"depth\",\"config\",\"getPromptGridApiUrl\",\"rawValue\",\"url\",\"url2\",\"backendUrlNotTriviallyIdentifiableInMinifiedCode\",\"Token\",\"source\",\"fieldName\",\"maybeIncomplete\",\"JsonTokenProcessor\",\"_JsonTokenProcessor\",\"highestOffsetParsed\",\"toJsonTokenFlux\",\"dataBufferFlux\",\"processDataBuffer\",\"deltaContentFlux\",\"getExcerpts\",\"token\",\"excerpts\",\"jsonParser\",\"JsonParser\",\"nextToken\",\"currentTokenLocation\",\"getCharOffset\",\"position\",\"currentTokenType\",\"parentFieldName\",\"currentValue\",\"context\",\"startPosition\",\"test\",\"substring\",\"char\",\"pushContext\",\"popContext\",\"currentContextType\",\"startPos\",\"endPos\",\"indexOf\",\"nextFourChars\",\"nextFiveChars\",\"numStr\",\"hasDecimal\",\"parseFloat\",\"parseInt\",\"mayBeIncomplete\",\"JsonParseException\",\"contextType\",\"currentContext\",\"pop\",\"nonNullish\",\"StreamedJsonElement\",\"receivedJson\",\"propertyCallbacks\",\"Map\",\"onElementCallbacks\",\"Set\",\"onCompleteCallbacks\",\"onEachExcerptCallbacks\",\"currentToken\",\"state\",\"Begin\",\"receivedExcerpts\",\"onElement\",\"add\",\"onProperty\",\"has\",\"set\",\"onJsonStringProperty\",\"processor\",\"stringBuffer\",\"jsonElement\",\"StreamedJsonChildElement\",\"onEachExcerpt\",\"jsonStringExcerpt\",\"allData\",\"excerptWithHoleEscapeTokens\",\"endsOnUnevenNumberOfBackslashes\",\"unescapedExcerptWithoutOpeningQuote\",\"unescapedExcerptWithoutClosingQuote\",\"forEach\",\"getResponseAsPromise\",\"onCompleteAs\",\"onComplete\",\"_onComplete\",\"toAsync\",\"expectedTokenType\",\"consumer\",\"onCompleteAsync\",\"onCompleteAsAsync\",\"jsonStringValue\",\"jsonString\",\"deserializedValue\",\"onCompleteAsString\",\"onCompleteAsStringAsync\",\"onCompleteAsInt\",\"onCompleteAsIntAsync\",\"onCompleteAsNumber\",\"onCompleteAsNumberAsync\",\"onCompleteAsBoolean\",\"onCompleteAsBooleanAsync\",\"asJsonFlux\",\"Xe\",\"whenCompleteAs\",\"isState\",\"InNested\",\"child\",\"tokenType\",\"size\",\"InObject\",\"InArray\",\"end\",\"UnexpectedTokenException\",\"resultingJson\",\"InPropertyValue\",\"InArrayElement\",\"subscription\",\"completeValue\",\"from\",\"stateClass\",\"count\",\"State\",\"StreamedJsonRootElement\",\"jsonTokenFlux\",\"Ze\",\"lastTokenExcerpt\",\"StreamedJsonParser\",\"parseJsonWithUsefulError\",\"completedJson\",\"parsePartialJson\",\"partialJson\",\"opened\",\"escaped\",\"pushScope\",\"scope\",\"popScope\",\"expect\",\"lastOpened\",\"includes\",\"illegalState\",\"nextEscapedValue\",\"match\",\"closeEverything\",\"reverse\",\"opener\",\"requireDefined\",\"byteToHex\",\"toString\",\"slice\",\"randomFillSync\",\"rnds8Pool\",\"Uint8Array\",\"poolPtr\",\"randomUUID\",\"native_default\",\"v4_default\",\"options\",\"buf\",\"offset\",\"rnds\",\"random\",\"rng\",\"RangeError\",\"arr\",\"toLowerCase\",\"unsafeStringify\",\"specType\",\"EmptyTypeSpec\",\"evaluations\",\"juggleBetweenNullAndUndefined\",\"juggleTo\",\"elementConformities\",\"element\",\"c\",\"juggles\",\"typeConformity\",\"newValue\",\"juggle\",\"typeConformities\",\"evaluation\",\"conformsPerfectly\",\"typeConformitiesThatPassWithJuggle\",\"juggleThatWouldMakeValueConform\",\"_\",\"_EmptyTypeSpec\",\"FullTypeSpec\",\"object\",\"properties\",\"TypeMemberSpec\",\"string\",\"number\",\"boolean\",\"constant\",\"otherValues\",\"FullPropTypeSpec\",\"undefined\",\"any\",\"_FullTypeSpec\",\"orArray\",\"orObject\",\"orString\",\"orNumber\",\"orBoolean\",\"orConstant\",\"orNull\",\"orUndefined\",\"_TypeMemberSpec\",\"mayHave\",\"hint\",\"canHaveString\",\"canHaveNumber\",\"canHaveBoolean\",\"canHaveConstant\",\"firstConstant\",\"otherConstants\",\"arg3\",\"arg4\",\"comment\",\"propertyTypeSpec\",\"EmptyPropTypeSpec\",\"commentsFromPropTypeSpec\",\"_comments\",\"comments\",\"hasNumber\",\"hasBoolean\",\"hasConstant\",\"arg2\",\"otherArgs\",\"constants\",\"PropTypeSpec\",\"withComment\",\"_FullPropTypeSpec\",\"assertType\",\"typeSpec\",\"describeType\",\"propSpec\",\"comma\",\"promptOpenaiImageGen\",\"apiKey\",\"ok\",\"errorData\",\"b64_json\",\"atob\",\"charCodeAt\",\"writeFile\",\"AiModel\",\"gpt_3_5_turbo\",\"gpt_3_5_turbo_0125\",\"gpt_3_5_turbo_1106\",\"gpt_3_5_turbo_16k\",\"gpt_3_5_turbo_instruct\",\"gpt_3_5_turbo_instruct_0914\",\"gpt_4\",\"gpt_4_0125_preview\",\"gpt_4_0613\",\"gpt_4_1106_preview\",\"gpt_4_turbo\",\"gpt_4_turbo_2024_04_09\",\"gpt_4_turbo_preview\",\"gpt_4_1\",\"gpt_4_1_2025_04_14\",\"gpt_4_1_mini\",\"gpt_4_1_mini_2025_04_14\",\"gpt_4_1_nano\",\"gpt_4_1_nano_2025_04_14\",\"gpt_4o\",\"gpt_4o_2024_05_13\",\"gpt_4o_2024_08_06\",\"gpt_4o_2024_11_20\",\"gpt_4o_audio_preview\",\"gpt_4o_audio_preview_2024_10_01\",\"gpt_4o_audio_preview_2024_12_17\",\"gpt_4o_audio_preview_2025_06_03\",\"gpt_4o_mini\",\"gpt_4o_mini_2024_07_18\",\"gpt_4o_mini_audio_preview\",\"gpt_4o_mini_audio_preview_2024_12_17\",\"gpt_4o_mini_realtime_preview\",\"gpt_4o_mini_realtime_preview_2024_12_17\",\"gpt_4o_mini_search_preview\",\"gpt_4o_mini_search_preview_2025_03_11\",\"gpt_4o_mini_transcribe\",\"gpt_4o_mini_tts\",\"gpt_4o_realtime_preview\",\"gpt_4o_realtime_preview_2024_10_01\",\"gpt_4o_realtime_preview_2024_12_17\",\"gpt_4o_realtime_preview_2025_06_03\",\"gpt_4o_search_preview\",\"gpt_4o_search_preview_2025_03_11\",\"gpt_4o_transcribe\",\"gpt_5\",\"gpt_5_2025_08_07\",\"gpt_5_chat_latest\",\"gpt_5_mini\",\"gpt_5_mini_2025_08_07\",\"gpt_5_nano\",\"gpt_5_nano_2025_08_07\",\"gpt_image_1\",\"o1\",\"o1_2024_12_17\",\"o1_mini\",\"o1_mini_2024_09_12\",\"o1_pro\",\"o1_pro_2025_03_19\",\"o3\",\"o3_2025_04_16\",\"o3_deep_research\",\"o3_deep_research_2025_06_26\",\"o3_mini\",\"o3_mini_2025_01_31\",\"o3_pro\",\"o3_pro_2025_06_10\",\"o4_mini\",\"o4_mini_2025_04_16\",\"o4_mini_deep_research\",\"o4_mini_deep_research_2025_06_26\",\"omni_moderation_2024_09_26\",\"omni_moderation_latest\",\"OpenaiImageModel\",\"dall_e_2\",\"dall_e_3\",\"AIClient\",\"_apiKeyChain\",\"_conversation\",\"arg\",\"effectivePromptGunConfig\",\"createConversation\",\"newClient\",\"AIConversation\",\"uuid\",\"apiKeyChain\",\"obtainAiClientData\",\"conversation\",\"chat\",\"arg1\",\"toPrompt\",\"effectiveMessages\",\"user\",\"m\",\"BasicPrompt\",\"getCallerFileNameAndLineNumber\",\"image\",\"ImagePrompt\",\"_AIConversation\",\"copyConversation\",\"messageUuid\",\"_model\",\"_imageSize\",\"aiClient\",\"getResponseAsString\",\"imageSize\",\"toFile\",\"fileName\",\"ImageFilePrompt\",\"openai\",\"getResponseAsFile\",\"byptes\",\"File\",\"ai\",\"setupAI\",\"newAIClient\",\"promptGridApiKey\",\"effectivePromptGridApiKey\",\"debugMode\",\"attemptsPerCall\",\"apiKeys\",\"effectiveAttemptsPerCall\",\"rawPromptGridApiKey\",\"rawAttemptsPerCall\",\"typedAttemptsPerCall\",\"promptgrid\",\"promptMappings\",\"promptAI\",\"client\",\"effectiveClient\",\"PromptBase\",\"callingCodeLine\",\"completeChat\",\"promptSupplier\",\"promptSupplierArgs\",\"_temperature\",\"_topP\",\"_serviceTier\",\"_firstThink\",\"self\",\"executeLlmCall\",\"genericMessages\",\"promptName\",\"_tools\",\"firstThink\",\"flex\",\"useFlexTier\",\"role\",\"TypeSpecMarker\",\"genericPrompt\",\"typeSpecIndex\",\"toGenericPrompt\",\"jsonSpecMessage\",\"jsonSpec\",\"JsonPrompt\",\"getBoolean\",\"o\",\"getString\",\"getNumber\",\"getObject\",\"getArray\",\"JsonArrayPrompt\",\"getAny\",\"normalizedTools\",\"tool\",\"typeSpecToJsonSchema\",\"convertType\",\"required\",\"entries\",\"items\",\"const\",\"defineTool\",\"description\",\"parameters\",\"jsonTypeSupplier\",\"streamingJsonRootElement\",\"getFlux\",\"$e\",\"lazyGenerator\",\"stringGenerator\",\"jsonExcerpt\",\"partialJsonGenerator\",\"accumulatedJson\",\"getResponse\",\"stringResult\",\"uncheckedPackedResult\",\"_responseAsStringPromise\",\"_getResponseAsString\",\"arrayElementGenerator\",\"pickModel\",\"modelId\",\"typeSpecMessage\",\"toOpenAiMessage\",\"msg\",\"system\",\"assistant\",\"genericPromptWithJsonSpec\",\"convSavePromises\",\"promptFilename\",\"lineNumber\",\"promptLineNumber\",\"startsWith\",\"promptProfile\",\"conversationUuid\",\"saveLoop\",\"saveConv\",\"conversationData\",\"newMsg\",\"existing\",\"find\",\"currentSave\",\"save\",\"saveConversation\",\"setTimeout\",\"delete\",\"genericPromptWithJsonSpecAndConversationHistory\",\"responseMessageId\",\"incomplete\",\"attempts\",\"openaiTools\",\"accumulatedContent\",\"toolCallsToExecute\",\"toolResults\",\"tool_call_id\",\"String\",\"toolCallMessage\",\"tc\",\"toolCallsDescription\",\"toolResultMessages\",\"toolResult\",\"toolName\",\"uncheckedResult\",\"typeError\",\"warn\",\"promises\",\"all\",\"newO\",\"frame\",\"stack\",\"l\",\"hasFunctionNameInFrameWithFileNameInParenthesis\",\"functionName\",\"groups\",\"stacktraceFrame\",\"ee\",\"Le\",\"Mt\",\"fe\",\"ye\",\"L\",\"v\",\"Fe\",\"Ve\",\"Ge\",\"he\",\"Nt\",\"Ke\",\"X\",\"O\",\"Q\",\"V\",\"G\",\"ge\",\"Be\",\"Hn\",\"Te\",\"zn\",\"st\",\"Me\",\"Wn\",\"Dn\"],\"sources\":[\"../node_modules/monoflux/src/Flux.ts\",\"../node_modules/monoflux/src/index.ts\",\"../src/index.ts\",\"../src/ai-inference/openai/promptOpenai.ts\",\"../src/require-that/requireThat.ts\",\"../src/env-vars.ts\",\"../src/json-streaming/types.ts\",\"../src/json-streaming/JsonTokenProcessor.ts\",\"../src/json-streaming/StreamedJsonElement.ts\",\"../src/util/nonNullish.ts\",\"../src/json-streaming/StreamedJsonRootElement.ts\",\"../src/json-streaming/StreamedJsonParser.ts\",\"../src/util/parseJsonWithUsefulError.ts\",\"../src/parse-partial-json/parsePartialJson.ts\",\"../src/util/requireDefined.ts\",\"../node_modules/uuid/dist/esm/stringify.js\",\"../node_modules/uuid/dist/esm/rng.js\",\"../node_modules/uuid/dist/esm/native.js\",\"../node_modules/uuid/dist/esm/v4.js\",\"../src/type-spec/type-spec.ts\",\"../src/ai-inference/openai/promptOpenaiImageGen.ts\",\"../src/ai-inference/AiModel.ts\",\"../src/ai-inference/openai/OpenaiImageModel.ts\"],\"sourcesContent\":[null,null,\"import {Flux} from 'monoflux'\\nimport type {AiModelId} from './ai-inference/AiModelId.js'\\nimport type {GenericPrompt, PromptMessage, Role, ServiceTier} from './ai-inference/model.js'\\nimport {promptOpenai, type PromptChunk, type ToolCall} from './ai-inference/openai/promptOpenai.js'\\nimport {getPromptGridApiUrl} from './env-vars.js'\\nimport {JsonTokenProcessor} from './json-streaming/JsonTokenProcessor.js'\\nimport {StreamedJsonChildElement} from './json-streaming/StreamedJsonElement.js'\\nimport {StreamedJsonParser} from './json-streaming/StreamedJsonParser.js'\\nimport {StreamedJsonRootElement} from './json-streaming/StreamedJsonRootElement.js'\\nimport {parsePartialJson} from './parse-partial-json/parsePartialJson.js'\\nimport {nonNullish} from './util/nonNullish.js'\\nimport {requireDefined} from './util/requireDefined.js'\\nimport {randomUuid} from './util/randomUuid.ts'\\nimport {\\n\\tassertType,\\n\\tdescribeType,\\n\\tEmptyTypeSpec,\\n\\tFullPropTypeSpec,\\n\\tspecType,\\n\\tTypeMemberSpec,\\n\\tTypeSpec\\n} from './type-spec/type-spec.js'\\nimport {requireThat} from './require-that/requireThat.js'\\nimport {parseJsonWithUsefulError} from './util/parseJsonWithUsefulError.js'\\nimport {ImageSize, promptOpenaiImageGen} from './ai-inference/openai/promptOpenaiImageGen.ts'\\nimport {writeFile} from 'fs'\\nimport {OpenaiImageModelId} from './ai-inference/openai/OpenaiImageModelId.js'\\n\\ntype SystemMessage = {system: string, user?: undefined, assistant?: undefined, developer?: undefined}\\ntype UserMessage = {system?: undefined, user: string, assistant?: undefined, developer?: undefined}\\ntype AssistantMessage = {system?: undefined, user?: undefined, assistant: string, developer?: undefined}\\ntype DeveloperMessage = {system?: undefined, user?: undefined, assistant?: undefined, developer: string}\\ntype TypeSpecMessage = {system?: undefined, user?: undefined, assistant?: undefined, developer?: undefined, typeSpec: true}\\n\\ntype Message = SystemMessage | UserMessage | AssistantMessage | DeveloperMessage | TypeSpecMessage\\n\\ntype Prompt = string | Message | (Message | undefined)[]\\n\\ntype ApiKeys = {\\n\\topenai?: string | undefined\\n}\\n\\ntype Opts = {\\n\\tmodel?: 'gpt-4o'\\n}\\n\\ntype HandshakeData = {\\n\\tapiKeys: ApiKeys\\n\\twithinQuotum: boolean\\n}\\n\\nexport type ApiKeyChain = {\\n\\tpromptgrid: string | undefined\\n\\topenai: Promise<string | undefined>\\n}\\n\\nexport type Conversation = {\\n\\tuuid: string\\n\\tmessages: PromptMessageWithId[]\\n}\\n\\nclass AIClient {\\n\\tprotected config: EffectivePromptGunConfig\\n\\tprotected _apiKeyChain: ApiKeyChain | undefined\\n\\tprotected _conversation?: Conversation\\n\\n\\tconstructor(arg: string | PromptGunConfig) {\\n\\t\\tthis.config = effectivePromptGunConfig(arg)\\n\\t}\\n\\n\\tpublic createConversation() {\\n\\t\\tconst newClient = new AIConversation(this.config)\\n\\t\\tnewClient._apiKeyChain = this._apiKeyChain\\n\\t\\tnewClient._conversation = {uuid: randomUuid(), messages: []}\\n\\t\\treturn newClient\\n\\t}\\n\\n\\tpublic get apiKeyChain(): ApiKeyChain {\\n\\t\\tif (this._apiKeyChain === undefined) {\\n\\t\\t\\tthis._apiKeyChain = obtainAiClientData(this.config)\\n\\t\\t}\\n\\t\\treturn this._apiKeyChain\\n\\t}\\n\\n\\tpublic get conversation(): Conversation | undefined {\\n\\t\\treturn this._conversation\\n\\t}\\n\\n\\tchat<T extends undefined>(userMessage: string): BasicPrompt<T>\\n\\tchat<T extends undefined>(...messages: (Message | undefined)[]): BasicPrompt<T>\\n\\tchat<T extends undefined>(messages: (Message | undefined)[]): BasicPrompt<T>\\n\\tchat<T extends undefined>(toPrompt: (args?: T, typeSpecMessage?: TypeSpecMessage) => Prompt): BasicPrompt<T>\\n\\tchat<T>(toPrompt: (args: T, typeSpecMessage?: TypeSpecMessage) => Prompt, args: T): BasicPrompt<T>\\n\\tchat<T = undefined>(toPrompt: (args?: T, typeSpecMessage?: TypeSpecMessage) => Prompt, args?: T): BasicPrompt<T>\\n\\tchat<T = undefined>(\\n\\t\\targ1: (Message | undefined) | (Message | undefined)[] | ((args?: T, typeSpecMessage?: TypeSpecMessage) => Prompt) | string,\\n\\t\\targ2?: (Message | undefined) | T,\\n\\t\\t...arg3: (Message | undefined)[]\\n\\t): BasicPrompt<T> {\\n\\t\\tconst {\\n\\t\\t\\ttoPrompt,\\n\\t\\t\\targs,\\n\\t\\t} = (() => {\\n\\t\\t\\tif (typeof arg1 === 'function') {\\n\\t\\t\\t\\treturn {\\n\\t\\t\\t\\t\\ttoPrompt: arg1,\\n\\t\\t\\t\\t\\targs: arg2,\\n\\t\\t\\t\\t}\\n\\t\\t\\t} else if (typeof arg1 === 'string') {\\n\\t\\t\\t\\treturn {\\n\\t\\t\\t\\t\\ttoPrompt: () => arg1,\\n\\t\\t\\t\\t\\targs: undefined,\\n\\t\\t\\t\\t}\\n\\t\\t\\t} else if (Array.isArray(arg1)) {\\n\\t\\t\\t\\tconst effectiveMessages = arg1.length === 0\\n\\t\\t\\t\\t\\t? [{user: ''}]\\n\\t\\t\\t\\t\\t: arg1.filter(m => m !== undefined)\\n\\t\\t\\t\\treturn {\\n\\t\\t\\t\\t\\ttoPrompt: () => effectiveMessages,\\n\\t\\t\\t\\t\\targs: undefined,\\n\\t\\t\\t\\t}\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tconst messages: Message[] = [\\n\\t\\t\\t\\t\\targ1,\\n\\t\\t\\t\\t\\t...(arg2 !== undefined ? [arg2 as Message] : []),\\n\\t\\t\\t\\t\\t...arg3,\\n\\t\\t\\t\\t].filter(m => m !== undefined)\\n\\t\\t\\t\\tconst effectiveMessages = messages.length === 0\\n\\t\\t\\t\\t\\t? [{user: ''}]\\n\\t\\t\\t\\t\\t: messages\\n\\t\\t\\t\\treturn {\\n\\t\\t\\t\\t\\ttoPrompt: () => effectiveMessages,\\n\\t\\t\\t\\t\\targs: undefined,\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t})()\\n\\t\\treturn new BasicPrompt<T>(\\n\\t\\t\\tthis,\\n\\t\\t\\ttoPrompt,\\n\\t\\t\\targ2 as T,\\n\\t\\t\\tgetCallerFileNameAndLineNumber(),\\n\\t\\t\\tundefined,\\n\\t\\t\\tundefined,\\n\\t\\t\\tundefined,\\n\\t\\t\\tundefined,\\n\\t\\t\\tfalse,\\n\\t\\t)\\n\\t}\\n\\n\\timage(prompt: string): ImagePrompt {\\n\\t\\treturn new ImagePrompt(\\n\\t\\t\\tprompt,\\n\\t\\t\\tundefined,\\n\\t\\t\\tundefined,\\n\\t\\t\\tthis\\n\\t\\t)\\n\\t}\\n}\\n\\nexport class AIConversation extends AIClient {\\n\\tconstructor(arg: string | PromptGunConfig) {\\n\\t\\tsuper(arg)\\n\\t}\\n\\n\\tpublic copyConversation() {\\n\\t\\tif (this._conversation === undefined) {\\n\\t\\t\\tthrow new Error('This method only works on copy conversation: no conversation exists')\\n\\t\\t}\\n\\t\\tconst newClient = new AIConversation(this.config)\\n\\t\\tnewClient._apiKeyChain = this._apiKeyChain\\n\\t\\tnewClient._conversation = {\\n\\t\\t\\tuuid: randomUuid(),\\n\\t\\t\\tmessages: this._conversation.messages.map(m => ({\\n\\t\\t\\t\\t...m,\\n\\t\\t\\t\\tmessageUuid: randomUuid(),\\n\\t\\t\\t})),\\n\\t\\t}\\n\\t\\treturn newClient\\n\\t}\\n}\\n\\nexport class ImagePrompt implements Promise<Buffer> {\\n\\tconstructor(\\n\\t\\tprivate prompt: string,\\n\\t\\tprivate _model: OpenaiImageModelId | undefined,\\n\\t\\tprivate _imageSize: ImageSize | undefined,\\n\\t\\tprivate aiClient: AIClient,\\n\\t) {}\\n\\n\\tasync then<TResult1 = Buffer, TResult2 = never>(\\n\\t\\tonfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null | undefined,\\n\\t\\tonrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined\\n\\t): Promise<TResult1 | TResult2> {\\n\\t\\ttry {\\n\\t\\t\\tconst result = await this.getResponseAsString()\\n\\t\\t\\treturn nonNullish(onfulfilled)\\n\\t\\t\\t\\t? await onfulfilled(result)\\n\\t\\t\\t\\t: result as TResult1\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn await onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tasync catch<TResult = never>(\\n\\t\\tonrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined\\n\\t): Promise<Buffer | TResult> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponseAsString()\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tasync finally(onfinally?: (() => void) | null | undefined): Promise<Buffer> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponseAsString()\\n\\t\\t} finally {\\n\\t\\t\\tonfinally?.()\\n\\t\\t}\\n\\t}\\n\\n\\tget [Symbol.toStringTag](): string {\\n\\t\\treturn 'ImagePrompt'\\n\\t}\\n\\n\\tmodel(model: OpenaiImageModelId) {\\n\\t\\tthis._model = model\\n\\t\\treturn this\\n\\t}\\n\\n\\t/**\\n\\t * The size of the generated images. Must be one of `1024x1024`, `1536x1024`\\n\\t * (landscape), `1024x1536` (portrait), or `auto` (default value) for\\n\\t * `gpt-image-1`, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and\\n\\t * one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`.\\n\\t */\\n\\tsize(imageSize: ImageSize) {\\n\\t\\tthis._imageSize = imageSize\\n\\t\\treturn this\\n\\t}\\n\\n\\ttoFile(fileName: string): ImageFilePrompt {\\n\\t\\treturn new ImageFilePrompt(\\n\\t\\t\\tthis.prompt,\\n\\t\\t\\tthis._model,\\n\\t\\t\\tthis._imageSize,\\n\\t\\t\\tfileName,\\n\\t\\t\\tthis.aiClient\\n\\t\\t)\\n\\t}\\n\\n\\tprivate async getResponseAsString(): Promise<Buffer> {\\n\\t\\tconst apiToken = requireThat(await this.aiClient['apiKeyChain']!.openai)\\n\\t\\t\\t.canBeString()\\n\\t\\t\\t.andNothingElse({errorMessage: 'No OpenAI access token set'})\\n\\t\\treturn await promptOpenaiImageGen(\\n\\t\\t\\tapiToken,\\n\\t\\t\\tthis.prompt\\n\\t\\t)\\n\\t}\\n}\\n\\nexport class ImageFilePrompt implements Promise<File> {\\n\\tconstructor(\\n\\t\\tprivate prompt: string,\\n\\t\\tprivate _model: OpenaiImageModelId | undefined,\\n\\t\\tprivate _imageSize: ImageSize | undefined,\\n\\t\\tprivate fileName: string,\\n\\t\\tprivate aiClient: AIClient,\\n\\t) {}\\n\\n\\tasync then<TResult1 = File, TResult2 = never>(\\n\\t\\tonfulfilled?: ((value: File) => TResult1 | PromiseLike<TResult1>) | null | undefined,\\n\\t\\tonrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined\\n\\t): Promise<TResult1 | TResult2> {\\n\\t\\ttry {\\n\\t\\t\\tconst result = await this.getResponseAsFile()\\n\\t\\t\\treturn nonNullish(onfulfilled)\\n\\t\\t\\t\\t? await onfulfilled(result)\\n\\t\\t\\t\\t: result as TResult1\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn await onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tasync catch<TResult = never>(\\n\\t\\tonrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined\\n\\t): Promise<File | TResult> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponseAsFile()\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tasync finally(onfinally?: (() => void) | null | undefined): Promise<File> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponseAsFile()\\n\\t\\t} finally {\\n\\t\\t\\tonfinally?.()\\n\\t\\t}\\n\\t}\\n\\n\\tget [Symbol.toStringTag](): string {\\n\\t\\treturn 'ImageFilePrompt'\\n\\t}\\n\\n\\tmodel(model: OpenaiImageModelId) {\\n\\t\\tthis._model = model\\n\\t\\treturn this\\n\\t}\\n\\n\\t/**\\n\\t * The size of the generated images. Must be one of `1024x1024`, `1536x1024`\\n\\t * (landscape), `1024x1536` (portrait), or `auto` (default value) for\\n\\t * `gpt-image-1`, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and\\n\\t * one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`.\\n\\t */\\n\\tsize(imageSize: ImageSize) {\\n\\t\\tthis._imageSize = imageSize\\n\\t\\treturn this\\n\\t}\\n\\n\\tprivate async getResponseAsFile(): Promise<File> {\\n\\t\\tconst apiToken = requireThat(await this.aiClient['apiKeyChain']!.openai)\\n\\t\\t\\t.canBeString()\\n\\t\\t\\t.andNothingElse({errorMessage: 'No OpenAI access token set'})\\n\\t\\tconst byptes = await promptOpenaiImageGen(\\n\\t\\t\\tapiToken,\\n\\t\\t\\tthis.prompt,\\n\\t\\t\\tthis._model,\\n\\t\\t\\tthis._imageSize\\n\\t\\t)\\n\\t\\treturn new Promise<File>((resolve, reject) => {\\n\\t\\t\\twriteFile(this.fileName, byptes, (err: any) => {\\n\\t\\t\\t\\tif (err) {\\n\\t\\t\\t\\t\\treject(err)\\n\\t\\t\\t\\t\\treturn\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tresolve(\\n\\t\\t\\t\\t\\tnew File([byptes], this.fileName, { type: 'image/png' })\\n\\t\\t\\t\\t)\\n\\t\\t\\t})\\n\\t\\t})\\n\\t}\\n}\\n\\nexport let ai = new AIClient({})\\n\\nexport type PromptGunConfig = {\\n\\tpromptGridApiKey?: string\\n\\tapiKeys?: ApiKeys\\n\\t/**\\n\\t * Finishes submitting logs to promptgrid before completing a prompt's result stream,\\n\\t * so that chat logs of prompts before breakpoints or test ends will not be cut short.\\n\\t */\\n\\tdebugMode?: boolean\\n\\n\\t/**\\n\\t * Number of times to try a prompt before giving up. If the prompt fails,\\n\\t * the next attempt will be made with the same prompt with a delay of 1 second. Should\\n\\t * be an integer greater than or equal to 1. Default value: 1 (no retrying).\\n\\t */\\n\\tattemptsPerCall?: number\\n}\\n\\nexport type EffectivePromptGunConfig = {\\n\\tpromptGridApiKey?: string\\n\\tapiKeys?: ApiKeys\\n\\tdebugMode: boolean\\n\\tattemptsPerCall: number\\n}\\n\\nexport function setupAI(arg: string | PromptGunConfig) {\\n\\tconst config = effectivePromptGunConfig(arg)\\n\\tai['config'] = config\\n\\tai['_apiKeyChain'] = obtainAiClientData(config)\\n}\\n\\nexport function newAIClient(promptGridApiKey: string): AIClient\\nexport function newAIClient(config: PromptGunConfig): AIClient\\nexport function newAIClient(arg: string | PromptGunConfig): AIClient {\\n\\tconst config = effectivePromptGunConfig(arg)\\n\\treturn new AIClient(config)\\n}\\n\\nfunction effectivePromptGunConfig(arg: string | PromptGunConfig): EffectivePromptGunConfig {\\n\\tif (typeof arg === 'string') {\\n\\t\\treturn {\\n\\t\\t\\tpromptGridApiKey: effectivePromptGridApiKey(arg),\\n\\t\\t\\tdebugMode: false,\\n\\t\\t\\tattemptsPerCall: 1,\\n\\t\\t}\\n\\t}\\n\\treturn {\\n\\t\\tpromptGridApiKey: effectivePromptGridApiKey(arg.promptGridApiKey),\\n\\t\\tapiKeys: arg.apiKeys,\\n\\t\\tdebugMode: arg.debugMode ?? false,\\n\\t\\tattemptsPerCall: effectiveAttemptsPerCall(arg.attemptsPerCall),\\n\\t}\\n}\\n\\nfunction effectivePromptGridApiKey(rawPromptGridApiKey: string | undefined) {\\n\\treturn assertType(\\n\\t\\trawPromptGridApiKey,\\n\\t\\tspecType(rawPromptGridApiKey)\\n\\t\\t\\t.string()\\n\\t\\t\\t.orUndefined(),\\n\\t\\t{errorMessage: `Please provide a valid API key; got ${rawPromptGridApiKey}`}\\n\\t)\\n}\\n\\nfunction effectiveAttemptsPerCall(rawAttemptsPerCall: number | undefined): number {\\n\\tconst typedAttemptsPerCall = assertType(\\n\\t\\trawAttemptsPerCall,\\n\\t\\tspecType(rawAttemptsPerCall)\\n\\t\\t\\t.number()\\n\\t\\t\\t.orUndefined(),\\n\\t\\t{errorMessage: `Please provide a valid number of attempts per call; got ${rawAttemptsPerCall}`}\\n\\t) ?? 1\\n\\tif (typedAttemptsPerCall < 1) {\\n\\t\\tthrow new Error(`Please provide a valid number of attempts per call; minimum is 1; got ${typedAttemptsPerCall}`)\\n\\t}\\n\\treturn typedAttemptsPerCall\\n}\\n\\nexport function obtainAiClientData(config: PromptGunConfig) {\\n\\tconst promptGridApiKey = config.promptGridApiKey\\n\\tconst apiKeys = config.apiKeys\\n\\n\\treturn {\\n\\t\\tpromptgrid: promptGridApiKey,\\n\\t\\topenai: (async () => {\\n\\t\\t\\tif (apiKeys?.openai) {\\n\\t\\t\\t\\treturn apiKeys.openai\\n\\t\\t\\t}\\n\\t\\t\\tif (promptGridApiKey === undefined) {\\n\\t\\t\\t\\treturn undefined\\n\\t\\t\\t}\\n\\t\\t\\tconst response = await (async () => {\\n\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\treturn await fetch(\\n\\t\\t\\t\\t\\t\\t`${getPromptGridApiUrl()}/handshake`,\\n\\t\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\tmethod: 'POST',\\n\\t\\t\\t\\t\\t\\t\\theaders: {\\n\\t\\t\\t\\t\\t\\t\\t\\t'Content-Type': 'application/json',\\n\\t\\t\\t\\t\\t\\t\\t\\t'User-Agent': 'promptgun',\\n\\t\\t\\t\\t\\t\\t\\t\\t'Authorization': `Bearer ${promptGridApiKey}`,\\n\\t\\t\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t)\\n\\t\\t\\t\\t} catch (e) {\\n\\t\\t\\t\\t\\tthrow new Error('HTTP called failed when doing handshake')\\n\\t\\t\\t\\t}\\n\\t\\t\\t})()\\n\\t\\t\\tif (response.status !== 200) {\\n\\t\\t\\t\\tconst body = await response.text()\\n\\t\\t\\t\\tthrow new Error(`Handshake failed with status ${response.status}, body: ${body}`)\\n\\t\\t\\t}\\n\\t\\t\\tconst handshakeData = await response.json() as HandshakeData\\n\\t\\t\\treturn handshakeData.apiKeys.openai\\n\\t\\t})(),\\n\\t}\\n}\\n\\n// Create a map to store resolved prompt UUIDs\\nconst promptMappings = new Map<string, string>();\\n\\n// Function to generate a key for the promptMappings map\\nfunction createPromptMappingKey(filename: string, lineNumber: number): string {\\n\\treturn `${filename}:${lineNumber}`;\\n}\\n\\n// Function to safely generate the key, handling undefined values\\nfunction safeCreateMappingKey(filename: string | undefined, lineNumber: number | undefined): string | null {\\n\\tif (filename && lineNumber !== undefined) {\\n\\t\\treturn createPromptMappingKey(filename, lineNumber);\\n\\t}\\n\\treturn null;\\n}\\n\\nexport function promptAI(client?: AIClient): PromptBase {\\n\\tconst effectiveClient = client ?? ai\\n\\tif (effectiveClient['apiKeyChain'] === undefined) {\\n\\t\\tthrow new Error('No LLM set up. Call setupPromptGun first: ```import { setupPromptGun } from \\\\'promptgun\\\\';\\\\n\\\\nsetupPromptGun({openAI: \\\"YOUR_OPENAI_API_KEY\\\"});\\\\n```')\\n\\t}\\n\\treturn new PromptBase(effectiveClient, getCallerFileNameAndLineNumber())\\n}\\n\\nclass PromptBase {\\n\\tconstructor(\\n\\t\\tprivate aiClient: AIClient,\\n\\t\\tprivate callingCodeLine: CodeLine,\\n\\t) {}\\n\\n\\tcompleteChat<T extends undefined>(toPrompt: (args?: T, typeSpecMessage?: TypeSpecMessage) => Prompt): BasicPrompt<T>\\n\\tcompleteChat<T>(toPrompt: (args: T, typeSpecMessage?: TypeSpecMessage) => Prompt, args: T): BasicPrompt<T>\\n\\tcompleteChat<T = undefined>(toPrompt: (args?: T, typeSpecMessage?: TypeSpecMessage) => Prompt, args?: T): BasicPrompt<T>\\n\\tcompleteChat<T = undefined>(\\n\\t\\ttoPrompt: (args?: T, typeSpecMessage?: TypeSpecMessage) => Prompt,\\n\\t\\targs?: T,\\n\\t): BasicPrompt<T> {\\n\\t\\treturn new BasicPrompt<T>(\\n\\t\\t\\tthis.aiClient,\\n\\t\\t\\ttoPrompt,\\n\\t\\t\\targs as T,\\n\\t\\t\\tgetCallerFileNameAndLineNumber(),\\n\\t\\t\\tundefined,\\n\\t\\t\\tundefined,\\n\\t\\t\\tundefined,\\n\\t\\t\\tundefined,\\n\\t\\t\\tfalse,\\n\\t\\t)\\n\\t}\\n}\\n\\nclass BasicPrompt<PSArgs> implements AsyncGenerator<string>, Promise<string> {\\n\\tprivate readonly generator: AsyncGenerator<string>\\n\\tprivate promptName?: string;\\n\\tprivate _tools?: ToolDefinition[];\\n\\n\\tconstructor(\\n\\t\\tprivate aiClient: AIClient,\\n\\t\\tprivate promptSupplier: (args: PSArgs, typeSpecMessage?: TypeSpecMessage) => Prompt,\\n\\t\\tprivate promptSupplierArgs: PSArgs,\\n\\t\\tprivate callingCodeLine: CodeLine,\\n\\t\\tprivate _temperature: number | undefined,\\n\\t\\tprivate _topP: number | undefined,\\n\\t\\tprivate _serviceTier: ServiceTier | undefined,\\n\\t\\tprivate _model: AiModelId | undefined,\\n\\t\\tprivate _firstThink: boolean,\\n\\t) {\\n\\t\\tconst self = this;\\n\\t\\tthis.generator = (async function* () {\\n\\t\\t\\tyield* await executeLlmCall(\\n\\t\\t\\t\\tself.aiClient,\\n\\t\\t\\t\\t_model,\\n\\t\\t\\t\\tself.genericMessages,\\n\\t\\t\\t\\tfalse,\\n\\t\\t\\t\\tself.promptName,\\n\\t\\t\\t\\t_temperature,\\n\\t\\t\\t\\t_topP,\\n\\t\\t\\t\\t_serviceTier,\\n\\t\\t\\t\\tcallingCodeLine,\\n\\t\\t\\t\\tundefined,\\n\\t\\t\\t\\tself._tools,\\n\\t\\t\\t)\\n\\t\\t})()\\n\\t}\\n\\n\\tpublic name(name: string): this {\\n\\t\\tthis.promptName = name;\\n\\t\\treturn this;\\n\\t}\\n\\n\\tpublic model(model: AiModelId): this {\\n\\t\\tthis._model = model;\\n\\t\\treturn this;\\n\\t}\\n\\n\\t/**\\n\\t * If requesting data, the model is asked to write out a\\n\\t * reasoning, step by step, before any of the requested\\n\\t * JSON is outputted.\\n\\t */\\n\\tpublic firstThink(firstThink: boolean = true) {\\n\\t\\tthis._firstThink = firstThink\\n\\t\\treturn this\\n\\t}\\n\\n\\t/**\\n\\t * What sampling temperature to use, between 0 and 2.\\n\\t * Higher values like 0.8 will make the output more random,\\n\\t * while lower values like 0.2 will make it more focused\\n\\t * and deterministic.\\n\\t * We generally recommend altering this or <b>topP</b> but not both.\\n\\t */\\n\\tpublic temperature(temperature: number): this {\\n\\t\\tthis._temperature = temperature;\\n\\t\\treturn this;\\n\\t}\\n\\n\\t/**\\n\\t * An alternative to sampling with temperature, called nucleus\\n\\t * sampling, where the model considers the results of the\\n\\t * tokens with top_p probability mass.\\n\\t * So 0.1 means only the tokens comprising the top 10%\\n\\t * probability mass are considered.\\n\\t *\\n\\t * We generally recommend altering this or <b>temperature</b>\\n\\t * but not both.\\n\\t */\\n\\tpublic topP(topP: number): this {\\n\\t\\tthis._topP = topP;\\n\\t\\treturn this;\\n\\t}\\n\\n\\t/**\\n\\t * Using the flex tier will make your prompts run significantly slower in exchange for a discount.\\n\\t */\\n\\tpublic flex(useFlexTier = true) {\\n\\t\\tthis._serviceTier = useFlexTier ? 'flex' : undefined\\n\\t\\treturn this\\n\\t}\\n\\n\\t// Getters for getting the result\\n\\tpublic get result() {\\n\\t\\treturn this\\n\\t}\\n\\n\\tpublic get messages(): Message[] {\\n\\t\\treturn this.genericMessages\\n\\t\\t\\t.map(m => ({[m.role]: m.content} as unknown as Message))\\n\\t}\\n\\n\\tprivate get json() {\\n\\t\\treturn false\\n\\t}\\n\\n\\tprivate get genericMessages() {\\n\\t\\tconst prompt = this.promptSupplier(this.promptSupplierArgs, TypeSpecMarker)\\n\\t\\tconst {messages: genericPrompt, typeSpecIndex} = toGenericPrompt(prompt, TypeSpecMarker)\\n\\t\\tif (!this.json) {\\n\\t\\t\\treturn genericPrompt\\n\\t\\t}\\n\\n\\t\\tconst jsonSpecMessage = {\\n\\t\\t\\trole: 'user' as const,\\n\\t\\t\\tcontent: jsonSpec(this._model, this.json, this._firstThink)\\n\\t\\t}\\n\\n\\t\\t// If TypeSpecMessage was found, insert at that position\\n\\t\\tif (typeSpecIndex !== undefined) {\\n\\t\\t\\treturn [\\n\\t\\t\\t\\t...genericPrompt.slice(0, typeSpecIndex),\\n\\t\\t\\t\\tjsonSpecMessage,\\n\\t\\t\\t\\t...genericPrompt.slice(typeSpecIndex)\\n\\t\\t\\t]\\n\\t\\t}\\n\\n\\t\\t// Otherwise, place at the end of the message array\\n\\t\\treturn [\\n\\t\\t\\t...genericPrompt,\\n\\t\\t\\tjsonSpecMessage\\n\\t\\t];\\n\\t}\\n\\n\\t// Methods for the generator interface\\n\\n\\tnext(...[value]: [] | [any]): Promise<IteratorResult<string, any>> {\\n\\t\\treturn this.generator.next(value)\\n\\t}\\n\\n\\treturn(value: any): Promise<IteratorResult<string, any>> {\\n\\t\\treturn this.generator.return(value)\\n\\t}\\n\\n\\tthrow(e: any): Promise<IteratorResult<string, any>> {\\n\\t\\treturn this.generator.throw(e)\\n\\t}\\n\\n\\t[Symbol.asyncIterator](): AsyncGenerator<string, any, any> {\\n\\t\\treturn this\\n\\t}\\n\\n\\t// Methods for the Promise interface\\n\\n\\tasync then<TResult1 = string, TResult2 = never>(\\n\\t\\tonfulfilled?: ((value: string) => TResult1 | PromiseLike<TResult1>) | null | undefined,\\n\\t\\tonrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined\\n\\t): Promise<TResult1 | TResult2> {\\n\\t\\ttry {\\n\\t\\t\\tconst result = await this.getResponseAsString()\\n\\t\\t\\treturn nonNullish(onfulfilled)\\n\\t\\t\\t\\t? await onfulfilled(result)\\n\\t\\t\\t\\t: result as TResult1\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn await onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tasync catch<TResult = never>(\\n\\t\\tonrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined\\n\\t): Promise<string | TResult> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponseAsString()\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tasync finally(onfinally?: (() => void) | null | undefined): Promise<string> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponseAsString()\\n\\t\\t} finally {\\n\\t\\t\\tonfinally?.()\\n\\t\\t}\\n\\t}\\n\\n\\tget [Symbol.toStringTag](): string {\\n\\t\\treturn 'BasicPrompt'\\n\\t}\\n\\n\\t// Other methods\\n\\tpublic get<Json extends AnyJson = AnyJson>(type: (value: EmptyTypeSpec<unknown>) => TypeSpec<Json>) {\\n\\t\\treturn new JsonPrompt<PSArgs, Json>(\\n\\t\\t\\tthis.aiClient,\\n\\t\\t\\tthis.promptSupplier,\\n\\t\\t\\tthis.promptSupplierArgs,\\n\\t\\t\\ttype,\\n\\t\\t\\tgetCallerFileNameAndLineNumber(),\\n\\t\\t\\tthis.promptName,\\n\\t\\t\\tthis._temperature,\\n\\t\\t\\tthis._topP,\\n\\t\\t\\tthis._serviceTier,\\n\\t\\t\\tthis._model,\\n\\t\\t\\tthis._firstThink,\\n\\t\\t\\tthis._tools,\\n\\t\\t)\\n\\t}\\n\\n\\tpublic getBoolean() {\\n\\t\\treturn this.get(o => o.boolean())\\n\\t}\\n\\n\\tpublic getString() {\\n\\t\\treturn this.get(o => o.string())\\n\\t}\\n\\n\\tpublic getNumber() {\\n\\t\\treturn this.get(o => o.number())\\n\\t}\\n\\n\\tpublic getObject<T_obj extends {}>(properties: (arg: TypeMemberSpec<{}>) => TypeMemberSpec<T_obj>) {\\n\\t\\treturn this.get(o => o\\n\\t\\t\\t.object(properties)\\n\\t\\t)\\n\\t}\\n\\n\\tpublic getArray<T_arr extends AnyJson>(element: (arg: EmptyTypeSpec<unknown>) => TypeSpec<T_arr>): JsonArrayPrompt<PSArgs, T_arr> {\\n\\t\\treturn new JsonArrayPrompt<PSArgs, T_arr>(\\n\\t\\t\\tthis.aiClient,\\n\\t\\t\\tthis.promptSupplier,\\n\\t\\t\\tthis.promptSupplierArgs,\\n\\t\\t\\to => o\\n\\t\\t\\t\\t.array<T_arr>(element),\\n\\t\\t\\tthis.callingCodeLine,\\n\\t\\t\\tthis.promptName,\\n\\t\\t\\tthis._temperature,\\n\\t\\t\\tthis._topP,\\n\\t\\t\\tthis._serviceTier,\\n\\t\\t\\tthis._model,\\n\\t\\t\\tthis._firstThink,\\n\\t\\t\\tthis._tools,\\n\\t\\t)\\n\\t}\\n\\n\\tpublic getAny() {\\n\\t\\treturn this.get(o => o.any())\\n\\t}\\n\\n\\tpublic tools(tools: ToolDefinition[]): this\\n\\tpublic tools(...tools: (ToolDefinition | undefined)[]): this\\n\\tpublic tools(...args: [ToolDefinition[]] | (ToolDefinition | undefined)[]): this {\\n\\t\\tconst normalizedTools = Array.isArray(args[0]) && args.length === 1\\n\\t\\t\\t? args[0].filter(tool => tool !== undefined)\\n\\t\\t\\t: args.filter(tool => tool !== undefined) as ToolDefinition[]\\n\\t\\tthis._tools = normalizedTools\\n\\t\\treturn this\\n\\t}\\n\\n\\tprivate async getResponseAsString(): Promise<string> {\\n\\t\\tlet result = ''\\n\\t\\tfor await (const chunk of this) {\\n\\t\\t\\tresult += chunk\\n\\t\\t}\\n\\t\\treturn result\\n\\t}\\n}\\n\\ntype JsonObject = {[key: string]: AnyJson}\\n\\ntype JsonArray = AnyJson[]\\n\\ntype AnyJson = string | null | boolean | number | JsonArray | JsonObject\\n\\ntype ToolFunction<T = any> = (args: T) => Promise<string> | string\\n\\ntype ToolDefinition<T = any> = {\\n\\tname: string\\n\\tdescription: string\\n\\tparameters: TypeSpec<T>\\n\\tfunction: ToolFunction<T>\\n}\\n\\nfunction typeSpecToJsonSchema(typeSpec: TypeSpec<any>): any {\\n\\tconst convertType = (type: any): any => {\\n\\t\\tif (Array.isArray(type)) {\\n\\t\\t\\t// Union types - for simplicity, take the first type\\n\\t\\t\\treturn convertType(type[0])\\n\\t\\t}\\n\\t\\t\\n\\t\\tswitch (type.type) {\\n\\t\\t\\tcase \\\"object\\\": {\\n\\t\\t\\t\\tconst properties: any = {}\\n\\t\\t\\t\\tconst required: string[] = []\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tfor (const [key, propSpec] of Object.entries(type.props)) {\\n\\t\\t\\t\\t\\tproperties[key] = convertType((propSpec as any).type)\\n\\t\\t\\t\\t\\tif (!(propSpec as any).optional) {\\n\\t\\t\\t\\t\\t\\trequired.push(key)\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\n\\t\\t\\t\\treturn {\\n\\t\\t\\t\\t\\ttype: \\\"object\\\",\\n\\t\\t\\t\\t\\tproperties,\\n\\t\\t\\t\\t\\trequired: required.length > 0 ? required : undefined\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tcase \\\"array\\\": {\\n\\t\\t\\t\\treturn {\\n\\t\\t\\t\\t\\ttype: \\\"array\\\",\\n\\t\\t\\t\\t\\titems: convertType(type.elementType)\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tcase \\\"string\\\": {\\n\\t\\t\\t\\treturn { type: \\\"string\\\" }\\n\\t\\t\\t}\\n\\t\\t\\tcase \\\"number\\\": {\\n\\t\\t\\t\\treturn { type: \\\"number\\\" }\\n\\t\\t\\t}\\n\\t\\t\\tcase \\\"boolean\\\": {\\n\\t\\t\\t\\treturn { type: \\\"boolean\\\" }\\n\\t\\t\\t}\\n\\t\\t\\tcase \\\"null\\\": {\\n\\t\\t\\t\\treturn { type: \\\"null\\\" }\\n\\t\\t\\t}\\n\\t\\t\\tcase \\\"undefined\\\": {\\n\\t\\t\\t\\treturn { type: \\\"null\\\" }\\n\\t\\t\\t}\\n\\t\\t\\tcase \\\"constant\\\": {\\n\\t\\t\\t\\treturn { const: type.value }\\n\\t\\t\\t}\\n\\t\\t\\tdefault: {\\n\\t\\t\\t\\treturn { type: \\\"string\\\" } // fallback\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\t\\n\\treturn convertType(typeSpec['type'])\\n}\\n\\nfunction defineTool<T>(config: {\\n\\tname: string\\n\\tdescription: string\\n\\tparameters: (spec: EmptyTypeSpec<unknown>) => TypeSpec<T>\\n\\tfunction: ToolFunction<T>\\n}): ToolDefinition<T> {\\n\\treturn {\\n\\t\\tname: config.name,\\n\\t\\tdescription: config.description,\\n\\t\\tparameters: config.parameters(specType(undefined as unknown)),\\n\\t\\tfunction: config.function\\n\\t}\\n}\\n\\nclass JsonPrompt<PSArgs, Json extends AnyJson = AnyJson> extends StreamedJsonChildElement<Json> implements AsyncGenerator<AnyJson>, Promise<Json> {\\n\\tprotected readonly stringGenerator: AsyncGenerator<string>\\n\\tprotected readonly partialJsonGenerator: AsyncGenerator<AnyJson>\\n\\tprotected _tools?: ToolDefinition[];\\n\\n\\tconstructor(\\n\\t\\tprotected aiClient: AIClient,\\n\\t\\tprotected promptSupplier: (args: PSArgs, typeSpecMessage?: TypeSpecMessage) => Prompt,\\n\\t\\tprotected promptSupplierArgs: PSArgs,\\n\\t\\tprotected jsonTypeSupplier: ((value: EmptyTypeSpec<unknown>) => TypeSpec<Json>) | undefined,\\n\\t\\tprotected callingCodeLine: CodeLine,\\n\\t\\tprotected promptName: string | undefined,\\n\\t\\tprotected _temperature: number | undefined,\\n\\t\\tprotected _topP: number | undefined,\\n\\t\\tprotected _serviceTier: ServiceTier | undefined,\\n\\t\\tprotected _model: AiModelId | undefined,\\n\\t\\tprotected _firstThink: boolean,\\n\\t\\ttools?: ToolDefinition[],\\n\\t) {\\n\\t\\tsuper()\\n\\t\\tconst thiss = this\\n\\t\\tthis._tools = tools\\n\\t\\t\\n\\t\\t// Create lazy generator that will only execute when accessed\\n\\t\\tconst lazyGenerator = (async function*() {\\n\\t\\t\\tyield* await executeLlmCall(\\n\\t\\t\\t\\taiClient,\\n\\t\\t\\t\\t_model,\\n\\t\\t\\t\\tthiss.genericMessages,\\n\\t\\t\\t\\tthiss.json,\\n\\t\\t\\t\\tpromptName,\\n\\t\\t\\t\\t_temperature,\\n\\t\\t\\t\\t_topP,\\n\\t\\t\\t\\t_serviceTier,\\n\\t\\t\\t\\tcallingCodeLine,\\n\\t\\t\\t\\tjsonTypeSupplier,\\n\\t\\t\\t\\tthiss._tools,\\n\\t\\t\\t)\\n\\t\\t})\\n\\t\\t\\n\\t\\t// Initialize generators lazily\\n\\t\\tlet flux: Flux<string> | undefined\\n\\t\\tlet jsonTokenFlux: Flux<any> | undefined\\n\\t\\tlet streamingJsonRootElement: any | undefined\\n\\t\\t\\n\\t\\tconst getFlux = () => {\\n\\t\\t\\tif (!flux) {\\n\\t\\t\\t\\tflux = Flux.fromGenerator(lazyGenerator())\\n\\t\\t\\t\\tjsonTokenFlux = new JsonTokenProcessor().processDataBuffer(flux)\\n\\t\\t\\t\\tstreamingJsonRootElement = new StreamedJsonParser().parse(jsonTokenFlux!)\\n\\t\\t\\t\\tif (jsonTypeSupplier !== undefined) {\\n\\t\\t\\t\\t\\tstreamingJsonRootElement\\n\\t\\t\\t\\t\\t\\t.onProperty(\\\"result\\\", (result: any) => result\\n\\t\\t\\t\\t\\t\\t\\t.onEachExcerpt((e: any) => {\\n\\t\\t\\t\\t\\t\\t\\t\\tif (e.token !== undefined) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tthis.push(e)\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\t\\t)\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tstreamingJsonRootElement\\n\\t\\t\\t\\t\\t\\t.onEachExcerpt((e: any) => {\\n\\t\\t\\t\\t\\t\\t\\tif (e.token !== undefined) {\\n\\t\\t\\t\\t\\t\\t\\t\\tthis.push(e)\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\treturn { flux: flux!, jsonTokenFlux: jsonTokenFlux!, streamingJsonRootElement: streamingJsonRootElement! }\\n\\t\\t}\\n\\t\\t\\n\\t\\tthis.stringGenerator = (async function*() {\\n\\t\\t\\tconst { jsonTokenFlux, streamingJsonRootElement } = getFlux()\\n\\t\\t\\tfor await (const jsonExcerpt of jsonTokenFlux) {\\n\\t\\t\\t\\tif (jsonExcerpt.token !== undefined) {\\n\\t\\t\\t\\t\\tstreamingJsonRootElement.push(jsonExcerpt)\\n\\t\\t\\t\\t} else if (jsonExcerpt.source !== undefined) {\\n\\t\\t\\t\\t\\tyield jsonExcerpt.source\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t})()\\n\\t\\tthis.partialJsonGenerator = (async function*() {\\n\\t\\t\\tlet accumulatedJson = ''\\n\\t\\t\\tfor await (const chunk of thiss.stringGenerator) {\\n\\t\\t\\t\\taccumulatedJson += chunk\\n\\t\\t\\t\\tconst partialJson = parsePartialJson<any>(accumulatedJson)\\n\\t\\t\\t\\tyield jsonTypeSupplier !== undefined\\n\\t\\t\\t\\t\\t? (partialJson as any)?.['result']\\n\\t\\t\\t\\t\\t: partialJson\\n\\t\\t\\t}\\n\\t\\t})()\\n\\t}\\n\\n\\t// Methods for the generator interface\\n\\n\\tnext(...[value]: [] | [any]): Promise<IteratorResult<AnyJson, any>> {\\n\\t\\treturn this.partialJsonGenerator.next(value)\\n\\t}\\n\\n\\treturn(value: any): Promise<IteratorResult<AnyJson, any>> {\\n\\t\\treturn this.partialJsonGenerator.return(value)\\n\\t}\\n\\n\\tthrow(e: any): Promise<IteratorResult<AnyJson, any>> {\\n\\t\\treturn this.partialJsonGenerator.throw(e)\\n\\t}\\n\\n\\t[Symbol.asyncIterator](): AsyncGenerator<AnyJson, any, any> {\\n\\t\\treturn this.partialJsonGenerator\\n\\t}\\n\\n\\t// Methods for the Promise interface\\n\\n\\toverride async then<TResult1 = Json, TResult2 = never>(\\n\\t\\tonfulfilled?: ((value: Json) => TResult1 | PromiseLike<TResult1>) | null | undefined,\\n\\t\\tonrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined\\n\\t): Promise<TResult1 | TResult2> {\\n\\t\\ttry {\\n\\t\\t\\tconst result = await this.getResponse()\\n\\t\\t\\treturn nonNullish(onfulfilled)\\n\\t\\t\\t\\t? await onfulfilled(result)\\n\\t\\t\\t\\t: result as unknown as TResult1\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn await onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\toverride async catch<TResult = never>(\\n\\t\\tonrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined\\n\\t): Promise<Json | TResult> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponse()\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\toverride async finally(onfinally?: (() => void) | null | undefined): Promise<Json> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponse()\\n\\t\\t} finally {\\n\\t\\t\\tonfinally?.()\\n\\t\\t}\\n\\t}\\n\\n\\toverride get [Symbol.toStringTag](): string {\\n\\t\\treturn 'JsonPrompt'\\n\\t}\\n\\n\\t// Other methods\\n\\n\\tpublic name(name: string): this {\\n\\t\\tthis.promptName = name;\\n\\t\\treturn this;\\n\\t}\\n\\n\\tpublic model(model: AiModelId): this {\\n\\t\\tthis._model = model;\\n\\t\\treturn this;\\n\\t}\\n\\n\\t/**\\n\\t * If requesting data, the model is asked to write out a\\n\\t * reasoning, step by step, before any of the requested\\n\\t * JSON is outputted.\\n\\t */\\n\\tpublic firstThink(firstThink: boolean = true) {\\n\\t\\tthis._firstThink = firstThink\\n\\t\\treturn this\\n\\t}\\n\\n\\t/**\\n\\t * What sampling temperature to use, between 0 and 2.\\n\\t * Higher values like 0.8 will make the output more random,\\n\\t * while lower values like 0.2 will make it more focused\\n\\t * and deterministic.\\n\\t * We generally recommend altering this or <b>topP</b> but not both.\\n\\t */\\n\\tpublic temperature(temperature: number): this {\\n\\t\\tthis._temperature = temperature;\\n\\t\\treturn this;\\n\\t}\\n\\n\\t/**\\n\\t * An alternative to sampling with temperature, called nucleus\\n\\t * sampling, where the model considers the results of the\\n\\t * tokens with top_p probability mass.\\n\\t * So 0.1 means only the tokens comprising the top 10%\\n\\t * probability mass are considered.\\n\\t *\\n\\t * We generally recommend altering this or <b>temperature</b>\\n\\t * but not both.\\n\\t */\\n\\tpublic topP(topP: number): this {\\n\\t\\tthis._topP = topP;\\n\\t\\treturn this;\\n\\t}\\n\\n\\t/**\\n\\t * Using the flex tier will make your prompts run significantly slower in exchange for a discount.\\n\\t */\\n\\tpublic flex(useFlexTier = true) {\\n\\t\\tthis._serviceTier = useFlexTier ? 'flex' : undefined\\n\\t\\treturn this\\n\\t}\\n\\n\\t// Getters for getting the result\\n\\tpublic get result() {\\n\\t\\treturn this\\n\\t}\\n\\n\\tpublic get messages(): Message[] {\\n\\t\\treturn this.genericMessages\\n\\t\\t\\t.map(m => ({[m.role]: m.content} as unknown as Message))\\n\\t}\\n\\n\\tprivate get genericMessages() {\\n\\t\\tconst prompt = this.promptSupplier(this.promptSupplierArgs, TypeSpecMarker)\\n\\t\\tconst {messages: genericPrompt, typeSpecIndex} = toGenericPrompt(prompt, TypeSpecMarker)\\n\\t\\tif (!this.json) {\\n\\t\\t\\treturn genericPrompt\\n\\t\\t}\\n\\n\\t\\tconst jsonSpecMessage = {\\n\\t\\t\\trole: 'user' as const,\\n\\t\\t\\tcontent: jsonSpec(this._model, this.json, this._firstThink)\\n\\t\\t}\\n\\n\\t\\t// If TypeSpecMessage was found, insert at that position\\n\\t\\tif (typeSpecIndex !== undefined) {\\n\\t\\t\\treturn [\\n\\t\\t\\t\\t...genericPrompt.slice(0, typeSpecIndex),\\n\\t\\t\\t\\tjsonSpecMessage,\\n\\t\\t\\t\\t...genericPrompt.slice(typeSpecIndex)\\n\\t\\t\\t]\\n\\t\\t}\\n\\n\\t\\t// Otherwise, place at the end of the message array\\n\\t\\treturn [\\n\\t\\t\\t...genericPrompt,\\n\\t\\t\\tjsonSpecMessage\\n\\t\\t];\\n\\t}\\n\\n\\tprivate get json() {\\n\\t\\treturn this.jsonTypeSupplier !== undefined\\n\\t\\t\\t? this.jsonTypeSupplier(specType(undefined as unknown))\\n\\t\\t\\t: true\\n\\t}\\n\\n\\tprotected async getResponse(): Promise<Json> {\\n\\t\\tconst stringResult = await this.getResponseAsString()\\n\\t\\tconst jsonTypeSupplier = this.jsonTypeSupplier\\n\\t\\tconst uncheckedPackedResult = parseJsonWithUsefulError(stringResult)\\n\\t\\tconst uncheckedResult = jsonTypeSupplier !== undefined\\n\\t\\t\\t? uncheckedPackedResult?.result\\n\\t\\t\\t: uncheckedPackedResult\\n\\t\\t\\n\\t\\t// Type checking is now handled in the retry loop, so we can trust the result\\n\\t\\treturn uncheckedResult as Json\\n\\t}\\n\\n\\tprivate _responseAsStringPromise?: Promise<string>\\n\\n\\tprotected getResponseAsString(): Promise<string> {\\n\\t\\tif (this._responseAsStringPromise === undefined) {\\n\\t\\t\\tthis._responseAsStringPromise = this._getResponseAsString()\\n\\t\\t}\\n\\t\\treturn this._responseAsStringPromise\\n\\t}\\n\\n\\tpublic tools(tools: ToolDefinition[]): this\\n\\tpublic tools(...tools: (ToolDefinition | undefined)[]): this\\n\\tpublic tools(...args: [ToolDefinition[]] | (ToolDefinition | undefined)[]): this {\\n\\t\\tconst normalizedTools = Array.isArray(args[0]) && args.length === 1\\n\\t\\t\\t? args[0].filter(tool => tool !== undefined)\\n\\t\\t\\t: args.filter(tool => tool !== undefined) as ToolDefinition[]\\n\\t\\tthis._tools = normalizedTools\\n\\t\\treturn this\\n\\t}\\n\\n\\tprotected async _getResponseAsString(): Promise<string> {\\n\\t\\tlet result = ''\\n\\t\\tfor await (const chunk of this.stringGenerator) {\\n\\t\\t\\tresult += chunk\\n\\t\\t}\\n\\t\\treturn result\\n\\t}\\n}\\n\\nexport class JsonArrayPrompt<PSArgs, T_arr extends AnyJson = AnyJson> extends JsonPrompt<PSArgs, T_arr[]> /*implements AsyncGenerator<T_arr>, Promise<T_arr[]>*/ {\\n\\tprotected readonly arrayElementGenerator: Flux<T_arr>\\n\\tconstructor(\\n\\t\\taiClient: AIClient,\\n\\t\\tpromptSupplier: (args: PSArgs, typeSpecMessage?: TypeSpecMessage) => Prompt,\\n\\t\\tpromptSupplierArgs: PSArgs,\\n\\t\\tjsonTypeSupplier: ((value: EmptyTypeSpec<unknown>) => TypeSpec<T_arr[]>) | undefined,\\n\\t\\tcallingCodeLine: CodeLine,\\n\\t\\tpromptName: string | undefined,\\n\\t\\t_temperature: number | undefined,\\n\\t\\t_topP: number | undefined,\\n\\t\\t_serviceTier: ServiceTier | undefined,\\n\\t\\t_model: AiModelId | undefined,\\n\\t\\t_firstThink: boolean,\\n\\t\\ttools?: ToolDefinition[],\\n\\t) {\\n\\t\\tsuper(\\n\\t\\t\\taiClient,\\n\\t\\t\\tpromptSupplier,\\n\\t\\t\\tpromptSupplierArgs,\\n\\t\\t\\tjsonTypeSupplier,\\n\\t\\t\\tcallingCodeLine,\\n\\t\\t\\tpromptName,\\n\\t\\t\\t_temperature,\\n\\t\\t\\t_topP,\\n\\t\\t\\t_serviceTier,\\n\\t\\t\\t_model,\\n\\t\\t\\t_firstThink,\\n\\t\\t\\ttools,\\n\\t\\t)\\n\\t\\tconst thiss = this\\n\\t\\tthis.arrayElementGenerator = Flux.create<T_arr>(\\n\\t\\t\\tasync (push, complete) => {\\n\\t\\t\\t\\tawait thiss\\n\\t\\t\\t\\t\\t.onElement(async element => {\\n\\t\\t\\t\\t\\t\\tpush(await element)\\n\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\tcomplete()\\n\\t\\t\\t}\\n\\t\\t)\\n\\t}\\n\\n\\t// Methods for the generator interface\\n\\n\\toverride next(...[value]: [] | [any]): Promise<IteratorResult<T_arr>> {\\n\\t\\treturn this.arrayElementGenerator.next(value)\\n\\t}\\n\\n\\toverride return(value: any): Promise<IteratorResult<T_arr, any>> {\\n\\t\\treturn this.arrayElementGenerator.return(value)\\n\\t}\\n\\n\\toverride throw(e: any): Promise<IteratorResult<T_arr, any>> {\\n\\t\\treturn this.arrayElementGenerator.throw(e)\\n\\t}\\n\\n\\toverride [Symbol.asyncIterator](): AsyncGenerator<T_arr, any, any> {\\n\\t\\treturn this.arrayElementGenerator\\n\\t}\\n\\n\\t// Methods for the Promise interface\\n\\n\\toverride async then<TResult1 = T_arr[], TResult2 = never>(\\n\\t\\tonfulfilled?: ((value: T_arr[]) => TResult1 | PromiseLike<TResult1>) | null | undefined,\\n\\t\\tonrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined\\n\\t): Promise<TResult1 | TResult2> {\\n\\t\\ttry {\\n\\t\\t\\tconst result = await this.getResponse()\\n\\t\\t\\treturn nonNullish(onfulfilled)\\n\\t\\t\\t\\t? await onfulfilled(result)\\n\\t\\t\\t\\t: result as unknown as TResult1\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn await onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\toverride async catch<TResult = never>(\\n\\t\\tonrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined\\n\\t): Promise<T_arr[] | TResult> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponse()\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\toverride async finally(onfinally?: (() => void) | null | undefined): Promise<T_arr[]> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponse()\\n\\t\\t} finally {\\n\\t\\t\\tonfinally?.()\\n\\t\\t}\\n\\t}\\n\\n\\toverride get [Symbol.toStringTag](): string {\\n\\t\\treturn 'JsonArrayPrompt'\\n\\t}\\n\\n\\t// Other methods\\n\\n\\t// protected override async getResponse(): Promise<T_arr[]> {\\n\\t// \\tconst array: T_arr[] = []\\n\\t// \\tfor await (const element of this.arrayElementGenerator) {\\n\\t// \\t\\tarray.push(element)\\n\\t// \\t}\\n\\t// \\treturn array\\n\\t// }\\n}\\n\\nfunction pickModel(modelId?: AiModelId): AiModelId {\\n\\treturn modelId ?? 'gpt-4o'\\n}\\n\\nfunction toGenericPrompt(prompt: string | Message | (Message | undefined)[], typeSpecMessage?: TypeSpecMessage): {messages: GenericPrompt, typeSpecIndex?: number} {\\n\\tconst toOpenAiMessage = (msg: Message | undefined): PromptMessage | null => {\\n\\t\\tif (msg === undefined) {\\n\\t\\t\\treturn null\\n\\t\\t}\\n\\t\\tif ('typeSpec' in msg) {\\n\\t\\t\\treturn null // TypeSpecMessage is just a placeholder\\n\\t\\t}\\n\\t\\treturn {\\n\\t\\t\\trole: msg.user !== undefined ? 'user' : (msg.system !== undefined ? 'system' : 'assistant'),\\n\\t\\t\\tcontent: requireDefined(msg.user ?? msg.system ?? msg.assistant),\\n\\t\\t}\\n\\t}\\n\\t\\n\\tif (typeof prompt === 'string') {\\n\\t\\treturn {messages: [{role: 'user' as const, content: prompt}]}\\n\\t} else if (!Array.isArray(prompt)) {\\n\\t\\tconst message = toOpenAiMessage(prompt)\\n\\t\\treturn {messages: message ? [message] : []}\\n\\t} else {\\n\\t\\tconst messages: PromptMessage[] = []\\n\\t\\tlet typeSpecIndex: number | undefined\\n\\t\\t\\n\\t\\tfor (let i = 0; i < prompt.length; i++) {\\n\\t\\t\\tconst msg = prompt[i]!\\n\\t\\t\\tif ('typeSpec' in msg) {\\n\\t\\t\\t\\ttypeSpecIndex = messages.length // Position where TypeSpec should be inserted\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tconst message = toOpenAiMessage(msg)\\n\\t\\t\\t\\tif (message) {\\n\\t\\t\\t\\t\\tmessages.push(message)\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t\\n\\t\\t// If typeSpecMessage was passed as parameter and no TypeSpecMessage found in array, use default behavior\\n\\t\\tif (typeSpecMessage && typeSpecIndex === undefined) {\\n\\t\\t\\t// typeSpecIndex remains undefined, will use default logic\\n\\t\\t}\\n\\t\\t\\n\\t\\treturn {messages, typeSpecIndex}\\n\\t}\\n}\\n\\nasync function* executeLlmCall(\\n\\taiClient: AIClient,\\n\\tmodel: AiModelId | undefined,\\n\\tgenericPromptWithJsonSpec: GenericPrompt,\\n\\tjson: boolean | TypeSpec<any>,\\n\\tpromptName: string | undefined,\\n\\ttemperature: number | undefined,\\n\\ttopP: number | undefined,\\n\\tserviceTier: ServiceTier = 'normal',\\n\\tcallingCodeLine: CodeLine,\\n\\tjsonTypeSupplier?: ((value: EmptyTypeSpec<unknown>) => TypeSpec<any>) | undefined,\\n\\ttools?: ToolDefinition[],\\n) {\\n\\tconst convSavePromises = new Map<string, {promise: Promise<void>, chunk?: string}>()\\n\\ttry {\\n\\t\\t// Find the relevant call in the stack trace (we need to skip internal calls)\\n\\t\\t// Typically this would be the first line after the executeLlmCall and other internal functions\\n\\t\\tconst {\\n\\t\\t\\tfileName: promptFilename,\\n\\t\\t\\tlineNumber: promptLineNumber,\\n\\t\\t} = callingCodeLine\\n\\n\\t\\t// Check if multiple promptLineNumbers exist for this filename\\n\\t\\tif (promptFilename && promptLineNumber !== undefined) {\\n\\t\\t\\tconst matchingPrompts = Array.from(promptMappings.keys())\\n\\t\\t\\t\\t.filter(key => key.startsWith(`${promptFilename}:`))\\n\\t\\t\\t\\t.map(key => parseInt(key.split(':')![1]!, 10));\\n\\n\\t\\t\\t// If there are multiple prompts for the same file, throw an error\\n\\t\\t\\tif (matchingPrompts.length > 1 && !promptName) {\\n\\t\\t\\t\\tthrow new Error(`Multiple prompts found in ${promptFilename}. Please specify a name using .name() method.`);\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\tconst promptProfile = {id: promptName, callingCodeLine}\\n\\n\\t\\t// Create a unique conversation ID\\n\\t\\tconst conversationUuid = aiClient.conversation?.uuid ?? randomUuid()\\n\\n\\t\\tconst saveLoop: {\\n\\t\\t\\tcurrentSave?: {\\n\\t\\t\\t\\tuuid: string\\n\\t\\t\\t\\tcallback: () => Promise<void>\\n\\t\\t\\t}\\n\\t\\t\\tsave?: {\\n\\t\\t\\t\\tuuid: string\\n\\t\\t\\t\\tcallback: () => Promise<void>\\n\\t\\t\\t}\\n\\t\\t} = {}\\n\\t\\tconst saveConv = (conversationData: ConversationData, chunk?: string) => {\\n\\t\\t\\tconst uuid = randomUuid()\\n\\t\\t\\tconst callback = async () => {\\n\\t\\t\\t\\tif (aiClient.conversation !== undefined) {\\n\\t\\t\\t\\t\\tfor (const newMsg of conversationData.messages) {\\n\\t\\t\\t\\t\\t\\tconst existing = aiClient.conversation.messages.find(m => m.messageUuid === newMsg.messageUuid)\\n\\t\\t\\t\\t\\t\\tif (existing !== undefined) {\\n\\t\\t\\t\\t\\t\\t\\tif (existing.role !== newMsg.role) {\\n\\t\\t\\t\\t\\t\\t\\t\\tthrow new Error('Illegal state')\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\texisting.content = newMsg.content\\n\\t\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\t\\taiClient.conversation.messages.push(newMsg)\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tsaveLoop.currentSave = saveLoop.save\\n\\t\\t\\t\\tsaveLoop.save = undefined\\n\\t\\t\\t\\tawait saveConversation(\\n\\t\\t\\t\\t\\tconversationData,\\n\\t\\t\\t\\t\\taiClient['apiKeyChain']!.promptgrid\\n\\t\\t\\t\\t)\\n\\t\\t\\t\\tawait new Promise(resolve => setTimeout(resolve, 100))\\n\\t\\t\\t\\tawait (saveLoop.save as (typeof saveLoop)['save'])?.callback()\\n\\t\\t\\t\\tsaveLoop.currentSave = undefined\\n\\t\\t\\t}\\n\\t\\t\\tif (saveLoop.save !== undefined) {\\n\\t\\t\\t\\tconvSavePromises.delete(saveLoop.save.uuid)\\n\\t\\t\\t}\\n\\t\\t\\tsaveLoop.save = {uuid, callback}\\n\\t\\t\\tif (saveLoop.currentSave === undefined) {\\n\\t\\t\\t\\tconvSavePromises.set(uuid, {chunk, promise: callback().then()})\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\tlet genericPromptWithJsonSpecAndConversationHistory = [\\n\\t\\t\\t...(aiClient.conversation?.messages ?? []),\\n\\t\\t\\t...genericPromptWithJsonSpec,\\n\\t\\t] as (PromptMessage & Partial<PromptMessageWithId>)[]\\n\\n\\t\\t// Send the conversation start and messages to PromptGrid\\n\\t\\tsaveConv({\\n\\t\\t\\tconversationUuid,\\n\\t\\t\\tprompt: promptProfile,\\n\\t\\t\\tmessages: genericPromptWithJsonSpecAndConversationHistory\\n\\t\\t\\t\\t.map(message => ({\\n\\t\\t\\t\\t\\tmessageUuid: message.messageUuid ?? randomUuid(),\\n\\t\\t\\t\\t\\trole: message.role,\\n\\t\\t\\t\\t\\tcontent: message.content || ''\\n\\t\\t\\t\\t})),\\n\\t\\t});\\n\\n\\t\\t// Now add an 'assistant' message that will be updated as the response streams in\\n\\t\\tlet responseMessageId = randomUuid()\\n\\t\\tsaveConv({\\n\\t\\t\\tconversationUuid,\\n\\t\\t\\tprompt: promptProfile,\\n\\t\\t\\tmessages: [\\n\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\tmessageUuid: responseMessageId,\\n\\t\\t\\t\\t\\trole: 'assistant',\\n\\t\\t\\t\\t\\tcontent: '' // Start with empty content that will be updated\\n\\t\\t\\t\\t}\\n\\t\\t\\t]\\n\\t\\t})\\n\\n\\t\\tlet incomplete = true\\n\\t\\tlet attempts = 1\\n\\t\\twhile (incomplete) {\\n\\t\\t\\ttry {\\n\\t\\t\\t\\tconst apiToken = requireThat(await aiClient['apiKeyChain']!.openai).canBeString().andNothingElse({errorMessage: 'No OpenAI access token set'})\\n\\t\\t\\t\\tconst openaiTools = tools?.map(tool => ({\\n\\t\\t\\t\\t\\ttype: 'function' as const,\\n\\t\\t\\t\\t\\tfunction: {\\n\\t\\t\\t\\t\\t\\tname: tool.name,\\n\\t\\t\\t\\t\\t\\tdescription: tool.description,\\n\\t\\t\\t\\t\\t\\tparameters: typeSpecToJsonSchema(tool.parameters)\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}))\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tconst flux = promptOpenai(\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\tmodel: pickModel(model),\\n\\t\\t\\t\\t\\t\\tprompt: genericPromptWithJsonSpecAndConversationHistory,\\n\\t\\t\\t\\t\\t\\tapiToken,\\n\\t\\t\\t\\t\\t\\ttemperature,\\n\\t\\t\\t\\t\\t\\ttopP,\\n\\t\\t\\t\\t\\t\\trequireJsonResponse: json !== false,\\n\\t\\t\\t\\t\\t\\tserviceTier,\\n\\t\\t\\t\\t\\t\\ttools: openaiTools,\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t)\\n\\n\\t\\t\\t\\tlet accumulatedContent = '';\\n\\t\\t\\t\\tlet toolCallsToExecute: ToolCall[] = []\\n\\n\\t\\t\\t\\tconst generator = flux\\n\\t\\t\\t\\t\\t.doOnEach(chunk => {\\n\\t\\t\\t\\t\\t\\tif (chunk.type === 'content') {\\n\\t\\t\\t\\t\\t\\t\\t// Regular text content\\n\\t\\t\\t\\t\\t\\t\\taccumulatedContent += chunk.content\\n\\n\\t\\t\\t\\t\\t\\t\\t// Send the updated content to PromptGrid\\n\\t\\t\\t\\t\\t\\t\\tsaveConv({\\n\\t\\t\\t\\t\\t\\t\\t\\tconversationUuid,\\n\\t\\t\\t\\t\\t\\t\\t\\tprompt: promptProfile,\\n\\t\\t\\t\\t\\t\\t\\t\\tmessages: [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tmessageUuid: responseMessageId,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\trole: 'assistant',\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tcontent: accumulatedContent,\\n\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t}, chunk.content)\\n\\t\\t\\t\\t\\t\\t} else if (chunk.type === 'toolCalls') {\\n\\t\\t\\t\\t\\t\\t\\t// Tool calls detected\\n\\t\\t\\t\\t\\t\\t\\ttoolCallsToExecute = chunk.toolCalls\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t})\\n\\n\\t\\t\\t\\t// Process all chunks first\\n\\t\\t\\t\\tfor await (const chunk of generator) {\\n\\t\\t\\t\\t\\tif (chunk.type === 'content') {\\n\\t\\t\\t\\t\\t\\tyield chunk.content\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t// If we have tool calls to execute, execute them and continue\\n\\t\\t\\t\\tif (toolCallsToExecute.length > 0 && tools) {\\n\\t\\t\\t\\t\\t// Execute each tool call\\n\\t\\t\\t\\t\\tconst toolResults = []\\n\\t\\t\\t\\t\\tfor (const toolCall of toolCallsToExecute) {\\n\\t\\t\\t\\t\\t\\tconst tool = tools.find(t => t.name === toolCall.name)\\n\\t\\t\\t\\t\\t\\tif (tool) {\\n\\t\\t\\t\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\t\\t\\t\\tconst args = toolCall.arguments.trim() === '' ? {} : JSON.parse(toolCall.arguments)\\n\\t\\t\\t\\t\\t\\t\\t\\tconst result = await tool.function(args)\\n\\t\\t\\t\\t\\t\\t\\t\\ttoolResults.push({\\n\\t\\t\\t\\t\\t\\t\\t\\t\\ttool_call_id: toolCall.id,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\trole: 'tool' as const,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tcontent: result\\n\\t\\t\\t\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\t\\t\\t} catch (error) {\\n\\t\\t\\t\\t\\t\\t\\t\\ttoolResults.push({\\n\\t\\t\\t\\t\\t\\t\\t\\t\\ttool_call_id: toolCall.id,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\trole: 'tool' as const,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tcontent: `Error: ${error instanceof Error ? error.message : String(error)}`\\n\\t\\t\\t\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\t\\ttoolResults.push({\\n\\t\\t\\t\\t\\t\\t\\t\\ttool_call_id: toolCall.id,\\n\\t\\t\\t\\t\\t\\t\\t\\trole: 'tool' as const,\\n\\t\\t\\t\\t\\t\\t\\t\\tcontent: `Error: Tool ${toolCall.name} not found`\\n\\t\\t\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t// Add tool call message to conversation\\n\\t\\t\\t\\t\\tconst toolCallMessage = {\\n\\t\\t\\t\\t\\t\\tmessageUuid: responseMessageId,\\n\\t\\t\\t\\t\\t\\trole: 'assistant' as const,\\n\\t\\t\\t\\t\\t\\tcontent: accumulatedContent || '',\\n\\t\\t\\t\\t\\t\\ttool_calls: toolCallsToExecute.map(tc => ({\\n\\t\\t\\t\\t\\t\\t\\tid: tc.id,\\n\\t\\t\\t\\t\\t\\t\\ttype: 'function' as const,\\n\\t\\t\\t\\t\\t\\t\\tfunction: {\\n\\t\\t\\t\\t\\t\\t\\t\\tname: tc.name,\\n\\t\\t\\t\\t\\t\\t\\t\\targuments: tc.arguments\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t}))\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t// Save tool calls as assistant message\\n\\t\\t\\t\\t\\tconst toolCallsDescription = toolCallMessage.tool_calls.map(tc => \\n\\t\\t\\t\\t\\t\\t`${tc.function.name}(${tc.function.arguments})`\\n\\t\\t\\t\\t\\t).join('\\\\n')\\n\\t\\t\\t\\t\\tsaveConv({\\n\\t\\t\\t\\t\\t\\tconversationUuid,\\n\\t\\t\\t\\t\\t\\tprompt: promptProfile,\\n\\t\\t\\t\\t\\t\\tmessages: [{\\n\\t\\t\\t\\t\\t\\t\\tmessageUuid: responseMessageId,\\n\\t\\t\\t\\t\\t\\t\\trole: 'assistant',\\n\\t\\t\\t\\t\\t\\t\\tcontent: toolCallMessage.content + (toolCallMessage.content ? '\\\\n\\\\n' : '') + toolCallsDescription\\n\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t// Save all tool responses as user messages in a single saveConv call\\n\\t\\t\\t\\t\\tconst toolResultMessages = toolResults.map(toolResult => {\\n\\t\\t\\t\\t\\t\\t// Find the corresponding tool call to get the tool name\\n\\t\\t\\t\\t\\t\\tconst toolName = toolCallsToExecute\\n\\t\\t\\t\\t\\t\\t\\t.find(tc => tc.id === toolResult.tool_call_id)!\\n\\t\\t\\t\\t\\t\\t\\t.name\\n\\t\\t\\t\\t\\t\\treturn {\\n\\t\\t\\t\\t\\t\\t\\tmessageUuid: randomUuid(),\\n\\t\\t\\t\\t\\t\\t\\trole: 'user' as const,\\n\\t\\t\\t\\t\\t\\t\\tcontent: `${toolName}: ${toolResult.content}`\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\tsaveConv({\\n\\t\\t\\t\\t\\t\\tconversationUuid,\\n\\t\\t\\t\\t\\t\\tprompt: promptProfile,\\n\\t\\t\\t\\t\\t\\tmessages: toolResultMessages\\n\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t// Add tool results to conversation history and make new request\\n\\t\\t\\t\\t\\tgenericPromptWithJsonSpecAndConversationHistory = [\\n\\t\\t\\t\\t\\t\\t...genericPromptWithJsonSpecAndConversationHistory,\\n\\t\\t\\t\\t\\t\\ttoolCallMessage,\\n\\t\\t\\t\\t\\t\\t...toolResults\\n\\t\\t\\t\\t\\t] as (PromptMessage & Partial<PromptMessageWithId>)[]\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t// Reset for next iteration\\n\\t\\t\\t\\t\\taccumulatedContent = ''\\n\\t\\t\\t\\t\\ttoolCallsToExecute = []\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t// Continue the loop to make another request\\n\\t\\t\\t\\t\\tresponseMessageId = randomUuid()\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t// If this is a JSON prompt with type validation, validate after completion\\n\\t\\t\\t\\tif (jsonTypeSupplier !== undefined) {\\n\\t\\t\\t\\t\\t// Then validate the complete JSON response\\n\\t\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\t\\tconst uncheckedPackedResult = parseJsonWithUsefulError(accumulatedContent)\\n\\t\\t\\t\\t\\t\\tconst uncheckedResult = uncheckedPackedResult?.result ?? uncheckedPackedResult\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t// Attempt type checking\\n\\t\\t\\t\\t\\t\\tassertType(\\n\\t\\t\\t\\t\\t\\t\\tuncheckedResult,\\n\\t\\t\\t\\t\\t\\t\\tjsonTypeSupplier(specType(uncheckedResult)),\\n\\t\\t\\t\\t\\t\\t\\t{juggleBetweenNullAndUndefined: true},\\n\\t\\t\\t\\t\\t\\t)\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t// If we get here, validation passed\\n\\t\\t\\t\\t\\t\\tincomplete = false\\n\\t\\t\\t\\t\\t} catch (typeError) {\\n\\t\\t\\t\\t\\t\\t// Try fallback validation (AI might have forgotten the wrapper)\\n\\t\\t\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\t\\t\\tconst uncheckedPackedResult = parseJsonWithUsefulError(accumulatedContent)\\n\\t\\t\\t\\t\\t\\t\\tassertType(\\n\\t\\t\\t\\t\\t\\t\\t\\tuncheckedPackedResult,\\n\\t\\t\\t\\t\\t\\t\\t\\tjsonTypeSupplier(specType(uncheckedPackedResult)),\\n\\t\\t\\t\\t\\t\\t\\t\\t{juggleBetweenNullAndUndefined: true},\\n\\t\\t\\t\\t\\t\\t\\t)\\n\\t\\t\\t\\t\\t\\t\\tincomplete = false\\n\\t\\t\\t\\t\\t\\t} catch (fallbackError) {\\n\\t\\t\\t\\t\\t\\t\\t// Type validation failed, treat as a retriable error\\n\\t\\t\\t\\t\\t\\t\\tconst errorMessage = typeError instanceof Error ? typeError.message : String(typeError)\\n\\t\\t\\t\\t\\t\\t\\tthrow new Error(`JSON response failed type validation: ${errorMessage}`)\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t// No type validation needed, we're done\\n\\t\\t\\t\\t\\tincomplete = false\\n\\t\\t\\t\\t}\\n\\t\\t\\t} catch (e) {\\n\\t\\t\\t\\tif (attempts >= (aiClient['config'].attemptsPerCall)) {\\n\\t\\t\\t\\t\\tthrow e\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tawait new Promise(resolve => setTimeout(resolve, 1000))\\n\\t\\t\\t\\tconsole.warn(`AI call failed, retrying (${attempts}/${aiClient['config'].attemptsPerCall})`, e)\\n\\t\\t\\t} finally {\\n\\t\\t\\t\\tattempts++\\n\\t\\t\\t}\\n\\t\\t}\\n\\t} finally {\\n\\t\\tif (aiClient['config'].debugMode) {\\n\\t\\t\\tconst promises = Array.from(convSavePromises.values()).map(c => c.promise)\\n\\t\\t\\tawait Promise.all(promises)\\n\\t\\t}\\n\\t}\\n}\\n\\nfunction jsonSpec(\\n\\tmodel: AiModelId | undefined,\\n\\tjson: true | TypeSpec<any>,\\n\\tfirstThink: boolean,\\n): string {\\n\\tswitch (model) {\\n\\t\\tdefault: {\\n\\t\\t\\tif (json === true) {\\n\\t\\t\\t\\treturn 'TYPE SPEC :: IGNORE ALL PREVIOUS TYPE SPECS\\\\n\\\\nIn your next message only, respond with JSON'\\n\\t\\t\\t}\\n\\t\\t\\tconst propSpec = (json as TypeSpec<any>)\\n\\t\\t\\tconst jsonInPrompt = new EmptyTypeSpec([], undefined as unknown)\\n\\t\\t\\t\\t.object(o => {\\n\\t\\t\\t\\t\\tlet newO = o\\n\\t\\t\\t\\t\\tif (firstThink) {\\n\\t\\t\\t\\t\\t\\tnewO = newO.hasString('reasoning', 'Elaborate your reasoning here. Think step by step. Give your thinking steps in a numbered list or in markdown with headers if the task requires it.')\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\treturn newO.has('result', () => new FullPropTypeSpec(propSpec['type'], propSpec['value']))\\n\\t\\t\\t\\t})\\n\\t\\t\\treturn `TYPE SPEC :: IGNORE ALL PREVIOUS TYPE SPECS\\\\n\\\\n`\\n\\t\\t\\t\\t+ `In its next message only, the assistant will respond with JSON matching the Typescript type below.\\\\n`\\n\\t\\t\\t\\t+ '- strictNullChecks, exactOptionalPropertyTypes are both on\\\\n'\\n\\t\\t\\t\\t+ `- a value can ONLY be null if explicitly stated, e.g. 'string | null'\\\\n`\\n\\t\\t\\t\\t+ '- optional properties (e.g. `{foo?: string}`) can only be achieved by not including it, NOT by setting them to null\\\\n'\\n\\t\\t\\t\\t// + '- examples:\\\\n'\\n\\t\\t\\t\\t// + ' - type `{foo: string}`\\\\n'\\n\\t\\t\\t\\t// + ' - GOOD: `{\\\"foo\\\": \\\"bar\\\"}`\\\\n'\\n\\t\\t\\t\\t// + ' - BAD: `{\\\"foo\\\": null}`\\\\n'\\n\\t\\t\\t\\t// + ' - type: `{foo: string | null}`\\\\n'\\n\\t\\t\\t\\t// + ' - GOOD: `{\\\"foo\\\": \\\"bar\\\"}`\\\\n'\\n\\t\\t\\t\\t// + ' - GOOD: `{\\\"foo\\\": null}`\\\\n'\\n\\t\\t\\t\\t// + ' - BAD: `{}`\\\\n'\\n // + ' - type: `{foo?: string}`\\\\n'\\n\\t\\t\\t\\t// + ' - GOOD: `{\\\"foo\\\": \\\"bar\\\"}`\\\\n'\\n\\t\\t\\t\\t// + ' - GOOD: `{}`\\\\n'\\n\\t\\t\\t\\t// + ' - BAD: `{\\\"foo\\\": null}`\\\\n'\\n\\t\\t\\t\\t+ '\\\\n'\\n + 'The type:\\\\n'\\n + `${describeType(jsonInPrompt)}`\\n\\t\\t}\\n\\t}\\n}\\n\\nexport type { JsonExcerpt } from './json-streaming/JsonExcerpt.js'\\nexport type { StreamedJsonElement, ElementType, PropType } from './json-streaming/StreamedJsonElement.js'\\nexport type { Token, TokenType } from './json-streaming/types.js'\\nexport type {\\n\\tBaseType,\\n\\tTypeType,\\n\\tNullType,\\n\\tBooleanType,\\n\\tStringType,\\n\\tNumberType,\\n\\tObjectType,\\n\\tArrayType,\\n\\tConstantType,\\n\\tCombine,\\n\\tType,\\n\\tUndefinedType,\\n} from './type-spec/type-spec.js'\\nexport {\\n\\tEmptyTypeSpec,\\n\\tTypeSpec,\\n\\tFullTypeSpec,\\n\\tTypeMemberSpec,\\n\\tFullPropTypeSpec,\\n\\tEmptyPropTypeSpec,\\n\\tPropTypeSpec,\\n} from './type-spec/type-spec.js'\\n// Helper constant to create a TypeSpecMessage\\nexport const TypeSpecMarker = {typeSpec: true} as const\\n\\nexport { AIClient, BasicPrompt, JsonPrompt, PromptBase, StreamedJsonChildElement, StreamedJsonRootElement, defineTool }\\nexport type { ApiKeys as AccessTokens, AnyJson, AssistantMessage, DeveloperMessage, HandshakeData, JsonArray, JsonObject, Message, Opts, Prompt, SystemMessage, UserMessage, TypeSpecMessage, ToolDefinition, ToolFunction }\\nexport type { AiModelId } from './ai-inference/AiModelId.js'\\nexport { AiModel } from './ai-inference/AiModel.js'\\nexport { parsePartialJson } from './parse-partial-json/parsePartialJson.js'\\nexport type { DeepPartial } from './parse-partial-json/parsePartialJson.js'\\nexport type { ImageSize } from './ai-inference/openai/promptOpenaiImageGen.js'\\nexport type { OpenaiImageModelId } from './ai-inference/openai/OpenaiImageModelId.js'\\nexport { OpenaiImageModel } from './ai-inference/openai/OpenaiImageModel.js'\\nexport type { GenericPrompt, PromptMessage, ServiceTier, PromptMessageWithId, Role }\\n\\nexport type CodeLine = {\\n\\tstacktraceFrame: string\\n\\tfileName: string\\n\\tlineNumber: number\\n\\tfunctionName?: string\\n}\\n\\nexport function getCallerFileNameAndLineNumber(): CodeLine {\\n\\tconst error = new Error()\\n\\tconst stacktrace = error.stack ?? ''\\n\\tconst stack = stacktrace\\n\\t\\t.split('\\\\n')\\n\\t\\t.map(l => l.trim())\\n\\t\\t.filter(l => l.startsWith('at '))\\n\\tconst frame = stack[2]!\\n\\tconst hasFunctionNameInFrameWithFileNameInParenthesis = frame.match(/[^(]+\\\\([^)]+\\\\)/)\\n\\tconst {\\n\\t\\tfunctionName,\\n\\t\\tfileName,\\n\\t\\tlineNumber,\\n\\t} = hasFunctionNameInFrameWithFileNameInParenthesis\\n\\t\\t? frame.match('at (?<functionName>[^(]*) \\\\((?<scheme>.*://)?(?<fileName>[^:]*):(?<lineNumber>[0-9]+):(?<colNumber>[0-9]+)\\\\)')!.groups!\\n\\t\\t: frame.match('at (?<scheme>.*://)?(?<fileName>[^:]*):(?<lineNumber>[0-9]+):(?<colNumber>[0-9]+)')!.groups!\\n\\treturn {\\n\\t\\tstacktraceFrame: requireThat(frame).canBeString().andNothingElse(),\\n\\t\\tfileName: requireThat(fileName).canBeString().andNothingElse(),\\n\\t\\tlineNumber: requireThat(parseInt(lineNumber!)).canBeNumber().andNothingElse(),\\n\\t\\tfunctionName: requireThat(functionName).canBeString().canBeUndefined().andNothingElse(),\\n\\t}\\n}\\n\\ntype PromptMessageWithId = PromptMessage & {\\n\\tmessageUuid: string\\n}\\n\\n// Define a type for conversation data\\ninterface ConversationData {\\n\\tconversationUuid: string\\n\\tprompt: {\\n\\t\\tid: string | undefined\\n\\t\\tcallingCodeLine: CodeLine\\n\\t}\\n\\tmessages: PromptMessageWithId[]\\n}\\n\\n// Function to save conversation using HTTP PUT\\nasync function saveConversation(\\n\\tconversationData: ConversationData,\\n\\tapiKey: string | undefined,\\n) {\\n\\ttry {\\n\\t\\tif (apiKey === undefined) {\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tconst response = await fetch(`${getPromptGridApiUrl()}/api/conversations`, {\\n\\t\\t\\tmethod: 'PUT',\\n\\t\\t\\theaders: {\\n\\t\\t\\t\\t'Content-Type': 'application/json',\\n\\t\\t\\t\\t'Authorization': `Bearer ${apiKey}`\\n\\t\\t\\t},\\n\\t\\t\\tbody: JSON.stringify(conversationData),\\n\\t\\t});\\n\\n\\t\\tif (!response.ok) {\\n\\t\\t\\tthrow new Error(`Got ${response.status} when attempting to save conversation, with body: ${await response.text()}`);\\n\\t\\t}\\n\\t} catch (error) {\\n\\t\\tconsole.error('Error saving conversation', error);\\n\\t}\\n}\\n\\n\",\"import {AiModelId} from '../AiModelId.ts'\\nimport {PlatformSpecificPromptRequest} from '../model.js'\\nimport {Flux} from 'monoflux'\\n\\nexport type ToolCall = {\\n id: string\\n name: string\\n arguments: string\\n}\\n\\nexport type ContentChunk = {\\n type: 'content'\\n content: string\\n}\\n\\nexport type ToolCallsChunk = {\\n type: 'toolCalls'\\n toolCalls: ToolCall[]\\n}\\n\\nexport type PromptChunk = ContentChunk | ToolCallsChunk\\n\\nfunction errorMessage(bodyText: string) {\\n try {\\n const body = JSON.parse(bodyText) as { error: { message: string } }\\n return body.error.message\\n } catch (e) {\\n return bodyText\\n }\\n}\\n\\nexport function promptOpenai(\\n {\\n model,\\n prompt,\\n apiToken,\\n temperature,\\n topP,\\n requireJsonResponse,\\n serviceTier,\\n tools,\\n }: PlatformSpecificPromptRequest<boolean> & {\\n tools?: {\\n type: 'function'\\n function: {\\n name: string\\n description: string\\n parameters: any\\n }\\n }[]\\n }\\n): Flux<PromptChunk> {\\n return Flux.fromGeneratorFunction(async function* () {\\n const abortController = new AbortController()\\n const response = await fetch(\\n `https://api.openai.com/v1/chat/completions`,\\n {\\n headers: {\\n 'Content-Type': 'application/json',\\n 'Accept': 'application/json',\\n 'Authorization': `Bearer ${apiToken}`\\n },\\n method: 'POST',\\n signal: abortController.signal,\\n body: JSON.stringify({\\n model,\\n messages: prompt,\\n stream: true,\\n temperature,\\n top_p: topP,\\n response_format: requireJsonResponse ? {\\n type: 'json_object'\\n } : undefined,\\n service_tier: serviceTier === 'flex' ? 'flex' : 'default',\\n tools,\\n } satisfies OpenAiRequestBody)\\n }\\n )\\n if (response.status < 200 || response.status >= 300) {\\n const message = errorMessage(await response.text())\\n throw new Error(`OpenAPI reported: ${message}`)\\n }\\n if (response.body === null) {\\n throw new Error('illegal state')\\n }\\n let jsonBuffer = ''\\n let accumulatedToolCalls: Record<string, { id: string; name: string; arguments: string }> = {}\\n \\n yield* Flux\\n .fromReadableStream(response.body, () => abortController.abort())\\n .map(value => textDecoder.decode(value, {stream: true}))\\n .flatMap(value =>\\n value\\n .replaceAll('data: [DONE]', '')\\n .replace(/^data: /, '')\\n .split('data: ')\\n )\\n .map(\\n value => value\\n .replace(/[\\\\n ]*$/, '')\\n .trim()\\n )\\n .flatMap(value => {\\n jsonBuffer += value\\n try {\\n const json = JSON.parse(jsonBuffer) as ChatCompletionChunk\\n jsonBuffer = ''\\n return [json]\\n } catch (e) {\\n return [] as ChatCompletionChunk[]\\n }\\n })\\n .map(chunk => chunk.choices[0]!)\\n .flatMap(choice => {\\n \\n // Handle tool calls accumulation\\n if (choice.delta.tool_calls) {\\n for (const toolCall of choice.delta.tool_calls) {\\n if (toolCall.id && toolCall.function?.name) {\\n // First chunk with id and name\\n accumulatedToolCalls[toolCall.id] = {\\n id: toolCall.id,\\n name: toolCall.function.name,\\n arguments: toolCall.function.arguments || ''\\n }\\n } else if (toolCall.id && accumulatedToolCalls[toolCall.id]) {\\n // Subsequent chunks with more arguments\\n accumulatedToolCalls[toolCall.id]!.arguments += toolCall.function?.arguments || ''\\n } else if (toolCall.index !== undefined && toolCall.function?.arguments) {\\n // Handle streaming by index when id is not present\\n const existingEntry = Object.values(accumulatedToolCalls)[toolCall.index]\\n if (existingEntry) {\\n existingEntry.arguments += toolCall.function.arguments\\n }\\n }\\n }\\n }\\n \\n // If we're finishing with tool calls, emit them\\n if (choice.finish_reason === 'tool_calls') {\\n return [{\\n type: 'toolCalls' as const,\\n toolCalls: Object.values(accumulatedToolCalls)\\n }] as PromptChunk[]\\n }\\n \\n // If we have regular content, emit it\\n if (choice.delta.content) {\\n return [{\\n type: 'content' as const,\\n content: choice.delta.content\\n }] as PromptChunk[]\\n }\\n \\n // Check if we're done\\n if (choice.finish_reason && choice.finish_reason !== 'tool_calls') {\\n return [] as PromptChunk[]\\n }\\n \\n return [] as PromptChunk[]\\n })\\n .filter<PromptChunk>(item => item !== undefined && item !== null)\\n })\\n}\\n\\nconst textDecoder = new TextDecoder()\\n\\ntype OpenAiRequestBody = {\\n model: AiModelId\\n messages: {\\n role: 'developer' | 'system' | 'user' | 'assistant' | 'tool'\\n content: string | string[] | null\\n tool_call_id?: string\\n }[]\\n stream: boolean\\n temperature?: number\\n top_p?: number\\n response_format?: {\\n type: 'json_object' | 'text'\\n }\\n service_tier?: 'default' | 'flex'\\n tools?: {\\n type: 'function'\\n function: {\\n name: string\\n description: string\\n parameters: any\\n }\\n }[]\\n}\\n\\ntype ChatCompletionChunk = {\\n id: string\\n choices: {\\n id: number\\n delta: {\\n refusal?: string\\n content?: string\\n role?: string\\n tool_calls?: {\\n id?: string\\n index?: number\\n type?: 'function'\\n function?: {\\n name?: string\\n arguments?: string\\n }\\n }[]\\n }\\n finish_reason?: string | 'tool_calls'\\n }[]\\n // usage: {\\n // completion_tokens: number\\n // prompt_tokens: number\\n // total_tokens: number\\n // completion_tokens_details: {\\n // accepted_prediction_tokens: number\\n // audio_tokens: number\\n // reasoning_tokens: number\\n // rejected_prediction_tokens: number\\n // }\\n // prompt_tokens_details: {\\n // audio_tokens: number\\n // cached_tokens: number\\n // }\\n // } | null\\n}\\n\",\"export type Combine<Current, New> = unknown extends Current\\n ? New\\n : (Current & New) extends never\\n ? Current | New\\n : (Current & New)\\n\\ntype Simplify<T> = {\\n [K in keyof T]: Simplify<T[K]>\\n}\\n\\nexport type Opts = {\\n ignoreUnknownProps?: boolean\\n logValueIfWrong?: boolean\\n errorMessage?: string\\n}\\n\\ntype Problem = {\\n path: string\\n expectedType?: Type[]\\n expectedProp?: string\\n value: unknown\\n unknownProp?: string\\n}\\n\\nclass ComplexTypeError extends Error {\\n public readonly data: any\\n public readonly httpStatus = 400\\n\\n constructor(problems: Problem[], message?: string) {\\n const data = problems\\n .map(problem => {\\n if (problem.expectedProp) {\\n return {\\n expectedProp: (problem.path + '.').replace(/^root\\\\./, '') + problem.expectedProp\\n }\\n } else if (problem.expectedType) {\\n return {\\n expectedType: problem.expectedType.map(typeToString).join(' | '),\\n path: problem.path,\\n insteadGot: problem.value\\n }\\n } else if (problem.unknownProp) {\\n return {\\n unknownProp: (problem.path + '.').replace(/^root\\\\./, '') + problem.unknownProp\\n }\\n } else {\\n throw new Error('illegal state')\\n }\\n })\\n super(message ?? `Value is of the wrong format: ${JSON.stringify(data, null, 2)}`)\\n this.data = data\\n }\\n}\\n\\n/**\\n * Way to assert the shape of a type both in runtime and in the\\n * type system.\\n *\\n * Usage example:\\n *\\n * ```typescript\\n * const inputValue = ['foo', 'bar'] as unknown\\n *\\n * assert(\\n * inputValue,\\n * t => t\\n * .canBeArray(t => t\\n * .canBeObject(t => t\\n * .canHaveString('foo')\\n * .canHaveString('bar')\\n * )\\n * )\\n * )\\n *\\n * let safeInputvalue = inputValue\\n *\\n * safeInputvalue = [{}] // typescript disapproves\\n * safeInputvalue = [{foo: 'bla', bar: 'bla'}] // typescript approves\\n * ```\\n */\\nexport function requireThat(\\n value: unknown\\n): TypeSpec<unknown> {\\n return new TypeSpec<unknown>([], value)\\n}\\n\\nfunction checkIsOneOf(value: unknown, types: Type[], path: string, opts: Opts): Problem[] {\\n const problemsPerType = types\\n .map(type => checkIs(value, type, path, opts))\\n if (problemsPerType.some(list => list.length === 0)) {\\n return []\\n } else {\\n const typeProblemsOnThisPath = problemsPerType\\n .flatMap(list => list.filter(t => t.expectedType !== undefined && t.path === path))\\n if (typeProblemsOnThisPath.length > 0) {\\n return [{\\n expectedType: typeProblemsOnThisPath\\n .flatMap(problem => problem.expectedType!),\\n path,\\n value\\n }]\\n }\\n return problemsPerType.flatMap(list => list)\\n }\\n}\\n\\nfunction checkIs(value: unknown, type: Type, path: string, opts: Opts): Problem[] {\\n const {ignoreUnknownProps = true} = opts\\n switch (type.type) {\\n case 'array': {\\n if (!Array.isArray(value)) {\\n return [{expectedType: [type], path, value}]\\n }\\n if (value.length === 0) {\\n return []\\n }\\n return checkIsOneOf(value[0], type.elementType, path + '[..]', opts)\\n }\\n case 'boolean': {\\n if (typeof value !== 'boolean') {\\n return [{expectedType: [type], path, value}]\\n }\\n return []\\n }\\n case 'undefined': {\\n return value === undefined\\n ? []\\n : [{expectedType: [type], path, value}]\\n }\\n case 'object': {\\n if (typeof value !== 'object' || value === null) {\\n return [{expectedType: [type], path, value}]\\n }\\n const problems: Problem[] = []\\n for (const key in type.props) {\\n const prop = type.props[key]!\\n if (!(key in value)) {\\n if (!prop.optional) {\\n problems.push({expectedProp: key, path, value})\\n }\\n continue\\n }\\n const typeAccountingOptionality: Type[] = prop.optional\\n ? [...prop.type, {type: 'undefined'}]\\n : prop.type\\n problems.push(...checkIsOneOf(value[key as keyof typeof value], typeAccountingOptionality, path + `.${key}`, opts))\\n }\\n if (!ignoreUnknownProps) {\\n for (const key in value) {\\n if (!(key in type.props)) {\\n problems.push({unknownProp: key, path, value})\\n }\\n }\\n }\\n return problems\\n }\\n case 'string': {\\n return typeof value === 'string'\\n ? []\\n : [{expectedType: [type], path, value}]\\n }\\n case 'null': {\\n return value === null\\n ? []\\n : [{expectedType: [type], path, value}]\\n }\\n case 'number': {\\n return typeof value === 'number'\\n ? []\\n : [{expectedType: [type], path, value}]\\n }\\n case 'constant': {\\n return value === type.value && !Number.isNaN(value)\\n ? []\\n : [{expectedType: [type], path, value}]\\n }\\n }\\n}\\n\\nexport class TypeSpec<T> {\\n public readonly type: Type[]\\n private readonly value: unknown\\n\\n constructor(type: Type[] = [], value: unknown) {\\n this.type = type\\n this.value = value\\n }\\n\\n canBeArray<T_arr = unknown>(assertTypeOfArray: (arg: TypeSpec<unknown>) => TypeSpec<T_arr>) {\\n const elementSpec = assertTypeOfArray(new TypeSpec<unknown>([], this.value))\\n const arraySpec = new TypeSpec<unknown>(\\n [{type: 'array', elementType: elementSpec.type}],\\n this.value\\n )\\n return new TypeSpec<Combine<T, T_arr[]>>([...this.type, ...arraySpec.type], this.value)\\n }\\n\\n canBeObject<T_obj extends {}>(assertTypeOfObject: (arg: TypeSpec<{}>) => TypeSpec<T_obj>) {\\n const objectSpec = assertTypeOfObject(new TypeSpec([{type: 'object', props: {}}], this.value))\\n return new TypeSpec<Combine<T, T_obj>>([...this.type, ...objectSpec.type], this.value)\\n }\\n\\n hasString<Key extends string>(propertyName: Key): TypeSpec<Combine<T, Record<Key, string>>> {\\n return this.hasProperty(\\n propertyName,\\n type => type.canBeString()\\n )\\n }\\n\\n canHaveProperty<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: TypeSpec<unknown>) => TypeSpec<T_prop | undefined>\\n ): TypeSpec<Combine<T, Partial<Record<Key, T_prop>>>> {\\n return this.hasProperty(propertyName, assertTypeOfProperty, true)\\n }\\n\\n hasProperty<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: TypeSpec<unknown>) => TypeSpec<T_prop>,\\n optional: false\\n ): TypeSpec<Combine<T, Partial<Record<Key, T_prop>>>>\\n hasProperty<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: TypeSpec<unknown>) => TypeSpec<T_prop>,\\n optional?: boolean\\n ): TypeSpec<Combine<T, Record<Key, T_prop>>>\\n hasProperty<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: TypeSpec<unknown>) => TypeSpec<T_prop>,\\n optional = false\\n ): TypeSpec<Combine<T, Record<Key, T_prop> | Partial<Record<Key, T_prop>>>> {\\n const old = this.type.length === 1\\n ? this.type[0]!\\n : undefined\\n if (old === undefined || old.type !== 'object') {\\n throw new Error('illegal state')\\n }\\n const {type: propertyType} = assertTypeOfProperty(new TypeSpec([], this.value))\\n return new TypeSpec<Combine<T, Record<Key, T_prop>>>([{\\n ...old,\\n props: {\\n ...old.props,\\n [propertyName]: {\\n optional,\\n type: propertyType\\n }\\n }\\n }], this.value)\\n }\\n\\n canBeString() {\\n return new TypeSpec<Combine<T, string>>([...this.type, {type: 'string'}], this.value)\\n }\\n\\n canBeNumber() {\\n return new TypeSpec<Combine<T, number>>([...this.type, {type: 'number'}], this.value)\\n }\\n\\n canBeBoolean() {\\n return new TypeSpec<Combine<T, boolean>>([...this.type, {type: 'boolean'}], this.value)\\n }\\n\\n canBeConstant<Value extends (string | number | boolean)>(value: Value) {\\n return new TypeSpec<Combine<T, Value>>([...this.type, {type: 'constant', value}], this.value)\\n }\\n\\n canBeNull(): TypeSpec<Combine<T, null>> {\\n return new TypeSpec<Combine<T, null>>([...this.type, {type: 'null'}], this.value)\\n }\\n\\n canBeUndefined(): TypeSpec<Combine<T, undefined>> {\\n return new TypeSpec<Combine<T, undefined>>([...this.type, {type: 'undefined'}], this.value)\\n }\\n\\n public andNothingElse(\\n opts: Opts = {}\\n ): T {\\n const problems = checkIsOneOf(this.value, this.type, 'root', opts)\\n if (problems.length > 0) {\\n throw new ComplexTypeError(problems, opts.errorMessage)\\n }\\n return this.value as T\\n }\\n\\n public orDefaultTo<Value>(\\n value: Value,\\n opts: Opts = {}\\n ): T | Value {\\n const problems = checkIsOneOf(this.value, this.type, 'root', opts)\\n if (problems.length > 0) {\\n return value\\n }\\n return this.value as T\\n }\\n\\n public describe(): string {\\n return describe(this.type)\\n }\\n}\\n\\nfunction describe(type: Type | Type[], indentLevel = 0): string {\\n if (Array.isArray(type)) {\\n return type.map(t => describe(t, indentLevel)).join(' | ')\\n }\\n switch (type.type) {\\n case 'array': {\\n return `${describe(type.elementType, indentLevel)}[]`\\n }\\n case 'boolean': {\\n return 'boolean'\\n }\\n case 'undefined': {\\n return 'undefined'\\n }\\n case 'object': {\\n return `{\\\\n`\\n +\\n Object.keys(type.props).map(\\n key => `${indent(indentLevel + 1)}${key}: ${describe(type.props[key]!.type, indentLevel + 1)}`\\n ).join(',\\\\n')\\n + `\\\\n${indent(indentLevel)}}`\\n }\\n case 'string': {\\n return 'string'\\n }\\n case 'null': {\\n return 'null'\\n }\\n case 'number': {\\n return 'number'\\n }\\n case 'constant': {\\n return `\\\"${type.value}\\\"`\\n }\\n }\\n}\\n\\nfunction indent(depth: number) {\\n let indent = ''\\n for (let i = 0; i < depth; i++) {\\n indent += ' '\\n }\\n return indent\\n}\\n\\nexport type TypeType = 'undefined' | 'null' | 'boolean' | 'string' | 'number' | 'object' | 'array' | 'constant'\\n\\nexport type BaseType<TT extends TypeType> = {\\n type: TT\\n}\\n\\nexport type UndefinedType = BaseType<'undefined'>\\nexport type NullType = BaseType<'null'>\\nexport type BooleanType = BaseType<'boolean'>\\nexport type StringType = BaseType<'string'>\\nexport type NumberType = BaseType<'number'>\\nexport type ObjectType = BaseType<'object'> & {\\n props: Record<string, {\\n optional: boolean\\n type: Type[]\\n }>\\n}\\nexport type ArrayType = BaseType<'array'> & {\\n elementType: Type[]\\n}\\nexport type ConstantType<Value extends (string | number | boolean)> = BaseType<'constant'> & {\\n value: Value\\n}\\n\\nexport type Type =\\n UndefinedType\\n | NullType\\n | BooleanType\\n | StringType\\n | NumberType\\n | ObjectType\\n | ArrayType\\n | ConstantType<any>\\n\\nfunction typeToString(type: Type) {\\n return type.type === 'constant'\\n ? `'${type.value}'`\\n : type.type\\n}\\n\",\"import { requireThat } from \\\"./require-that/requireThat.js\\\";\\nimport {config} from 'dotenv'\\n\\nlet promptGridApiKey: string;\\nexport function getPromptGridApiKey() {\\n if (!promptGridApiKey) {\\n config()\\n const rawValue = process.env['PROMPTGRID_API_KEY']\\n promptGridApiKey = requireThat(rawValue)\\n .canBeString()\\n .andNothingElse({errorMessage: `PromptGrid API key invalid: ${rawValue}`})\\n }\\n return promptGridApiKey;\\n}\\n\\nlet promptGridApiUrl: string;\\n\\nexport function getPromptGridApiUrl() {\\n if (!promptGridApiUrl) {\\n config()\\n let url = backendUrlNotTriviallyIdentifiableInMinifiedCode()\\n const rawValue = process.env['PROMPTGRID_API_URL'] ?? url\\n promptGridApiUrl = requireThat(rawValue)\\n .canBeString()\\n .andNothingElse({errorMessage: `PromptGrid API URL invalid: ${rawValue}`})\\n }\\n return promptGridApiUrl;\\n}\\n\\n/**\\n * @returns https://api.promptgrid.ai\\n */\\nfunction backendUrlNotTriviallyIdentifiableInMinifiedCode() {\\n let url = 't'\\n url = url + 'ps'\\n url = 'ht' + url\\n url = url + ':'\\n url = url + '/'\\n url = url + '/ap'\\n url = url + 'i.pr'\\n let url2 = 'i'\\n url2 = 'd.a' + url2\\n url2 = 'gri' + url2\\n url = url + 'ompt'\\n return url + url2\\n}\\n\",\"export enum TokenType {\\n START_OBJECT = 'START_OBJECT',\\n END_OBJECT = 'END_OBJECT',\\n START_ARRAY = 'START_ARRAY',\\n END_ARRAY = 'END_ARRAY',\\n FIELD_NAME = 'FIELD_NAME',\\n VALUE_STRING = 'VALUE_STRING',\\n VALUE_NUMBER_INT = 'VALUE_NUMBER_INT',\\n VALUE_NUMBER_FLOAT = 'VALUE_NUMBER_FLOAT',\\n VALUE_TRUE = 'VALUE_TRUE',\\n VALUE_FALSE = 'VALUE_FALSE',\\n VALUE_NULL = 'VALUE_NULL',\\n COMMA = 'COMMA',\\n}\\n\\nexport class Token {\\n constructor(\\n public type: TokenType,\\n public source: string,\\n public value?: string | number,\\n public fieldName?: string,\\n public maybeIncomplete: boolean = false\\n ) {}\\n}\\n\",\"import {Token, TokenType} from './types.js'\\nimport {JsonExcerpt} from './JsonExcerpt.js'\\nimport {Flux} from 'monoflux'\\n\\n\\nexport class JsonTokenProcessor {\\n private jsonBuffer: string = ''\\n private highestOffsetParsed: number = -1\\n\\n public static toJsonTokenFlux(\\n dataBufferFlux: Flux<string>\\n ): Flux<JsonExcerpt> {\\n return new JsonTokenProcessor().processDataBuffer(dataBufferFlux)\\n }\\n\\n public processDataBuffer(deltaContentFlux: Flux<string>): Flux<JsonExcerpt> {\\n return deltaContentFlux.flatMap(content => this.getExcerpts(content))\\n }\\n\\n public getExcerpts(source: string): JsonExcerpt[] {\\n this.jsonBuffer += source\\n\\n const excerpts: JsonExcerpt[] = []\\n\\n const jsonParser = new JsonParser(this.jsonBuffer)\\n\\n let token: Token | undefined\\n while ((token = this.nextToken(jsonParser))) {\\n if (jsonParser.currentTokenLocation().getCharOffset() > this.highestOffsetParsed && !token.maybeIncomplete) {\\n excerpts.push({token})\\n this.highestOffsetParsed = jsonParser\\n .currentTokenLocation()\\n .getCharOffset()\\n }\\n }\\n\\n excerpts.push({source})\\n\\n return excerpts\\n }\\n\\n private nextToken(jsonParser: JsonParser): Token | undefined {\\n const result = jsonParser.nextToken()\\n return typeof result !== 'string' ? result : undefined\\n }\\n}\\n\\nclass JsonParser {\\n private position: number = 0\\n private currentTokenType: TokenType | undefined\\n private parentFieldName: string | undefined\\n private currentValue: any = null\\n private context: ContextType[] = []\\n\\n constructor(private readonly content: string) {}\\n\\n nextToken(): Token | 'token-incomplete' | 'string-ended' {\\n const startPosition = this.position\\n\\n if (this.position >= this.content.length) {\\n return 'string-ended'\\n }\\n\\n // Skip whitespace\\n while (\\n this.position < this.content.length &&\\n /\\\\s/.test(this.content[this.position]!)\\n ) {\\n this.position++\\n }\\n\\n if (this.position >= this.content.length) {\\n return 'string-ended'\\n }\\n\\n const source = (position: number) =>\\n this.content.substring(startPosition, position)\\n\\n const char = this.content[this.position]!\\n\\n switch (char) {\\n case '{':\\n this.position++\\n this.currentTokenType = TokenType.START_OBJECT\\n this.pushContext('object')\\n return new Token(\\n this.currentTokenType,\\n source(this.position),\\n undefined,\\n this.parentFieldName,\\n )\\n case '}': {\\n this.position++\\n this.currentTokenType = TokenType.END_OBJECT\\n const token = new Token(this.currentTokenType, source(this.position), undefined, this.parentFieldName)\\n this.parentFieldName = undefined\\n this.popContext('object')\\n if (this.currentContextType === 'field') {\\n this.popContext('field')\\n }\\n return token\\n }\\n case '[':\\n this.position++\\n this.currentTokenType = TokenType.START_ARRAY\\n this.pushContext('array')\\n return new Token(this.currentTokenType, source(this.position), undefined, this.parentFieldName)\\n case ']': {\\n this.position++\\n this.currentTokenType = TokenType.END_ARRAY\\n const token = new Token(this.currentTokenType, source(this.position), undefined, this.parentFieldName)\\n this.parentFieldName = undefined\\n this.popContext('array')\\n if (this.currentContextType === 'field') {\\n this.popContext('field')\\n }\\n return token\\n }\\n case '\\\"':\\n // Check if this is a field name (followed by colon)\\n if (this.currentContextType === 'object') {\\n this.currentTokenType = TokenType.FIELD_NAME\\n\\n let startPos = ++this.position\\n let endPos = this.content.indexOf('\\\"', startPos)\\n while (endPos >= 0 && this.content[endPos - 1] === '\\\\\\\\') {\\n endPos = this.content.indexOf('\\\"', endPos + 1)\\n }\\n if (endPos === -1) {\\n return 'token-incomplete'\\n }\\n const value = this.content.substring(startPos, endPos)\\n endPos++\\n while (endPos < this.content.length && /\\\\s/.test(this.content[endPos]!)) {\\n endPos++\\n }\\n if (endPos === this.content.length) {\\n return 'token-incomplete'\\n }\\n if (this.content[endPos]! !== ':') {\\n throw new Error('Expected token \\\\':\\\\'')\\n }\\n endPos++\\n\\n this.position = endPos\\n const token = new Token(\\n this.currentTokenType,\\n source(this.position),\\n value,\\n undefined\\n )\\n this.parentFieldName = value\\n this.pushContext('field')\\n return token\\n } else {\\n this.currentTokenType = TokenType.VALUE_STRING\\n\\n\\n // Parse string\\n let startPos = ++this.position\\n let endPos = this.content.indexOf('\\\"', startPos)\\n while (endPos > 0 && this.content[endPos - 1] === '\\\\\\\\') {\\n endPos = this.content.indexOf('\\\"', endPos + 1)\\n }\\n\\n if (endPos === -1) {\\n return 'token-incomplete'\\n }\\n\\n const value = this.content.substring(startPos, endPos)\\n this.position = endPos + 1\\n\\n this.currentValue = value\\n const token = new Token(\\n this.currentTokenType,\\n source(this.position),\\n value,\\n this.currentTokenType === TokenType.VALUE_STRING\\n ? this.parentFieldName\\n : undefined\\n )\\n this.parentFieldName = undefined;\\n if (this.currentContextType === 'field') {\\n this.popContext('field')\\n }\\n return token\\n }\\n case 't': {\\n const nextFourChars = this.content.substring(\\n this.position,\\n this.position + 4\\n )\\n if (nextFourChars === 'true') {\\n this.position += 4\\n this.currentTokenType = TokenType.VALUE_TRUE\\n this.currentValue = true\\n if (this.currentContextType === 'field') {\\n this.popContext('field')\\n }\\n return new Token(\\n this.currentTokenType,\\n source(this.position),\\n this.currentValue,\\n this.parentFieldName\\n )\\n } else if (nextFourChars.length < 4) {\\n return 'token-incomplete'\\n }\\n break\\n }\\n case 'f': {\\n const nextFiveChars = this.content.substring(\\n this.position,\\n this.position + 5\\n )\\n if (nextFiveChars === 'false') {\\n this.position += 5\\n this.currentTokenType = TokenType.VALUE_FALSE\\n this.currentValue = false\\n if (this.currentContextType === 'field') {\\n this.popContext('field')\\n }\\n return new Token(\\n this.currentTokenType,\\n source(this.position),\\n this.currentValue,\\n this.parentFieldName\\n )\\n } else if (nextFiveChars.length < 5) {\\n return 'token-incomplete'\\n }\\n break\\n }\\n case 'n': {\\n const nextFourChars = this.content.substring(\\n this.position,\\n this.position + 4\\n )\\n if (nextFourChars === 'null') {\\n this.position += 4\\n this.currentTokenType = TokenType.VALUE_NULL\\n this.currentValue = null\\n if (this.currentContextType === 'field') {\\n this.popContext('field')\\n }\\n return new Token(\\n this.currentTokenType,\\n source(this.position),\\n this.currentValue,\\n this.parentFieldName\\n )\\n } else if (nextFourChars.length < 4) {\\n return 'token-incomplete'\\n }\\n break\\n }\\n case ',': {\\n this.position++\\n this.currentTokenType = TokenType.COMMA\\n return new Token(\\n this.currentTokenType,\\n source(this.position),\\n undefined,\\n undefined,\\n false\\n )\\n }\\n default:\\n if (/[0-9-]/.test(char)) {\\n // Parse number\\n let numStr = ''\\n let hasDecimal = false\\n\\n while (\\n this.position < this.content.length &&\\n (/[0-9]/.test(this.content[this.position]!) ||\\n this.content[this.position] === '-' ||\\n this.content[this.position] === '.' ||\\n this.content[this.position] === 'e' ||\\n this.content[this.position] === 'E' ||\\n this.content[this.position] === '+')\\n ) {\\n if (this.content[this.position] === '.') {\\n hasDecimal = true\\n }\\n numStr += this.content[this.position++]\\n }\\n\\n if (hasDecimal) {\\n this.currentTokenType = TokenType.VALUE_NUMBER_FLOAT\\n this.currentValue = parseFloat(numStr)\\n } else {\\n this.currentTokenType = TokenType.VALUE_NUMBER_INT\\n this.currentValue = parseInt(numStr, 10)\\n }\\n const mayBeIncomplete = this.position >= this.content.length\\n\\n if (this.currentContextType === 'field') {\\n this.popContext('field')\\n }\\n return new Token(\\n this.currentTokenType,\\n source(this.position),\\n this.currentValue,\\n this.parentFieldName,\\n // cannot tell from number itself whether the number token is incomplete\\n mayBeIncomplete\\n )\\n }\\n }\\n\\n throw new JsonParseException('Invalid JSON at position ' + this.position)\\n }\\n\\n currentTokenLocation(): { getCharOffset: () => number } {\\n return {\\n getCharOffset: () => this.position\\n }\\n }\\n\\n private get currentContextType() {\\n return this.context[this.context.length - 1]\\n }\\n\\n private pushContext(contextType: ContextType) {\\n this.context.push(contextType)\\n }\\n\\n private popContext(contextType: ContextType) {\\n if (this.context.length === 0) {\\n throw new Error('Cannot pop context, context empty')\\n }\\n const currentContext = this.currentContextType\\n if (currentContext !== contextType) {\\n throw new Error(`Cannot pop context \\\\`${contextType}\\\\', current context '${currentContext}'`)\\n }\\n this.context.pop()\\n }\\n}\\n\\ntype ContextType = 'object' | 'array' | 'field'\\n\\nclass JsonParseException extends Error {\\n constructor(message: string) {\\n super(message)\\n this.name = 'JsonParseException'\\n }\\n}\\n\",\"import {Token, TokenType} from './types.js'\\nimport {JsonExcerpt} from './JsonExcerpt.js'\\nimport {Flux} from 'monoflux'\\nimport {AnyJson} from '../index.js'\\nimport {nonNullish} from '../util/nonNullish.js'\\n\\ntype MultiMap<K, V> = Map<K, V[]>;\\n\\ninterface CompletetionSubscription {\\n consumer: (value: any) => void;\\n expectedTokenType?: Set<TokenType> | undefined;\\n}\\n\\nexport type ElementType<ArrayType extends AnyJson> =\\n ArrayType extends readonly (infer ElementType)[] ? ElementType : never;\\n\\nexport type PropType<ObjectType extends AnyJson, PropName extends string> =\\n ObjectType extends Record<PropName, infer PropType extends AnyJson> ? PropType : never;\\n\\nexport abstract class StreamedJsonElement<T extends AnyJson> implements Promise<T> {\\n protected readonly receivedJson: string[] = [];\\n private readonly propertyCallbacks: MultiMap<string, (value: StreamedJsonElement<any>) => void> = new Map();\\n private onElementCallbacks: Set<(value: StreamedJsonElement<any>) => void> = new Set();\\n private onCompleteCallbacks: Set<CompletetionSubscription> = new Set();\\n private onEachExcerptCallbacks: Set<(value: JsonExcerpt) => void> = new Set();\\n private currentToken?: Token;\\n private state: State = new Begin();\\n private receivedExcerpts: JsonExcerpt[] = [];\\n\\n public onElement(callback: (value: StreamedJsonElement<ElementType<T>>) => void): this {\\n this.onElementCallbacks.add(callback);\\n return this;\\n }\\n\\n public onProperty<P extends string>(propertyName: P, callback: (element: StreamedJsonElement<PropType<T, P>>) => void): this {\\n if (!this.propertyCallbacks.has(propertyName)) {\\n this.propertyCallbacks.set(propertyName, []);\\n }\\n this.propertyCallbacks.get(propertyName)!.push(callback);\\n return this;\\n }\\n\\n /**\\n * @deprecated Does not work right now because FIELD_NAME\\n * token comes after string value is already streaming\\n */\\n public onJsonStringProperty<P extends string>(propertyName: P, callback: (element :StreamedJsonElement<PropType<T, P>>) => void): this {\\n if (!this.propertyCallbacks.has(propertyName)) {\\n this.propertyCallbacks.set(propertyName, []);\\n }\\n\\n this.propertyCallbacks.get(propertyName)!.push(content => {\\n const processor = new JsonTokenProcessor();\\n let seenFirst = false;\\n const stringBuffer: string[] = [];\\n const jsonElement = new StreamedJsonChildElement<PropType<T, P>>();\\n\\n content.onEachExcerpt(jsonStringExcerpt => {\\n if (jsonStringExcerpt.source !== undefined) {\\n stringBuffer.push(jsonStringExcerpt.source);\\n }\\n const allData = stringBuffer.join('');\\n const excerptWithHoleEscapeTokens = this.endsOnUnevenNumberOfBackslashes(allData)\\n ? allData.substring(0, allData.length - 1)\\n : allData;\\n\\n stringBuffer.length = 0;\\n const unescapedExcerpt = excerptWithHoleEscapeTokens.replace(/\\\\\\\\\\\"/g, '\\\"');\\n const unescapedExcerptWithoutOpeningQuote = seenFirst\\n ? unescapedExcerpt\\n : unescapedExcerpt.substring(1);\\n\\n const isLastOfJsonString = jsonStringExcerpt.token != null;\\n const unescapedExcerptWithoutClosingQuote = isLastOfJsonString\\n ? unescapedExcerptWithoutOpeningQuote.substring(0, unescapedExcerptWithoutOpeningQuote.length - 1)\\n : unescapedExcerptWithoutOpeningQuote;\\n\\n const jsonExcerpts = processor.getExcerpts(unescapedExcerptWithoutClosingQuote);\\n jsonExcerpts.forEach(excerpt => jsonElement.push(excerpt));\\n });\\n\\n callback(jsonElement);\\n });\\n\\n return this;\\n }\\n\\n public onEachExcerpt(callback: (value: JsonExcerpt) => void): this {\\n this.onEachExcerptCallbacks.add(callback);\\n this.receivedExcerpts.forEach(callback);\\n return this;\\n }\\n\\n // Promise methods\\n\\n async then<TResult1 = T, TResult2 = never>(\\n onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined,\\n onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined\\n ): Promise<TResult1 | TResult2> {\\n try {\\n const result = await this.getResponseAsPromise()\\n return nonNullish(onfulfilled)\\n ? await onfulfilled(result)\\n : result as unknown as TResult1\\n } catch (e) {\\n if (nonNullish(onrejected)) {\\n return await onrejected(e)\\n } else {\\n throw e\\n }\\n }\\n }\\n\\n async catch<TResult = never>(\\n onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined\\n ): Promise<T | TResult> {\\n try {\\n return await this.getResponseAsPromise()\\n } catch (e) {\\n if (nonNullish(onrejected)) {\\n return onrejected(e)\\n } else {\\n throw e\\n }\\n }\\n }\\n\\n async finally(onfinally?: (() => void) | null | undefined): Promise<T> {\\n try {\\n return await this.getResponseAsPromise()\\n } finally {\\n onfinally?.()\\n }\\n }\\n\\n get [Symbol.toStringTag](): string {\\n return 'StreamedJsonElement'\\n }\\n\\n\\n // other methods\\n\\n private getResponseAsPromise(): Promise<T> {\\n return new Promise(resolve => {\\n this.onCompleteAs(resolve)\\n })\\n }\\n\\n /**\\n * @param onComplete - a callback that will receive the complete JSON\\n * string for this element once it's done streaming\\n */\\n private onComplete(onComplete: (value: string) => void): void {\\n this._onComplete(this.toAsync(onComplete), undefined);\\n }\\n\\n private _onComplete(onComplete: (value: any) => void, expectedTokenType?: Set<TokenType>): void {\\n this.onCompleteCallbacks.add({\\n consumer: onComplete,\\n expectedTokenType\\n });\\n }\\n\\n public onCompleteAsync(onComplete: (value: string) => Promise<void>): void {\\n this._onComplete(onComplete, undefined);\\n }\\n\\n public onCompleteAs<T>(onComplete: (value: T) => void): void {\\n this.onCompleteAsAsync(this.toAsync(onComplete));\\n }\\n\\n public onCompleteAsAsync<T>(\\n onComplete: (value: T) => Promise<void>\\n ): void {\\n this._onComplete(\\n (jsonStringValue: string) => {\\n const jsonString = jsonStringValue.replace(/,$/, '')\\n const deserializedValue = (() => {\\n try {\\n return JSON.parse(jsonString)\\n } catch (e: any) {\\n e.message = `${e.message}. JSON string was: ${jsonString}`\\n throw e\\n }\\n })()\\n return onComplete(deserializedValue);\\n },\\n undefined\\n );\\n }\\n\\n public onCompleteAsString(onComplete: (value: string) => void): void {\\n this._onComplete(\\n this.toAsync(onComplete),\\n new Set([TokenType.VALUE_STRING, TokenType.VALUE_NULL])\\n );\\n }\\n\\n public onCompleteAsStringAsync(onComplete: (value: string) => Promise<void>): void {\\n this._onComplete(\\n onComplete,\\n new Set([TokenType.VALUE_STRING, TokenType.VALUE_NULL])\\n );\\n }\\n\\n public onCompleteAsInt(onComplete: (value: number) => void): void {\\n this._onComplete(\\n this.toAsync(onComplete),\\n new Set([TokenType.VALUE_NUMBER_INT, TokenType.VALUE_NULL])\\n );\\n }\\n\\n public onCompleteAsIntAsync(onComplete: (value: number) => Promise<void>): void {\\n this._onComplete(\\n onComplete,\\n new Set([TokenType.VALUE_NUMBER_INT, TokenType.VALUE_NULL])\\n );\\n }\\n\\n public onCompleteAsNumber(onComplete: (value: number) => void): void {\\n this._onComplete(\\n this.toAsync(onComplete),\\n new Set([TokenType.VALUE_NUMBER_INT, TokenType.VALUE_NUMBER_FLOAT, TokenType.VALUE_NULL])\\n );\\n }\\n\\n public onCompleteAsNumberAsync(onComplete: (value: number) => Promise<void>): void {\\n this._onComplete(\\n onComplete,\\n new Set([TokenType.VALUE_NUMBER_INT, TokenType.VALUE_NUMBER_FLOAT, TokenType.VALUE_NULL])\\n );\\n }\\n\\n public onCompleteAsBoolean(onComplete: (value: boolean) => void): void {\\n this._onComplete(\\n this.toAsync(onComplete),\\n new Set([TokenType.VALUE_TRUE, TokenType.VALUE_FALSE, TokenType.VALUE_NULL])\\n );\\n }\\n\\n public onCompleteAsBooleanAsync(onComplete: (value: boolean) => Promise<void>): void {\\n this._onComplete(\\n onComplete,\\n new Set([TokenType.VALUE_TRUE, TokenType.VALUE_FALSE, TokenType.VALUE_NULL])\\n );\\n }\\n\\n public whenComplete(): Promise<string> {\\n return new Promise<string>(resolve => {\\n this.onComplete(value => resolve(value));\\n });\\n }\\n\\n public asJsonFlux(): Flux<string> {\\n return Flux.create<string>((push, complete) => {\\n this.onEachExcerpt(excerpt => {\\n if (excerpt.source) {\\n push(excerpt.source);\\n }\\n });\\n this._onComplete(async () => complete());\\n });\\n }\\n\\n public whenCompleteAs<T>(): Promise<T> {\\n return new Promise<T>(resolve => {\\n this.onCompleteAs(resolve);\\n });\\n }\\n\\n public async push(excerpt: JsonExcerpt): Promise<void> {\\n const token = excerpt.token;\\n\\n this.onEachExcerptCallbacks.forEach(callback => callback(excerpt));\\n\\n if (this.isState(InNested)) {\\n return (this.state as InNested).child.push(excerpt);\\n }\\n\\n if (!token) {\\n return;\\n }\\n\\n const tokenType = token.type;\\n this.currentToken = token;\\n\\n if (this.isState(Begin)) {\\n switch (tokenType) {\\n case TokenType.START_OBJECT: {\\n if (this.onElementCallbacks.size > 0) {\\n throw new Error(\\\"registered onElement for object\\\");\\n }\\n this.state = new InObject();\\n this.receivedJson.push(token.source);\\n return;\\n }\\n\\n case TokenType.START_ARRAY: {\\n if (this.propertyCallbacks.size > 0) {\\n throw new Error(\\\"registered onProperty for array\\\");\\n }\\n this.state = new InArray();\\n this.receivedJson.push(token.source);\\n return;\\n }\\n\\n case TokenType.VALUE_STRING:\\n case TokenType.VALUE_NUMBER_INT:\\n case TokenType.VALUE_NUMBER_FLOAT:\\n case TokenType.VALUE_TRUE:\\n case TokenType.VALUE_FALSE:\\n case TokenType.VALUE_NULL:\\n this.receivedJson.push(token.source);\\n return this.end();\\n\\n default:\\n throw new UnexpectedTokenException(token);\\n }\\n } else if (this.isState(InObject)) {\\n switch (tokenType) {\\n case TokenType.FIELD_NAME: {\\n this.receivedJson.push(token.source);\\n return;\\n }\\n\\n case TokenType.END_OBJECT: {\\n this.receivedJson.push(token.source);\\n return this.end();\\n }\\n\\n case TokenType.START_OBJECT:\\n case TokenType.START_ARRAY:\\n case TokenType.VALUE_STRING:\\n case TokenType.VALUE_NUMBER_INT:\\n case TokenType.VALUE_NUMBER_FLOAT:\\n case TokenType.VALUE_TRUE:\\n case TokenType.VALUE_FALSE:\\n case TokenType.VALUE_NULL: {\\n const child = new StreamedJsonChildElement();\\n child.onComplete(resultingJson => {\\n this.receivedJson.push(resultingJson);\\n this.state = new InObject();\\n })\\n this.state = new InPropertyValue(child);\\n this.propertyCallbacks.get(token.fieldName!)\\n ?.forEach(callback => {\\n callback(child)\\n });\\n return child.push(excerpt);\\n }\\n\\n case TokenType.COMMA: {\\n this.receivedJson.push(token.source);\\n return;\\n }\\n\\n default:\\n throw new UnexpectedTokenException(token);\\n }\\n } else if (this.isState(InArray)) {\\n switch (tokenType) {\\n case TokenType.END_ARRAY: {\\n this.receivedJson.push(token.source);\\n return this.end();\\n }\\n\\n case TokenType.START_OBJECT:\\n case TokenType.START_ARRAY:\\n case TokenType.VALUE_STRING:\\n case TokenType.VALUE_NUMBER_INT:\\n case TokenType.VALUE_NUMBER_FLOAT:\\n case TokenType.VALUE_TRUE:\\n case TokenType.VALUE_FALSE:\\n case TokenType.VALUE_NULL: {\\n const child = new StreamedJsonChildElement();\\n child.onComplete(resultingJson => {\\n this.receivedJson.push(resultingJson);\\n this.state = new InArray();\\n })\\n this.onElementCallbacks.forEach(callback => callback(child));\\n this.state = new InArrayElement(child);\\n return child.push(excerpt);\\n }\\n\\n case TokenType.COMMA: {\\n this.receivedJson.push(token.source);\\n return;\\n }\\n\\n default:\\n throw new UnexpectedTokenException(token);\\n }\\n }\\n\\n throw new Error(\\\"Unknown state\\\");\\n }\\n\\n protected async end(): Promise<void> {\\n if (this.currentToken === undefined) {\\n throw new Error('Illegal state')\\n }\\n\\n this.onCompleteCallbacks.forEach(subscription => {\\n const expectedTokenType = subscription.expectedTokenType;\\n const completeValue = (() => {\\n if (expectedTokenType === undefined) {\\n return this.receivedJson.join('');\\n }\\n if (!expectedTokenType.has(this.currentToken!.type)) {\\n throw new Error(`Expected token type ${Array.from(expectedTokenType).join(', ')} but got ${this.currentToken!.type}`);\\n }\\n return this.currentToken!.value\\n })()\\n subscription.consumer(completeValue);\\n });\\n }\\n\\n private isState(stateClass: typeof Begin | typeof InArray | typeof InObject | typeof InNested): boolean {\\n return this.state instanceof stateClass;\\n }\\n\\n private endsOnUnevenNumberOfBackslashes(data: string): boolean {\\n let count = 0;\\n for (let i = data.length - 1; i >= 0; i--) {\\n if (data[i] === '\\\\\\\\') {\\n count++;\\n } else {\\n break;\\n }\\n }\\n return count % 2 === 1;\\n }\\n\\n private toAsync<T>(consumer: (value: T) => void): (value: T) => Promise<void> {\\n return async (value: T) => {\\n consumer(value);\\n };\\n }\\n}\\n\\n// State classes\\nabstract class State {\\n}\\n\\nclass InNested extends State {\\n constructor(public readonly child: StreamedJsonChildElement<AnyJson>) {\\n super();\\n }\\n}\\n\\nclass Begin extends State {\\n}\\n\\nclass InArray extends State {\\n}\\n\\nclass InArrayElement extends InNested {\\n constructor(child: StreamedJsonChildElement<AnyJson>) {\\n super(child);\\n }\\n}\\n\\nclass InObject extends State {\\n}\\n\\nclass InPropertyValue extends InNested {\\n constructor(child: StreamedJsonChildElement<AnyJson>) {\\n super(child);\\n }\\n}\\n\\nclass UnexpectedTokenException extends Error {\\n constructor(token: Token) {\\n super(`Unexpected token: ${token.type}`);\\n this.name = \\\"UnexpectedTokenException\\\";\\n }\\n}\\n\\n// Mock JsonTokenProcessor for onJsonStringProperty\\nclass JsonTokenProcessor {\\n getExcerpts(data: string): JsonExcerpt[] {\\n return [{source: data}];\\n }\\n}\\n\\nexport class StreamedJsonChildElement<T extends AnyJson> extends StreamedJsonElement<T> {\\n constructor() {\\n super();\\n }\\n}\\n\",\"export function nonNullish<T>(value: T | undefined | null): value is T\\n{\\n return value !== undefined && value !== null;\\n}\",\"import {JsonExcerpt} from './JsonExcerpt.js';\\nimport {StreamedJsonElement} from './StreamedJsonElement.js';\\nimport {Flux} from \\\"monoflux\\\";\\nimport {AnyJson} from '../index.js'\\n\\nexport class StreamedJsonRootElement<T extends AnyJson> extends StreamedJsonElement<T> {\\n protected readonly jsonTokenFlux: Flux<JsonExcerpt>\\n constructor(jsonTokenFlux: Flux<JsonExcerpt>) {\\n super();\\n const thiss = this\\n this.jsonTokenFlux = Flux.fromGeneratorFunction(async function* () {\\n let lastTokenExcerpt: JsonExcerpt | undefined = undefined;\\n for await (const excerpt of jsonTokenFlux) {\\n if (excerpt.token !== undefined) {\\n if (lastTokenExcerpt?.token?.maybeIncomplete && lastTokenExcerpt.token.type === excerpt.token.type && !excerpt.token.maybeIncomplete) {\\n await thiss.push(excerpt)\\n }\\n lastTokenExcerpt = excerpt.token;\\n }\\n if (excerpt.token === undefined || !excerpt.token.maybeIncomplete) {\\n await thiss.push(excerpt)\\n }\\n yield excerpt;\\n }\\n if (lastTokenExcerpt?.token?.maybeIncomplete) {\\n await thiss.push(lastTokenExcerpt)\\n }\\n })\\n }\\n\\n override whenComplete(): Promise<string> {\\n return this.jsonTokenFlux\\n .then(() => this.receivedJson.join(''));\\n }\\n\\n override asJsonFlux(): Flux<string> {\\n return this.jsonTokenFlux\\n .map(excerpt => excerpt.source)\\n .filter(source => source !== undefined)\\n }\\n}\\n\",\"import { JsonExcerpt } from './JsonExcerpt.js'\\nimport { StreamedJsonRootElement } from './StreamedJsonRootElement.js'\\nimport {Flux} from \\\"monoflux\\\";\\n\\nexport class StreamedJsonParser {\\n parse(jsonTokenFlux: Flux<JsonExcerpt>): StreamedJsonRootElement<any> {\\n return new StreamedJsonRootElement(jsonTokenFlux)\\n }\\n}\\n\",\"export function parseJsonWithUsefulError(completedJson: string) {\\n try {\\n return JSON.parse(completedJson)\\n } catch (e) {\\n throw new Error(`Failed to parse JSON with error '${(e as Error).message}'. JSON was: ${completedJson}`)\\n }\\n}\",\"import {parseJsonWithUsefulError} from '../util/parseJsonWithUsefulError.js'\\n\\ntype Scope = '{' | '['\\n | '\\\"prop' | '\\\"prop\\\"' | '\\\"prop\\\":'\\n | 'n' | 'nu' | 'nul'\\n | 't' | 'tr' | 'tru'\\n | 'f' | 'fa' | 'fal' | 'fals'\\n | '\\\"value'\\n | 'number.'\\n\\nexport type DeepPartial<T> = T extends object ? {\\n [P in keyof T]?: DeepPartial<T[P]>;\\n} : T;\\n\\nexport function parsePartialJson<T>(partialJson: string): DeepPartial<T> | undefined {\\n if (partialJson.trim() === '') {\\n return undefined\\n }\\n const opened: Scope[] = []\\n let escaped = false\\n const pushScope = (scope: Scope) => opened.push(scope)\\n const popScope = (...expect: Scope[]) => {\\n const lastOpened = opened[opened.length - 1]\\n if (lastOpened === undefined || !expect.includes(lastOpened)) {\\n throw new Error('illegal state')\\n }\\n opened.pop()\\n }\\n const illegalState = () => {\\n return new Error(`Illegal state (json: ${partialJson})`)\\n }\\n for (const char of partialJson) {\\n const scope = opened.length > 0 ? opened[opened.length - 1]! : null\\n let nextEscapedValue = false\\n if (char === '\\\"') {\\n if (scope === null) {\\n pushScope('\\\"value')\\n } else if (scope === '[' || scope === null) {\\n pushScope('\\\"value')\\n } else if (scope === '{') {\\n pushScope('\\\"prop')\\n } else if (scope === '\\\"prop\\\":') {\\n popScope('\\\"prop\\\":')\\n pushScope('\\\"value')\\n } else if (scope === '\\\"prop') {\\n if (!escaped) {\\n popScope('\\\"prop')\\n pushScope('\\\"prop\\\"')\\n }\\n } else if (scope === '\\\"value') {\\n if (!escaped) {\\n popScope('\\\"value')\\n }\\n } else throw illegalState()\\n } else if (char === '[') {\\n if (scope === '[' || scope === null) {\\n pushScope('[')\\n } else if (scope === '\\\"prop\\\":') {\\n popScope('\\\"prop\\\":')\\n pushScope('[')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState()\\n } else if (char === '{') {\\n if (scope === null || scope === '[' || scope === '\\\"prop\\\":') {\\n pushScope('{');\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState();\\n } else if (char === '\\\\\\\\') {\\n if (scope === '\\\"prop' || scope === '\\\"value') {\\n if (!escaped) {\\n nextEscapedValue = true;\\n }\\n } else throw illegalState();\\n } else if (char === ':') {\\n if (scope === '\\\"prop\\\"') {\\n popScope('\\\"prop\\\"');\\n pushScope('\\\"prop\\\":');\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState();\\n } else if (char === 'n') {\\n if (scope === '\\\"prop\\\":') {\\n popScope('\\\"prop\\\":');\\n pushScope('n');\\n } else if (scope === '[' || scope === null) {\\n pushScope('n')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState();\\n } else if (char === 'u') {\\n if (scope === 'n') {\\n popScope('n');\\n pushScope('nu');\\n } else if (scope === 'tr') {\\n popScope('tr');\\n pushScope('tru');\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState();\\n } else if (char === 'l') {\\n if (scope === 'nu') {\\n popScope('nu');\\n pushScope('nul');\\n } else if (scope === 'nul') {\\n popScope('nul');\\n } else if (scope === 'fa') {\\n popScope('fa');\\n pushScope('fal');\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState();\\n } else if (char === 't') {\\n if (scope === '\\\"prop\\\":') {\\n popScope('\\\"prop\\\":');\\n pushScope('t');\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else if (scope === '[' || scope === null) {\\n pushScope('t')\\n } else throw illegalState();\\n } else if (char === 'r') {\\n if (scope === 't') {\\n popScope('t');\\n pushScope('tr');\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState();\\n } else if (char === 'e') {\\n if (scope === 'tru') {\\n popScope('tru');\\n } else if (scope === 'fals') {\\n popScope('fals');\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState();\\n } else if (char === 'f') {\\n if (scope === '\\\"prop\\\":') {\\n popScope('\\\"prop\\\":')\\n pushScope('f')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else if (scope === '[' || scope === null) {\\n pushScope('f')\\n } else throw illegalState()\\n } else if (char === 'a') {\\n if (scope === 'f') {\\n popScope('f')\\n pushScope('fa')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState()\\n } else if (char === 's') {\\n if (scope === 'fal') {\\n popScope('fal')\\n pushScope('fals')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState()\\n } else if (char === '.') {\\n if (scope === '\\\"prop\\\":') {\\n popScope('\\\"prop\\\":')\\n pushScope('number.')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else if (scope === '{') {\\n pushScope('number.')\\n } else if (scope === '[' || scope === null) {\\n pushScope('number.')\\n } else throw illegalState()\\n } else if (char.match(/[0-9]/)) {\\n if (scope === 'number.') {\\n popScope('number.')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else if (scope === '\\\"prop\\\":') {\\n popScope('\\\"prop\\\":')\\n } else if (scope === '{' || scope === '[' || scope === null) {\\n // do nothing\\n } else throw illegalState()\\n } else if (char === '}') {\\n if (scope === '{') {\\n popScope('{')\\n } else if (scope === 'number.') {\\n popScope('number.')\\n popScope('{')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState()\\n } else if (char === ']') {\\n if (scope === '[') {\\n popScope('[')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState()\\n } else if (char === ',') {\\n if (scope === 'number.') {\\n popScope('number.')\\n } else {\\n // do nothing\\n }\\n }\\n escaped = nextEscapedValue\\n }\\n const closeEverything = opened\\n .reverse()\\n .map(opener => {\\n switch (opener) {\\n case '{': return '}'\\n case '[': return ']'\\n case '\\\"prop': return '\\\": null'\\n case '\\\"prop\\\"': return ': null'\\n case '\\\"prop\\\":': return ' null'\\n case 'n': return 'ull'\\n case 'nu': return 'll'\\n case 'nul': return 'l'\\n case 't': return 'rue'\\n case 'tr': return 'ue'\\n case 'tru': return 'e'\\n case 'f': return 'alse'\\n case 'fa': return 'lse'\\n case 'fal': return 'se'\\n case 'fals': return 'e'\\n case '\\\"value': return '\\\"'\\n case 'number.': return '0'\\n default: throw illegalState()\\n }\\n })\\n .join('')\\n const partialJsonWithoutEndingOnEscapeSign = escaped\\n ? partialJson.substring(0, partialJson.length - 1)\\n : partialJson\\n const partialJsonWithoutEndingComma = partialJsonWithoutEndingOnEscapeSign\\n .replace(/( |\\\\n|,)+$/, '')\\n const completedJson = partialJsonWithoutEndingComma + closeEverything\\n return parseJsonWithUsefulError(completedJson)\\n}\",\"export function requireDefined<T>(value: T | undefined): T {\\n if (value === undefined) {\\n throw new Error('Value is undefined');\\n }\\n return value;\\n}\",\"import validate from './validate.js';\\nconst byteToHex = [];\\nfor (let i = 0; i < 256; ++i) {\\n byteToHex.push((i + 0x100).toString(16).slice(1));\\n}\\nexport function unsafeStringify(arr, offset = 0) {\\n return (byteToHex[arr[offset + 0]] +\\n byteToHex[arr[offset + 1]] +\\n byteToHex[arr[offset + 2]] +\\n byteToHex[arr[offset + 3]] +\\n '-' +\\n byteToHex[arr[offset + 4]] +\\n byteToHex[arr[offset + 5]] +\\n '-' +\\n byteToHex[arr[offset + 6]] +\\n byteToHex[arr[offset + 7]] +\\n '-' +\\n byteToHex[arr[offset + 8]] +\\n byteToHex[arr[offset + 9]] +\\n '-' +\\n byteToHex[arr[offset + 10]] +\\n byteToHex[arr[offset + 11]] +\\n byteToHex[arr[offset + 12]] +\\n byteToHex[arr[offset + 13]] +\\n byteToHex[arr[offset + 14]] +\\n byteToHex[arr[offset + 15]]).toLowerCase();\\n}\\nfunction stringify(arr, offset = 0) {\\n const uuid = unsafeStringify(arr, offset);\\n if (!validate(uuid)) {\\n throw TypeError('Stringified UUID is invalid');\\n }\\n return uuid;\\n}\\nexport default stringify;\\n\",\"import { randomFillSync } from 'crypto';\\nconst rnds8Pool = new Uint8Array(256);\\nlet poolPtr = rnds8Pool.length;\\nexport default function rng() {\\n if (poolPtr > rnds8Pool.length - 16) {\\n randomFillSync(rnds8Pool);\\n poolPtr = 0;\\n }\\n return rnds8Pool.slice(poolPtr, (poolPtr += 16));\\n}\\n\",\"import { randomUUID } from 'crypto';\\nexport default { randomUUID };\\n\",\"import native from './native.js';\\nimport rng from './rng.js';\\nimport { unsafeStringify } from './stringify.js';\\nfunction v4(options, buf, offset) {\\n if (native.randomUUID && !buf && !options) {\\n return native.randomUUID();\\n }\\n options = options || {};\\n const rnds = options.random ?? options.rng?.() ?? rng();\\n if (rnds.length < 16) {\\n throw new Error('Random bytes length must be >= 16');\\n }\\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\\n if (buf) {\\n offset = offset || 0;\\n if (offset < 0 || offset + 16 > buf.length) {\\n throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);\\n }\\n for (let i = 0; i < 16; ++i) {\\n buf[offset + i] = rnds[i];\\n }\\n return buf;\\n }\\n return unsafeStringify(rnds);\\n}\\nexport default v4;\\n\",\"import {AnyJson} from '../index.js'\\n\\nexport type Combine<Current, New> = unknown extends Current\\n ? New\\n : (Current & New) extends never\\n ? Current | New\\n : (Current & New)\\n\\n\\ntype Test = {foo: string} extends unknown ? true : false\\n\\ntype Bla = Combine<{foo: string}, {bar: string}>\\n\\ntype Simplify<T> = {\\n [K in keyof T]: Simplify<T[K]>\\n}\\n\\nexport type AssertTypeOpts = {\\n ignoreUnknownProps?: boolean\\n logValueIfWrong?: boolean\\n errorMessage?: string\\n juggleBetweenNullAndUndefined?: boolean\\n}\\n\\ntype Problem = {\\n path: string\\n expectedType?: Type[]\\n expectedProp?: string\\n value: unknown\\n unknownProp?: string\\n}\\n\\ntype Juggle = {value: unknown}\\n\\ntype UnionTypeConformity = {types: Type[], value: unknown, problems: Problem[], juggleTo?: Juggle}\\n\\ntype TypeConformity = {type: Type, value: unknown, problems: Problem[], juggleTo?: Juggle}\\n\\nclass ComplexTypeError extends Error {\\n public readonly data: any\\n public readonly httpStatus = 400\\n constructor(problems: Problem[], message?: string) {\\n const data = problems\\n .map(problem => {\\n if (problem.expectedProp) {\\n return {\\n expectedProp: (problem.path + '.').replace(/^root\\\\./, '') + problem.expectedProp\\n }\\n } else if (problem.expectedType) {\\n return {\\n expectedType: problem.expectedType.map(typeToString).join(' | '),\\n path: problem.path,\\n insteadGot: problem.value,\\n }\\n } else if (problem.unknownProp) {\\n return {\\n unknownProp: (problem.path + '.').replace(/^root\\\\./, '') + problem.unknownProp\\n }\\n } else {\\n throw new Error('illegal state')\\n }\\n })\\n super(message ?? `Value is of the wrong format: ${JSON.stringify(data, null, 2)}`)\\n this.data = data\\n }\\n}\\n\\n/**\\n * Way to assert the shape of a type both in runtime and in the\\n * type system.\\n *\\n * Usage example:\\n *\\n * ```typescript\\n * const inputValue = ['foo', 'bar'] as unknown\\n *\\n * assert(\\n * inputValue,\\n * t => t\\n * .canBeArray(t => t\\n * .canBeObject(t => t\\n * .canHaveString('foo')\\n * .canHaveString('bar')\\n * )\\n * )\\n * )\\n *\\n * let safeInputvalue = inputValue\\n *\\n * safeInputvalue = [{}] // typescript disapproves\\n * safeInputvalue = [{foo: 'bla', bar: 'bla'}] // typescript approves\\n * ```\\n */\\nexport function specType(\\n value: unknown,\\n): EmptyTypeSpec<unknown> {\\n return new EmptyTypeSpec<unknown>([], value)\\n}\\n\\nfunction conformsPerfectly(typeConformities: TypeConformity[]) {\\n return typeConformities.some(evaluation => evaluation.problems.length === 0 && evaluation.juggleTo === undefined)\\n}\\n\\nfunction juggleThatWouldMakeValueConform(evaluations: TypeConformity[]) {\\n const typeConformitiesThatPassWithJuggle = evaluations.filter(e => e.problems.length === 0 && e.juggleTo !== undefined)\\n if (typeConformitiesThatPassWithJuggle.length > 1) {\\n throw new Error('Illegal State')\\n }\\n return typeConformitiesThatPassWithJuggle[0]?.juggleTo\\n}\\n\\nfunction checkIsOneOf(value: unknown, types: Type[], path: string, opts: AssertTypeOpts): UnionTypeConformity {\\n const evaluations = types\\n .map(type => checkIs(value, type, path, opts))\\n if (conformsPerfectly(evaluations)) {\\n return {types, value, problems: []}\\n }\\n const juggleTo = juggleThatWouldMakeValueConform(evaluations)\\n if (juggleTo !== undefined) {\\n return {types, value, problems: [], juggleTo}\\n }\\n const typeProblemsOnThisPath = evaluations.flatMap(\\n evaluation => evaluation.problems\\n .filter(t => t.expectedType !== undefined && t.path === path)\\n )\\n if (typeProblemsOnThisPath.length > 0) {\\n return {\\n types,\\n value,\\n problems: [{\\n expectedType: typeProblemsOnThisPath\\n .flatMap(problem => problem.expectedType!),\\n path,\\n value\\n }],\\n }\\n }\\n return {\\n types,\\n value,\\n problems: evaluations.flatMap(list => list.problems)\\n }\\n}\\n\\nfunction checkIs(value: unknown, type: Type, path: string, opts: AssertTypeOpts): TypeConformity {\\n const {\\n ignoreUnknownProps = true,\\n juggleBetweenNullAndUndefined = false,\\n } = opts\\n const {\\n problems = [],\\n juggleTo,\\n } = ((): {problems?: Problem[], juggleTo?: Juggle} => {\\n switch (type.type) {\\n case \\\"array\\\": {\\n if (!Array.isArray(value)) {\\n return {problems: [{expectedType: [type], path, value}]}\\n }\\n if (value.length === 0) {\\n return {}\\n }\\n const elementConformities = value\\n .map(\\n element => checkIsOneOf(element, type.elementType, path + '[..]', opts)\\n )\\n const juggleTo = (() => {\\n if (elementConformities.filter(c => c.juggleTo).length === 0) {\\n return undefined\\n }\\n return {\\n value: elementConformities.map(\\n c => c.juggleTo === undefined ? c.value : c.juggleTo.value\\n )\\n }\\n })()\\n const problems = elementConformities.flatMap(c => c.problems)\\n return {problems, juggleTo}\\n }\\n case \\\"boolean\\\": {\\n if (typeof value !== 'boolean') {\\n return {problems: [{expectedType: [type], path, value}]}\\n }\\n return {}\\n }\\n case \\\"undefined\\\": {\\n if (value === undefined) {\\n return {}\\n }\\n if (juggleBetweenNullAndUndefined && value === null) {\\n return {juggleTo: {value: undefined}}\\n }\\n return {problems: [{expectedType: [type], path, value}]}\\n }\\n case \\\"object\\\": {\\n if (typeof value !== 'object' || value === null) {\\n return {problems: [{expectedType: [type], path, value}]}\\n }\\n const problems: Problem[] = []\\n const juggles: {key: string, juggleTo: unknown}[] = []\\n for (const key in type.props) {\\n const prop = type.props[key]!\\n const typeConformity = checkIsOneOf(\\n key in value\\n ? value[key as keyof typeof value]\\n : undefined,\\n prop.optional\\n ? [...prop.type, {type: 'undefined'}]\\n : prop.type,\\n path + `.${key}`,\\n opts\\n )\\n if (typeConformity.juggleTo !== undefined) {\\n juggles.push({key, juggleTo: typeConformity.juggleTo.value})\\n }\\n problems.push(...typeConformity.problems)\\n }\\n if (!ignoreUnknownProps) {\\n for (const key in value) {\\n if (!(key in type.props)) {\\n problems.push({unknownProp: key, path, value})\\n }\\n }\\n }\\n return {\\n problems,\\n juggleTo: (() => {\\n if (juggles.length === 0) {\\n return undefined\\n }\\n const newValue = {...value}\\n for (const juggle of juggles) {\\n (newValue as any)[juggle.key] = juggle.juggleTo\\n }\\n return {value: newValue}\\n })()\\n }\\n }\\n case \\\"string\\\": {\\n return {\\n problems: typeof value === 'string'\\n ? []\\n : [{expectedType: [type], path, value}],\\n }\\n }\\n case \\\"null\\\": {\\n if (value === null) {\\n return {}\\n }\\n if (juggleBetweenNullAndUndefined && value === undefined) {\\n return {juggleTo: {value: null}}\\n }\\n return {problems: [{expectedType: [type], path, value}]}\\n }\\n case \\\"number\\\": {\\n return {\\n problems: typeof value === 'number'\\n ? []\\n : [{expectedType: [type], path, value}],\\n }\\n }\\n case 'constant': {\\n return {\\n problems: value === type.value\\n ? []\\n : [{expectedType: [type], path, value}],\\n }\\n }\\n }\\n })()\\n return {type, value, problems, juggleTo}\\n}\\n\\nexport abstract class TypeSpec<T> {\\n constructor(\\n protected readonly type: Type[],\\n protected readonly value: unknown,\\n protected readonly _: T = undefined as any// type holder\\n ) {}\\n}\\n\\nexport class EmptyTypeSpec<T> extends TypeSpec<T> {\\n array<T_arr = unknown>(element: (arg: EmptyTypeSpec<unknown>) => TypeSpec<T_arr>) {\\n const elementSpec = element(new EmptyTypeSpec<unknown>([], this.value))\\n const arraySpec = new FullTypeSpec<unknown>(\\n [{type: 'array', elementType: elementSpec['type']}],\\n this.value\\n )\\n return new FullTypeSpec<Combine<T, T_arr[]>>([...this.type, ...arraySpec['type']], this.value)\\n }\\n\\n object<T_obj extends {}>(properties: (arg: TypeMemberSpec<{}>) => TypeMemberSpec<T_obj>) {\\n const objectSpec = properties(new TypeMemberSpec<{}>([{type: 'object', props: {}}], this.value))\\n return new FullTypeSpec<Combine<T, T_obj>>([...this.type, ...objectSpec['type']], this.value)\\n }\\n\\n string() {\\n return new FullTypeSpec<Combine<T, string>>([...this.type, {type: 'string'}], this.value)\\n }\\n\\n number() {\\n return new FullTypeSpec<Combine<T, number>>([...this.type, {type: 'number'}], this.value)\\n }\\n\\n boolean() {\\n return new FullTypeSpec<Combine<T, boolean>>([...this.type, {type: 'boolean'}], this.value)\\n }\\n\\n constant<Value extends (string | number | boolean)>(value: Value, ...otherValues: Value[]) {\\n return new FullPropTypeSpec<Combine<T, Value>>(\\n [\\n ...this.type,\\n {type: 'constant', value},\\n ...(otherValues ?? []).map(value => ({type: 'constant' as const, value}))\\n ],\\n this.value\\n )\\n }\\n\\n null() {\\n return new FullTypeSpec<Combine<T, null>>([...this.type, {type: 'null'}], this.value)\\n }\\n\\n undefined() {\\n return new FullTypeSpec<Combine<T, undefined>>([...this.type, {type: 'undefined'}], this.value)\\n }\\n\\n any() {\\n return new FullTypeSpec<Combine<T, AnyJson>>([], this.value)\\n }\\n}\\n\\nexport class FullTypeSpec<T> extends TypeSpec<T> {\\n orArray<T_arr = unknown>(element: (arg: TypeSpec<unknown>) => TypeSpec<T_arr>) {\\n const elementSpec = element(new FullTypeSpec<unknown>([], this.value))\\n const arraySpec = new FullTypeSpec<unknown>(\\n [{type: 'array', elementType: elementSpec['type']}],\\n this.value\\n )\\n return new FullTypeSpec<Combine<T, T_arr[]>>([...this.type, ...arraySpec.type], this.value)\\n }\\n\\n orObject<T_obj extends {}>(properties: (arg: TypeMemberSpec<{}>) => TypeMemberSpec<T_obj>) {\\n const objectSpec = properties(new TypeMemberSpec<{}>([{type: 'object', props: {}}], this.value))\\n return new FullTypeSpec<Combine<T, T_obj>>([...this.type, ...objectSpec['type']], this.value)\\n }\\n\\n orString() {\\n return new FullTypeSpec<Combine<T, string>>([...this.type, {type: 'string'}], this.value)\\n }\\n\\n orNumber() {\\n return new FullTypeSpec<Combine<T, number>>([...this.type, {type: 'number'}], this.value)\\n }\\n\\n orBoolean() {\\n return new FullTypeSpec<Combine<T, boolean>>([...this.type, {type: 'boolean'}], this.value)\\n }\\n\\n orConstant<Value extends (string | number | boolean)>(value: Value, ...otherValues: Value[]) {\\n return new FullPropTypeSpec<Combine<T, Value>>(\\n [\\n ...this.type,\\n {type: 'constant', value},\\n ...(otherValues ?? []).map(value => ({type: 'constant' as const, value}))\\n ],\\n this.value\\n )\\n }\\n\\n orNull() {\\n return new FullTypeSpec<Combine<T, null>>([...this.type, {type: 'null'}], this.value)\\n }\\n\\n orUndefined() {\\n return new FullTypeSpec<Combine<T, undefined>>([...this.type, {type: 'undefined'}], this.value)\\n }\\n}\\n\\nexport class TypeMemberSpec<T> {\\n constructor(\\n protected readonly type: Type[],\\n private readonly value: unknown\\n ) {}\\n\\n mayHave<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: EmptyPropTypeSpec<unknown>) => PropTypeSpec<T_prop>,\\n hint?: string,\\n ): TypeMemberSpec<Combine<T, Partial<Record<Key, T_prop>>>> {\\n return this.has(propertyName, assertTypeOfProperty, true, hint)\\n }\\n\\n canHaveString<Key extends string>(propertyName: Key, hint?: string): TypeMemberSpec<Combine<T, Partial<Record<Key, string>>>> {\\n return this.mayHave(propertyName, type => type.string(), hint)\\n }\\n\\n canHaveNumber<Key extends string>(propertyName: Key, hint?: string): TypeMemberSpec<Combine<T, Partial<Record<Key, number>>>> {\\n return this.mayHave(propertyName, type => type.number(), hint)\\n }\\n\\n canHaveBoolean<Key extends string>(propertyName: Key, hint?: string): TypeMemberSpec<Combine<T, Partial<Record<Key, boolean>>>> {\\n return this.mayHave(propertyName, type => type.boolean(), hint)\\n }\\n\\n canHaveConstant<Key extends string, Value extends (string | number | boolean)>(\\n propertyName: Key,\\n [firstConstant, ...otherConstants]: [Value, ...Value[]],\\n hint?: string\\n ): TypeMemberSpec<Combine<T, Partial<Record<Key, Value>>>> {\\n return this.mayHave(\\n propertyName,\\n type => type.constant(firstConstant, ...otherConstants),\\n hint,\\n )\\n }\\n\\n has<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: EmptyPropTypeSpec<unknown>) => PropTypeSpec<T_prop>,\\n optional: false,\\n comment?: string,\\n ): TypeMemberSpec<Combine<T, Record<Key, T_prop>>>\\n has<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: EmptyPropTypeSpec<unknown>) => PropTypeSpec<T_prop>,\\n comment?: string,\\n ): TypeMemberSpec<Combine<T, Record<Key, T_prop>>>\\n has<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: EmptyPropTypeSpec<unknown>) => PropTypeSpec<T_prop>,\\n optional?: boolean,\\n comment?: string,\\n ): TypeMemberSpec<Combine<T, Partial<Record<Key, T_prop>>>>\\n has<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: EmptyPropTypeSpec<unknown>) => PropTypeSpec<T_prop>,\\n arg3: boolean | string = false,\\n arg4?: string,\\n ): TypeMemberSpec<Combine<T, Record<Key, T_prop> | Partial<Record<Key, T_prop>>>> {\\n const {\\n optional,\\n comment,\\n }: {optional: boolean, comment: string | undefined} = (() => {\\n if (typeof arg3 === 'string') {\\n return {\\n optional: false,\\n comment: arg3,\\n }\\n } else {\\n return {\\n optional: arg3,\\n comment: arg4,\\n }\\n }\\n })()\\n const old = this.type.length === 1\\n ? this.type[0]!\\n : undefined\\n if (old === undefined || old.type !== 'object') {\\n throw new Error('illegal state')\\n }\\n const propertyTypeSpec = assertTypeOfProperty(new EmptyPropTypeSpec([], this.value))\\n const propertyType = propertyTypeSpec['type']\\n const commentsFromPropTypeSpec = propertyTypeSpec['_comments']\\n return new TypeMemberSpec<Combine<T, Record<Key, T_prop>>>([{\\n ...old,\\n props: {\\n ...old.props,\\n [propertyName]: {\\n optional,\\n type: propertyType,\\n comment: (() => {\\n const comments = [\\n ...commentsFromPropTypeSpec,\\n ...(comment !== undefined ? [comment] : []),\\n ]\\n return comments.length > 0\\n ? comments.join('. ')\\n : undefined\\n })(),\\n }\\n }\\n }], this.value)\\n }\\n\\n hasString<Key extends string>(propertyName: Key, comment?: string): TypeMemberSpec<Combine<T, Record<Key, string>>> {\\n return this.has(\\n propertyName,\\n type => type.string(),\\n false,\\n comment,\\n )\\n }\\n\\n hasNumber<Key extends string>(propertyName: Key, comment?: string): TypeMemberSpec<Combine<T, Record<Key, number>>> {\\n return this.has(\\n propertyName,\\n type => type.number(),\\n false,\\n comment,\\n )\\n }\\n\\n hasBoolean<Key extends string>(propertyName: Key, comment?: string): TypeMemberSpec<Combine<T, Record<Key, boolean>>> {\\n return this.has(\\n propertyName,\\n type => type.boolean(),\\n false,\\n comment,\\n )\\n }\\n\\n hasConstant<Key extends string, Value extends (string | number | boolean)>(propertyName: Key, ...constants: [Value, ...Value[]]): TypeMemberSpec<Combine<T, Record<Key, Value>>>\\n hasConstant<Key extends string, Value extends (string | number | boolean)>(propertyName: Key, [firstConstant, ...otherConstants]: [Value, ...Value[]], comment?: string): TypeMemberSpec<Combine<T, Record<Key, Value>>>\\n hasConstant<Key extends string, Value extends (string | number | boolean)>(\\n propertyName: Key,\\n arg2: Value | [Value, ...Value[]],\\n arg3?: Value | string,\\n ...otherArgs: Value[]\\n ): TypeMemberSpec<Combine<T, Record<Key, Value>>> {\\n const {\\n constants,\\n comment,\\n }: {constants: [Value, ...Value[]], comment?: string} = (() => {\\n if (Array.isArray(arg2)) {\\n return {\\n constants: arg2,\\n comment: arg3 as string | undefined,\\n }\\n } else {\\n return {\\n constants: [\\n arg2,\\n ...(arg3 !== undefined ? [arg3 as Value] : []),\\n ...otherArgs\\n ],\\n comment: undefined,\\n }\\n }\\n })()\\n return this.has(\\n propertyName,\\n type => type.constant(...constants),\\n false,\\n comment,\\n )\\n }\\n}\\n\\nexport abstract class PropTypeSpec<T> extends TypeSpec<T> {\\n constructor(\\n type: Type[],\\n value: unknown,\\n private _comments: string[] = [],\\n ) {\\n super(type, value)\\n }\\n\\n /**\\n * Give a comment to the LLM about this property\\n */\\n withComment(message: string) {\\n return new FullPropTypeSpec<Combine<T, string>>(this.type, this.value, [...this._comments, message])\\n }\\n}\\n\\nexport class EmptyPropTypeSpec<T> extends PropTypeSpec<T> {\\n array<T_arr = unknown>(element: (arg: EmptyTypeSpec<unknown>) => TypeSpec<T_arr>) {\\n const elementSpec = element(new EmptyTypeSpec<unknown>([], this.value))\\n const arraySpec = new FullTypeSpec<unknown>(\\n [{type: 'array', elementType: elementSpec['type']}],\\n this.value\\n )\\n return new FullPropTypeSpec<Combine<T, T_arr[]>>([...this.type, ...arraySpec['type']], this.value)\\n }\\n\\n object<T_obj extends {}>(properties: (arg: TypeMemberSpec<{}>) => TypeMemberSpec<T_obj>) {\\n const objectSpec = properties(new TypeMemberSpec<{}>([{type: 'object', props: {}}], this.value))\\n return new FullPropTypeSpec<Combine<T, T_obj>>([...this.type, ...objectSpec['type']], this.value)\\n }\\n\\n string() {\\n return new FullPropTypeSpec<Combine<T, string>>([...this.type, {type: 'string'}], this.value)\\n }\\n\\n number() {\\n return new FullPropTypeSpec<Combine<T, number>>([...this.type, {type: 'number'}], this.value)\\n }\\n\\n boolean() {\\n return new FullPropTypeSpec<Combine<T, boolean>>([...this.type, {type: 'boolean'}], this.value)\\n }\\n\\n constant<Value extends (string | number | boolean)>(...values: [Value, ...Value[]]) {\\n return new FullPropTypeSpec<Combine<T, Value>>(\\n [\\n ...this.type,\\n ...values.map(value => ({type: 'constant' as const, value}))\\n ],\\n this.value\\n )\\n }\\n\\n null() {\\n return new FullPropTypeSpec<Combine<T, null>>([...this.type, {type: 'null'}], this.value)\\n }\\n\\n undefined() {\\n return new FullPropTypeSpec<Combine<T, undefined>>([...this.type, {type: 'undefined'}], this.value)\\n }\\n}\\n\\nexport class FullPropTypeSpec<T> extends PropTypeSpec<T> {\\n orArray<T_arr = unknown>(element: (arg: TypeSpec<unknown>) => TypeSpec<T_arr>) {\\n const elementSpec = element(new FullTypeSpec<unknown>([], this.value))\\n const arraySpec = new FullTypeSpec<unknown>(\\n [{type: 'array', elementType: elementSpec['type']}],\\n this.value\\n )\\n return new FullPropTypeSpec<Combine<T, T_arr[]>>([...this.type, ...arraySpec['type']], this.value)\\n }\\n\\n orObject<T_obj extends {}>(properties: (arg: TypeMemberSpec<{}>) => TypeMemberSpec<T_obj>) {\\n const objectSpec = properties(new TypeMemberSpec<{}>([{type: 'object', props: {}}], this.value))\\n return new FullPropTypeSpec<Combine<T, T_obj>>([...this.type, ...objectSpec['type']], this.value)\\n }\\n\\n orString() {\\n return new FullPropTypeSpec<Combine<T, string>>([...this.type, {type: 'string'}], this.value)\\n }\\n\\n orNumber() {\\n return new FullPropTypeSpec<Combine<T, number>>([...this.type, {type: 'number'}], this.value)\\n }\\n\\n orBoolean() {\\n return new FullPropTypeSpec<Combine<T, boolean>>([...this.type, {type: 'boolean'}], this.value)\\n }\\n\\n orConstant<Value extends (string | number | boolean)>(...values: [Value, ...Value[]]) {\\n return new FullPropTypeSpec<Combine<T, Value>>(\\n [\\n ...this.type,\\n ...values.map(value => ({type: 'constant' as const, value}))\\n ],\\n this.value\\n )\\n }\\n\\n orNull() {\\n return new FullPropTypeSpec<Combine<T, null>>([...this.type, {type: 'null'}], this.value)\\n }\\n\\n orUndefined() {\\n return new FullPropTypeSpec<Combine<T, undefined>>([...this.type, {type: 'undefined'}], this.value)\\n }\\n}\\n\\nexport function assertType<T>(\\n value: unknown,\\n typeSpec: TypeSpec<T>,\\n opts: AssertTypeOpts = {}\\n): T {\\n const {problems, juggleTo} = checkIsOneOf(value, typeSpec['type'], 'root', opts)\\n if (problems.length > 0) {\\n throw new ComplexTypeError(problems, opts.errorMessage)\\n }\\n return juggleTo !== undefined\\n ? juggleTo.value as T\\n : value as T\\n}\\n\\nexport function describeType(typeSpec: TypeSpec<any>): string {\\n return describe(typeSpec['type'])\\n}\\n\\nexport function describe(type: Type[] | Type, indentLevel = 0): string {\\n if (Array.isArray(type)) {\\n return type.map(t => describe(t, indentLevel)).join(' | ')\\n }\\n switch (type.type) {\\n case \\\"array\\\": {\\n return `${describe(type.elementType, indentLevel)}[]`\\n }\\n case \\\"boolean\\\": {\\n return 'boolean'\\n }\\n case \\\"undefined\\\": {\\n return 'undefined'\\n }\\n case \\\"object\\\": {\\n const keys = Object.keys(type.props)\\n return `{\\\\n`\\n +\\n keys.map((key, i) => {\\n const propSpec = type.props[key]!\\n const value = describe(\\n propSpec.type,\\n indentLevel + 1\\n )\\n const comma = i < keys.length - 1 ? ',' : ''\\n const comment = propSpec.comment !== undefined ? ` // ${propSpec.comment}` : ''\\n return propSpec.optional\\n ? `${indent(indentLevel + 1)}${key}?: ${value}${comma}${comment}\\\\n`\\n : `${indent(indentLevel + 1)}${key}: ${value}${comma}${comment}\\\\n`\\n }).join('')\\n + `${indent(indentLevel)}}`\\n }\\n case \\\"string\\\": {\\n return 'string'\\n }\\n case \\\"null\\\": {\\n return 'null'\\n }\\n case \\\"number\\\": {\\n return 'number'\\n }\\n case 'constant': {\\n return `\\\"${type.value}\\\"`\\n }\\n }\\n}\\n\\nfunction indent(depth: number) {\\n let indent = ''\\n for (let i = 0; i < depth; i++) {\\n indent += ' '\\n }\\n return indent\\n}\\n\\nexport type TypeType = 'undefined' | 'null' | 'boolean' | 'string' | 'number' | 'object' | 'array' | 'constant'\\n\\nexport type BaseType<TT extends TypeType> = {\\n type: TT\\n}\\n\\nexport type UndefinedType = BaseType<'undefined'>\\nexport type NullType = BaseType<'null'>\\nexport type BooleanType = BaseType<'boolean'>\\nexport type StringType = BaseType<'string'>\\nexport type NumberType = BaseType<'number'>\\nexport type ObjectType = BaseType<'object'> & {\\n props: Record<string, {\\n optional: boolean\\n type: Type[]\\n comment: string | undefined\\n }>\\n}\\nexport type ArrayType = BaseType<'array'> & {\\n elementType: Type[]\\n}\\nexport type ConstantType<Value extends (string | number | boolean)> = BaseType<'constant'> & {\\n value: Value\\n}\\n\\nexport type Type = UndefinedType | NullType | BooleanType | StringType | NumberType | ObjectType | ArrayType | ConstantType<any>\\n\\nfunction typeToString(type: Type) {\\n return type.type === 'constant'\\n ? `'${type.value}'`\\n : type.type\\n}\\n\",\"import {OpenaiImageModelId} from './OpenaiImageModelId.js'\\n\\ntype OpenAIImageResponse = {\\n data: Array<{\\n b64_json?: string\\n url?: string\\n revised_prompt?: string\\n }>\\n}\\n\\nexport async function promptOpenaiImageGen(\\n apiKey: string,\\n prompt: string,\\n model: OpenaiImageModelId = 'gpt-image-1',\\n size?: ImageSize,\\n) {\\n const response = await fetch('https://api.openai.com/v1/images/generations', {\\n method: 'POST',\\n headers: {\\n 'Content-Type': 'application/json',\\n 'Authorization': `Bearer ${apiKey}`\\n },\\n body: JSON.stringify({\\n model,\\n prompt,\\n size,\\n })\\n })\\n\\n if (!response.ok) {\\n const errorData = await response.json() as Record<string, unknown>\\n throw new Error(`OpenAI API error: ${response.status} ${JSON.stringify(errorData)}`)\\n }\\n\\n const result = await response.json() as OpenAIImageResponse\\n \\n // Ensure we have a valid response structure\\n if (!result.data?.[0]?.b64_json) {\\n throw new Error('Invalid response structure from OpenAI API')\\n }\\n \\n const image_base64 = result.data[0].b64_json\\n \\n // Handle both Node.js and browser environments\\n return Uint8Array.from(atob(image_base64), c => c.charCodeAt(0)) as any\\n}\\n\\nexport type ImageSize =\\n | '1024x1024'\\n | '1536x1024'\\n | '1024x1536'\\n | '256x256'\\n | '512x512'\\n | '1792x1024'\\n | '1024x1792'\",\"export const AiModel = {\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.0015/1K tokens | \\\\$0.0020/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-3.5-turbo)\\n */\\n gpt_3_5_turbo: 'gpt-3.5-turbo',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.0005/1K tokens | \\\\$0.0015/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-3.5-turbo-0125)\\n */\\n gpt_3_5_turbo_0125: 'gpt-3.5-turbo-0125',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.0010/1K tokens | \\\\$0.0020/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-3.5-turbo-1106)\\n */\\n gpt_3_5_turbo_1106: 'gpt-3.5-turbo-1106',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.003/1K tokens | \\\\$0.004/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-3.5-turbo-16k)\\n */\\n gpt_3_5_turbo_16k: 'gpt-3.5-turbo-16k',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.0015/1K tokens | \\\\$0.0020/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-3.5-turbo-instruct)\\n */\\n gpt_3_5_turbo_instruct: 'gpt-3.5-turbo-instruct',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.0015/1K tokens | \\\\$0.0020/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-3.5-turbo-instruct-0914)\\n */\\n gpt_3_5_turbo_instruct_0914: 'gpt-3.5-turbo-instruct-0914',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.03/1K tokens | \\\\$0.06/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4)\\n */\\n gpt_4: 'gpt-4',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.01/1K tokens | \\\\$0.03/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4-0125-preview)\\n */\\n gpt_4_0125_preview: 'gpt-4-0125-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.03/1K tokens | \\\\$0.06/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4-0613)\\n */\\n gpt_4_0613: 'gpt-4-0613',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.01/1K tokens | \\\\$0.03/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4-1106-preview)\\n */\\n gpt_4_1106_preview: 'gpt-4-1106-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.01/1K tokens | \\\\$0.03/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4-turbo)\\n */\\n gpt_4_turbo: 'gpt-4-turbo',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.01/1K tokens | \\\\$0.03/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4-turbo-2024-04-09)\\n */\\n gpt_4_turbo_2024_04_09: 'gpt-4-turbo-2024-04-09',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.01/1K tokens | \\\\$0.03/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4-turbo-preview)\\n */\\n gpt_4_turbo_preview: 'gpt-4-turbo-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4.1)\\n */\\n gpt_4_1: 'gpt-4.1',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4.1-2025-04-14)\\n */\\n gpt_4_1_2025_04_14: 'gpt-4.1-2025-04-14',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4.1-mini)\\n */\\n gpt_4_1_mini: 'gpt-4.1-mini',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4.1-mini-2025-04-14)\\n */\\n gpt_4_1_mini_2025_04_14: 'gpt-4.1-mini-2025-04-14',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○ | Low |\\n * | Speed | ○○○○○ | Very Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4.1-nano)\\n */\\n gpt_4_1_nano: 'gpt-4.1-nano',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○ | Low |\\n * | Speed | ○○○○○ | Very Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4.1-nano-2025-04-14)\\n */\\n gpt_4_1_nano_2025_04_14: 'gpt-4.1-nano-2025-04-14',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.005/1K tokens | \\\\$0.015/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o)\\n */\\n gpt_4o: 'gpt-4o',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.005/1K tokens | \\\\$0.015/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-2024-05-13)\\n */\\n gpt_4o_2024_05_13: 'gpt-4o-2024-05-13',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.005/1K tokens | \\\\$0.015/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-2024-08-06)\\n */\\n gpt_4o_2024_08_06: 'gpt-4o-2024-08-06',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.005/1K tokens | \\\\$0.015/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-2024-11-20)\\n */\\n gpt_4o_2024_11_20: 'gpt-4o-2024-11-20',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-audio-preview)\\n */\\n gpt_4o_audio_preview: 'gpt-4o-audio-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-audio-preview-2024-10-01)\\n */\\n gpt_4o_audio_preview_2024_10_01: 'gpt-4o-audio-preview-2024-10-01',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-audio-preview-2024-12-17)\\n */\\n gpt_4o_audio_preview_2024_12_17: 'gpt-4o-audio-preview-2024-12-17',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-audio-preview-2025-06-03)\\n */\\n gpt_4o_audio_preview_2025_06_03: 'gpt-4o-audio-preview-2025-06-03',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.150/1M tokens | \\\\$0.600/1M tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini)\\n */\\n gpt_4o_mini: 'gpt-4o-mini',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.150/1M tokens | \\\\$0.600/1M tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-2024-07-18)\\n */\\n gpt_4o_mini_2024_07_18: 'gpt-4o-mini-2024-07-18',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-audio-preview)\\n */\\n gpt_4o_mini_audio_preview: 'gpt-4o-mini-audio-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-audio-preview-2024-12-17)\\n */\\n gpt_4o_mini_audio_preview_2024_12_17: 'gpt-4o-mini-audio-preview-2024-12-17',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-realtime-preview)\\n */\\n gpt_4o_mini_realtime_preview: 'gpt-4o-mini-realtime-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-realtime-preview-2024-12-17)\\n */\\n gpt_4o_mini_realtime_preview_2024_12_17: 'gpt-4o-mini-realtime-preview-2024-12-17',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-search-preview)\\n */\\n gpt_4o_mini_search_preview: 'gpt-4o-mini-search-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-search-preview-2025-03-11)\\n */\\n gpt_4o_mini_search_preview_2025_03_11: 'gpt-4o-mini-search-preview-2025-03-11',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Audio | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-transcribe)\\n */\\n gpt_4o_mini_transcribe: 'gpt-4o-mini-transcribe',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-tts)\\n */\\n gpt_4o_mini_tts: 'gpt-4o-mini-tts',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-realtime-preview)\\n */\\n gpt_4o_realtime_preview: 'gpt-4o-realtime-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-realtime-preview-2024-10-01)\\n */\\n gpt_4o_realtime_preview_2024_10_01: 'gpt-4o-realtime-preview-2024-10-01',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-realtime-preview-2024-12-17)\\n */\\n gpt_4o_realtime_preview_2024_12_17: 'gpt-4o-realtime-preview-2024-12-17',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-realtime-preview-2025-06-03)\\n */\\n gpt_4o_realtime_preview_2025_06_03: 'gpt-4o-realtime-preview-2025-06-03',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-search-preview)\\n */\\n gpt_4o_search_preview: 'gpt-4o-search-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-search-preview-2025-03-11)\\n */\\n gpt_4o_search_preview_2025_03_11: 'gpt-4o-search-preview-2025-03-11',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Audio | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-transcribe)\\n */\\n gpt_4o_transcribe: 'gpt-4o-transcribe',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-5)\\n */\\n gpt_5: 'gpt-5',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-5-2025-08-07)\\n */\\n gpt_5_2025_08_07: 'gpt-5-2025-08-07',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-5-chat-latest)\\n */\\n gpt_5_chat_latest: 'gpt-5-chat-latest',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-5-mini)\\n */\\n gpt_5_mini: 'gpt-5-mini',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-5-mini-2025-08-07)\\n */\\n gpt_5_mini_2025_08_07: 'gpt-5-mini-2025-08-07',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-5-nano)\\n */\\n gpt_5_nano: 'gpt-5-nano',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-5-nano-2025-08-07)\\n */\\n gpt_5_nano_2025_08_07: 'gpt-5-nano-2025-08-07',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-image-1)\\n */\\n gpt_image_1: 'gpt-image-1',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○○ | Very High |\\n * | Speed | ○○ | Slow |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$15.00/1M tokens | \\\\$60.00/1M tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o1)\\n */\\n o1: 'o1',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○○ | Very High |\\n * | Speed | ○○ | Slow |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$15.00/1M tokens | \\\\$60.00/1M tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o1-2024-12-17)\\n */\\n o1_2024_12_17: 'o1-2024-12-17',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$3.00/1M tokens | \\\\$12.00/1M tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o1-mini)\\n */\\n o1_mini: 'o1-mini',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$3.00/1M tokens | \\\\$12.00/1M tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o1-mini-2024-09-12)\\n */\\n o1_mini_2024_09_12: 'o1-mini-2024-09-12',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○○ | Very High |\\n * | Speed | ○○ | Slow |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o1-pro)\\n */\\n o1_pro: 'o1-pro',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○○ | Very High |\\n * | Speed | ○○ | Slow |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o1-pro-2025-03-19)\\n */\\n o1_pro_2025_03_19: 'o1-pro-2025-03-19',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○○ | Very High |\\n * | Speed | ○○ | Slow |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o3)\\n */\\n o3: 'o3',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○○ | Very High |\\n * | Speed | ○○ | Slow |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o3-2025-04-16)\\n */\\n o3_2025_04_16: 'o3-2025-04-16',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o3-deep-research)\\n */\\n o3_deep_research: 'o3-deep-research',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o3-deep-research-2025-06-26)\\n */\\n o3_deep_research_2025_06_26: 'o3-deep-research-2025-06-26',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o3-mini)\\n */\\n o3_mini: 'o3-mini',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o3-mini-2025-01-31)\\n */\\n o3_mini_2025_01_31: 'o3-mini-2025-01-31',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o3-pro)\\n */\\n o3_pro: 'o3-pro',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o3-pro-2025-06-10)\\n */\\n o3_pro_2025_06_10: 'o3-pro-2025-06-10',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o4-mini)\\n */\\n o4_mini: 'o4-mini',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o4-mini-2025-04-16)\\n */\\n o4_mini_2025_04_16: 'o4-mini-2025-04-16',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o4-mini-deep-research)\\n */\\n o4_mini_deep_research: 'o4-mini-deep-research',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o4-mini-deep-research-2025-06-26)\\n */\\n o4_mini_deep_research_2025_06_26: 'o4-mini-deep-research-2025-06-26',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/omni-moderation-2024-09-26)\\n */\\n omni_moderation_2024_09_26: 'omni-moderation-2024-09-26',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/omni-moderation-latest)\\n */\\n omni_moderation_latest: 'omni-moderation-latest'\\n} as const\\n\",\"export const OpenaiImageModel = {\\n dall_e_2: 'dall-e-2',\\n dall_e_3: 'dall-e-3',\\n gpt_image_1: 'gpt-image-1',\\n} as const\"],\"mappings\":\"oiBAAA,IAAaA,EAAb,MAAaC,EACQC,UACAC,SACAC,aACTC,GAAU,EAElB,WAAAC,CACIJ,EACAC,EACAC,GAEA,IAAMG,EAAQC,KACdA,KAAKN,UAAaO,kBACd,UACWP,QACFQ,GACL,YAAMC,EACAD,UAENH,EAAMF,GAAU,EAExB,CATkBI,GAUlBD,KAAKL,SAAWA,EAChBK,KAAKJ,aAAeA,CACxB,CAIA,CAACQ,OAAOC,iBACJ,OAAOL,IACX,CAIA,UAAMM,IAAQC,GACV,IAAMC,QAAcR,KAAKN,UAAUY,KAAKC,GACxC,OAAOC,EAAMA,QAAUL,EACjBK,QACMR,KAAKM,KAAKC,EAC1B,CAEA,OAAOC,GACH,OAAOR,KAAKN,UAAUe,OAAOD,EACjC,CA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ACP,GACduC,EAAkDH,EAAMrV,MAAM,mBAEnEyV,eACAtI,WACA4F,cACGyC,EACDH,EAAMrV,MAAM,8GAAiH0V,OAC7HL,EAAMrV,MAAM,qFAAsF0V,OACrG,MAAO,CACNC,gBAAiB1hB,EAAYohB,GAAOpf,cAAcU,iBAClDwW,SAAUlZ,EAAYkZ,GAAUlX,cAAcU,iBAC9Coc,WAAY9e,EAAY8F,SAASgZ,IAAczc,cAAcK,iBAC7D8e,aAAcxhB,EAAYwhB,GAAcxf,cAAcS,iBAAiBC,iBAEzE,QAwCAif,eAAAC,qBAAAC,cAAAC,kBAAAC,wBAAAC,oBAAAvT,uBAAAwT,mBAAAC,sBAAAC,kBAAAC,sBAAAC,iBAAAC,uBAAAC,iBAAAC,mBAAAC,8BAAAC,6BAAAC,qBAAAC,eAAAC,qBAAAC,SAAAC,iBAAAC,qCAAAC,kBAAAC,yBAAAC,sBAAAC,eAAAC\",\"ignoreList\":[]}"
|
|
1
|
+
"{\"version\":3,\"names\":[\"Flux\",\"_Flux\",\"generator\",\"upstream\",\"handleCancel\",\"_closed\",\"constructor\",\"thiss\",\"this\",\"async\",\"e\",\"ignorableValue\",\"Symbol\",\"asyncIterator\",\"next\",\"args\",\"value\",\"return\",\"throw\",\"cancel\",\"closed\",\"then\",\"onfulfilled\",\"onrejected\",\"result\",\"asList\",\"onfinally\",\"promise\",\"toStringTag\",\"subscribe\",\"callback\",\"flux\",\"doOnEach\",\"recur\",\"done\",\"catch\",\"err\",\"console\",\"error\",\"unsubscribe\",\"filter\",\"predicate\",\"constructFromGeneratorFunction\",\"untilExcl\",\"doAfterLast\",\"events\",\"push\",\"map\",\"mapper\",\"take\",\"n\",\"i\",\"flatMap\",\"Array\",\"isArray\",\"r\",\"transform\",\"defineGenerator\",\"definedGenerator\",\"reduce\",\"reducer\",\"initialValue\",\"reduction\",\"whenComplete\",\"ignored\",\"create\",\"creator\",\"values\",\"resolvers\",\"isDone\",\"Error\",\"length\",\"shift\",\"resolve\",\"complete\",\"reject\",\"fromGenerator\",\"Promise\",\"fromArray\",\"array\",\"fromGeneratorFunction\",\"fn\",\"fromReadableStream\",\"stream\",\"reader\",\"getReader\",\"excerpt\",\"read\",\"exports\",\"D\",\"We\",\"oe\",\"Object\",\"defineProperty\",\"Flux_1\",\"Ye\",\"enumerable\",\"get\",\"import_monoflux\",\"re\",\"promptOpenai\",\"model\",\"prompt\",\"apiToken\",\"temperature\",\"topP\",\"requireJsonResponse\",\"serviceTier\",\"tools\",\"_e\",\"abortController\",\"AbortController\",\"response\",\"fetch\",\"headers\",\"Accept\",\"Authorization\",\"method\",\"signal\",\"body\",\"JSON\",\"stringify\",\"messages\",\"top_p\",\"response_format\",\"type\",\"service_tier\",\"status\",\"message\",\"bodyText\",\"parse\",\"errorMessage\",\"text\",\"jsonBuffer\",\"accumulatedToolCalls\",\"abort\",\"textDecoder\",\"decode\",\"replaceAll\",\"replace\",\"split\",\"trim\",\"json\",\"chunk\",\"choices\",\"choice\",\"delta\",\"tool_calls\",\"toolCall\",\"id\",\"function\",\"name\",\"arguments\",\"index\",\"existingEntry\",\"finish_reason\",\"toolCalls\",\"content\",\"item\",\"TextDecoder\",\"ComplexTypeError\",\"data\",\"httpStatus\",\"problems\",\"problem\",\"expectedProp\",\"path\",\"expectedType\",\"typeToString\",\"join\",\"insteadGot\",\"unknownProp\",\"super\",\"requireThat\",\"TypeSpec\",\"checkIsOneOf\",\"types\",\"opts\",\"problemsPerType\",\"ignoreUnknownProps\",\"elementType\",\"key\",\"props\",\"prop\",\"optional\",\"typeAccountingOptionality\",\"Number\",\"isNaN\",\"checkIs\",\"some\",\"list\",\"typeProblemsOnThisPath\",\"t\",\"promptGridApiUrl\",\"_TypeSpec\",\"canBeArray\",\"assertTypeOfArray\",\"elementSpec\",\"arraySpec\",\"canBeObject\",\"assertTypeOfObject\",\"objectSpec\",\"hasString\",\"propertyName\",\"hasProperty\",\"canBeString\",\"canHaveProperty\",\"assertTypeOfProperty\",\"old\",\"propertyType\",\"canBeNumber\",\"canBeBoolean\",\"canBeConstant\",\"canBeNull\",\"canBeUndefined\",\"andNothingElse\",\"orDefaultTo\",\"describe\",\"indentLevel\",\"keys\",\"indent\",\"depth\",\"config\",\"getPromptGridApiUrl\",\"rawValue\",\"url\",\"url2\",\"backendUrlNotTriviallyIdentifiableInMinifiedCode\",\"Token\",\"source\",\"fieldName\",\"maybeIncomplete\",\"JsonTokenProcessor\",\"_JsonTokenProcessor\",\"highestOffsetParsed\",\"toJsonTokenFlux\",\"dataBufferFlux\",\"processDataBuffer\",\"deltaContentFlux\",\"getExcerpts\",\"token\",\"excerpts\",\"jsonParser\",\"JsonParser\",\"nextToken\",\"currentTokenLocation\",\"getCharOffset\",\"position\",\"currentTokenType\",\"parentFieldName\",\"currentValue\",\"context\",\"startPosition\",\"test\",\"substring\",\"char\",\"pushContext\",\"popContext\",\"currentContextType\",\"startPos\",\"endPos\",\"indexOf\",\"nextFourChars\",\"nextFiveChars\",\"numStr\",\"hasDecimal\",\"parseFloat\",\"parseInt\",\"mayBeIncomplete\",\"JsonParseException\",\"contextType\",\"currentContext\",\"pop\",\"nonNullish\",\"StreamedJsonElement\",\"receivedJson\",\"propertyCallbacks\",\"Map\",\"onElementCallbacks\",\"Set\",\"onCompleteCallbacks\",\"onEachExcerptCallbacks\",\"currentToken\",\"state\",\"Begin\",\"receivedExcerpts\",\"onElement\",\"add\",\"onProperty\",\"has\",\"set\",\"onJsonStringProperty\",\"processor\",\"stringBuffer\",\"jsonElement\",\"StreamedJsonChildElement\",\"onEachExcerpt\",\"jsonStringExcerpt\",\"allData\",\"excerptWithHoleEscapeTokens\",\"endsOnUnevenNumberOfBackslashes\",\"unescapedExcerptWithoutOpeningQuote\",\"unescapedExcerptWithoutClosingQuote\",\"forEach\",\"getResponseAsPromise\",\"onCompleteAs\",\"onComplete\",\"_onComplete\",\"toAsync\",\"expectedTokenType\",\"consumer\",\"onCompleteAsync\",\"onCompleteAsAsync\",\"jsonStringValue\",\"jsonString\",\"deserializedValue\",\"onCompleteAsString\",\"onCompleteAsStringAsync\",\"onCompleteAsInt\",\"onCompleteAsIntAsync\",\"onCompleteAsNumber\",\"onCompleteAsNumberAsync\",\"onCompleteAsBoolean\",\"onCompleteAsBooleanAsync\",\"asJsonFlux\",\"Xe\",\"whenCompleteAs\",\"isState\",\"InNested\",\"child\",\"tokenType\",\"size\",\"InObject\",\"InArray\",\"end\",\"UnexpectedTokenException\",\"resultingJson\",\"InPropertyValue\",\"InArrayElement\",\"subscription\",\"completeValue\",\"from\",\"stateClass\",\"count\",\"State\",\"StreamedJsonRootElement\",\"jsonTokenFlux\",\"Ze\",\"lastTokenExcerpt\",\"StreamedJsonParser\",\"parseJsonWithUsefulError\",\"completedJson\",\"parsePartialJson\",\"partialJson\",\"opened\",\"escaped\",\"pushScope\",\"scope\",\"popScope\",\"expect\",\"lastOpened\",\"includes\",\"illegalState\",\"nextEscapedValue\",\"match\",\"closeEverything\",\"reverse\",\"opener\",\"requireDefined\",\"byteToHex\",\"toString\",\"slice\",\"randomFillSync\",\"rnds8Pool\",\"Uint8Array\",\"poolPtr\",\"randomUUID\",\"native_default\",\"v4_default\",\"options\",\"buf\",\"offset\",\"rnds\",\"random\",\"rng\",\"RangeError\",\"arr\",\"toLowerCase\",\"unsafeStringify\",\"specType\",\"EmptyTypeSpec\",\"evaluations\",\"juggleBetweenNullAndUndefined\",\"juggleTo\",\"elementConformities\",\"element\",\"c\",\"juggles\",\"typeConformity\",\"newValue\",\"juggle\",\"typeConformities\",\"evaluation\",\"conformsPerfectly\",\"typeConformitiesThatPassWithJuggle\",\"juggleThatWouldMakeValueConform\",\"_\",\"_EmptyTypeSpec\",\"FullTypeSpec\",\"object\",\"properties\",\"TypeMemberSpec\",\"string\",\"number\",\"boolean\",\"constant\",\"otherValues\",\"FullPropTypeSpec\",\"undefined\",\"any\",\"_FullTypeSpec\",\"orArray\",\"orObject\",\"orString\",\"orNumber\",\"orBoolean\",\"orConstant\",\"orNull\",\"orUndefined\",\"_TypeMemberSpec\",\"mayHave\",\"hint\",\"canHaveString\",\"canHaveNumber\",\"canHaveBoolean\",\"canHaveConstant\",\"firstConstant\",\"otherConstants\",\"arg3\",\"arg4\",\"comment\",\"propertyTypeSpec\",\"EmptyPropTypeSpec\",\"commentsFromPropTypeSpec\",\"_comments\",\"comments\",\"hasNumber\",\"hasBoolean\",\"hasConstant\",\"arg2\",\"otherArgs\",\"constants\",\"PropTypeSpec\",\"withComment\",\"_FullPropTypeSpec\",\"assertType\",\"typeSpec\",\"describeType\",\"propSpec\",\"comma\",\"promptOpenaiImageGen\",\"apiKey\",\"ok\",\"errorData\",\"b64_json\",\"atob\",\"charCodeAt\",\"writeFile\",\"AiModel\",\"gpt_3_5_turbo\",\"gpt_3_5_turbo_0125\",\"gpt_3_5_turbo_1106\",\"gpt_3_5_turbo_16k\",\"gpt_3_5_turbo_instruct\",\"gpt_3_5_turbo_instruct_0914\",\"gpt_4\",\"gpt_4_0125_preview\",\"gpt_4_0613\",\"gpt_4_1106_preview\",\"gpt_4_turbo\",\"gpt_4_turbo_2024_04_09\",\"gpt_4_turbo_preview\",\"gpt_4_1\",\"gpt_4_1_2025_04_14\",\"gpt_4_1_mini\",\"gpt_4_1_mini_2025_04_14\",\"gpt_4_1_nano\",\"gpt_4_1_nano_2025_04_14\",\"gpt_4o\",\"gpt_4o_2024_05_13\",\"gpt_4o_2024_08_06\",\"gpt_4o_2024_11_20\",\"gpt_4o_audio_preview\",\"gpt_4o_audio_preview_2024_10_01\",\"gpt_4o_audio_preview_2024_12_17\",\"gpt_4o_audio_preview_2025_06_03\",\"gpt_4o_mini\",\"gpt_4o_mini_2024_07_18\",\"gpt_4o_mini_audio_preview\",\"gpt_4o_mini_audio_preview_2024_12_17\",\"gpt_4o_mini_realtime_preview\",\"gpt_4o_mini_realtime_preview_2024_12_17\",\"gpt_4o_mini_search_preview\",\"gpt_4o_mini_search_preview_2025_03_11\",\"gpt_4o_mini_transcribe\",\"gpt_4o_mini_tts\",\"gpt_4o_realtime_preview\",\"gpt_4o_realtime_preview_2024_10_01\",\"gpt_4o_realtime_preview_2024_12_17\",\"gpt_4o_realtime_preview_2025_06_03\",\"gpt_4o_search_preview\",\"gpt_4o_search_preview_2025_03_11\",\"gpt_4o_transcribe\",\"gpt_5\",\"gpt_5_2025_08_07\",\"gpt_5_chat_latest\",\"gpt_5_mini\",\"gpt_5_mini_2025_08_07\",\"gpt_5_nano\",\"gpt_5_nano_2025_08_07\",\"gpt_image_1\",\"o1\",\"o1_2024_12_17\",\"o1_mini\",\"o1_mini_2024_09_12\",\"o1_pro\",\"o1_pro_2025_03_19\",\"o3\",\"o3_2025_04_16\",\"o3_deep_research\",\"o3_deep_research_2025_06_26\",\"o3_mini\",\"o3_mini_2025_01_31\",\"o3_pro\",\"o3_pro_2025_06_10\",\"o4_mini\",\"o4_mini_2025_04_16\",\"o4_mini_deep_research\",\"o4_mini_deep_research_2025_06_26\",\"omni_moderation_2024_09_26\",\"omni_moderation_latest\",\"OpenaiImageModel\",\"dall_e_2\",\"dall_e_3\",\"AIClient\",\"_apiKeyChain\",\"_conversation\",\"arg\",\"effectivePromptGunConfig\",\"createConversation\",\"newClient\",\"AIConversation\",\"uuid\",\"apiKeyChain\",\"obtainAiClientData\",\"conversation\",\"chat\",\"arg1\",\"toPrompt\",\"effectiveMessages\",\"user\",\"m\",\"BasicPrompt\",\"getCallerFileNameAndLineNumber\",\"image\",\"ImagePrompt\",\"_AIConversation\",\"copyConversation\",\"messageUuid\",\"_model\",\"_imageSize\",\"aiClient\",\"getResponseAsString\",\"imageSize\",\"toFile\",\"fileName\",\"ImageFilePrompt\",\"openai\",\"getResponseAsFile\",\"byptes\",\"File\",\"ai\",\"setupAI\",\"newAIClient\",\"promptGridApiKey\",\"effectivePromptGridApiKey\",\"debugMode\",\"attemptsPerCall\",\"apiKeys\",\"effectiveAttemptsPerCall\",\"rawPromptGridApiKey\",\"rawAttemptsPerCall\",\"typedAttemptsPerCall\",\"promptgrid\",\"promptMappings\",\"promptAI\",\"client\",\"effectiveClient\",\"PromptBase\",\"callingCodeLine\",\"completeChat\",\"promptSupplier\",\"promptSupplierArgs\",\"_temperature\",\"_topP\",\"_serviceTier\",\"_firstThink\",\"self\",\"executeLlmCall\",\"genericMessages\",\"promptName\",\"_tools\",\"firstThink\",\"flex\",\"useFlexTier\",\"role\",\"TypeSpecMarker\",\"genericPrompt\",\"typeSpecIndex\",\"toGenericPrompt\",\"jsonSpecMessage\",\"jsonSpec\",\"JsonPrompt\",\"getBoolean\",\"o\",\"getString\",\"getNumber\",\"getObject\",\"getArray\",\"JsonArrayPrompt\",\"getAny\",\"normalizedTools\",\"tool\",\"typeSpecToJsonSchema\",\"convertType\",\"required\",\"entries\",\"items\",\"const\",\"defineTool\",\"description\",\"parameters\",\"jsonTypeSupplier\",\"streamingJsonRootElement\",\"getFlux\",\"$e\",\"lazyGenerator\",\"stringGenerator\",\"jsonExcerpt\",\"partialJsonGenerator\",\"accumulatedJson\",\"getResponse\",\"stringResult\",\"uncheckedPackedResult\",\"_responseAsStringPromise\",\"_getResponseAsString\",\"arrayElementGenerator\",\"pickModel\",\"modelId\",\"typeSpecMessage\",\"toOpenAiMessage\",\"msg\",\"system\",\"assistant\",\"genericPromptWithJsonSpec\",\"convSavePromises\",\"promptFilename\",\"lineNumber\",\"promptLineNumber\",\"startsWith\",\"promptProfile\",\"conversationUuid\",\"saveLoop\",\"saveConv\",\"conversationData\",\"newMsg\",\"existing\",\"find\",\"currentSave\",\"save\",\"saveConversation\",\"setTimeout\",\"delete\",\"genericPromptWithJsonSpecAndConversationHistory\",\"responseMessageId\",\"incomplete\",\"attempts\",\"openaiTools\",\"accumulatedContent\",\"toolCallsToExecute\",\"toolResults\",\"tool_call_id\",\"String\",\"toolCallMessage\",\"tc\",\"toolCallsDescription\",\"toolResultMessages\",\"toolResult\",\"toolName\",\"uncheckedResult\",\"typeError\",\"warn\",\"promises\",\"all\",\"newO\",\"frame\",\"stack\",\"l\",\"hasFunctionNameInFrameWithFileNameInParenthesis\",\"functionName\",\"groups\",\"stacktraceFrame\",\"ee\",\"Le\",\"Mt\",\"fe\",\"ye\",\"L\",\"v\",\"Fe\",\"Ve\",\"Ge\",\"he\",\"Nt\",\"Ke\",\"X\",\"O\",\"Q\",\"V\",\"G\",\"ge\",\"Be\",\"Hn\",\"Te\",\"zn\",\"st\",\"Me\",\"Wn\",\"Dn\"],\"sources\":[\"../node_modules/monoflux/src/Flux.ts\",\"../node_modules/monoflux/src/index.ts\",\"../src/index.ts\",\"../src/ai-inference/openai/promptOpenai.ts\",\"../src/require-that/requireThat.ts\",\"../src/env-vars.ts\",\"../src/json-streaming/types.ts\",\"../src/json-streaming/JsonTokenProcessor.ts\",\"../src/json-streaming/StreamedJsonElement.ts\",\"../src/util/nonNullish.ts\",\"../src/json-streaming/StreamedJsonRootElement.ts\",\"../src/json-streaming/StreamedJsonParser.ts\",\"../src/util/parseJsonWithUsefulError.ts\",\"../src/parse-partial-json/parsePartialJson.ts\",\"../src/util/requireDefined.ts\",\"../node_modules/uuid/dist/esm/stringify.js\",\"../node_modules/uuid/dist/esm/rng.js\",\"../node_modules/uuid/dist/esm/native.js\",\"../node_modules/uuid/dist/esm/v4.js\",\"../src/type-spec/type-spec.ts\",\"../src/ai-inference/openai/promptOpenaiImageGen.ts\",\"../src/ai-inference/AiModel.ts\",\"../src/ai-inference/openai/OpenaiImageModel.ts\"],\"sourcesContent\":[null,null,\"import {Flux} from 'monoflux'\\nimport type {AiModelId} from './ai-inference/AiModelId.js'\\nimport type {GenericPrompt, PromptMessage, Role, ServiceTier} from './ai-inference/model.js'\\nimport {promptOpenai, type PromptChunk, type ToolCall} from './ai-inference/openai/promptOpenai.js'\\nimport {getPromptGridApiUrl} from './env-vars.js'\\nimport {JsonTokenProcessor} from './json-streaming/JsonTokenProcessor.js'\\nimport {StreamedJsonChildElement} from './json-streaming/StreamedJsonElement.js'\\nimport {StreamedJsonParser} from './json-streaming/StreamedJsonParser.js'\\nimport {StreamedJsonRootElement} from './json-streaming/StreamedJsonRootElement.js'\\nimport {parsePartialJson} from './parse-partial-json/parsePartialJson.js'\\nimport {nonNullish} from './util/nonNullish.js'\\nimport {requireDefined} from './util/requireDefined.js'\\nimport {randomUuid} from './util/randomUuid.ts'\\nimport {\\n\\tassertType,\\n\\tdescribeType,\\n\\tEmptyTypeSpec,\\n\\tFullPropTypeSpec,\\n\\tspecType,\\n\\tTypeMemberSpec,\\n\\tTypeSpec\\n} from './type-spec/type-spec.js'\\nimport {requireThat} from './require-that/requireThat.js'\\nimport {parseJsonWithUsefulError} from './util/parseJsonWithUsefulError.js'\\nimport {ImageSize, promptOpenaiImageGen} from './ai-inference/openai/promptOpenaiImageGen.ts'\\nimport {writeFile} from 'fs'\\nimport {OpenaiImageModelId} from './ai-inference/openai/OpenaiImageModelId.js'\\n\\ntype SystemMessage = {system: string, user?: undefined, assistant?: undefined, developer?: undefined}\\ntype UserMessage = {system?: undefined, user: string, assistant?: undefined, developer?: undefined}\\ntype AssistantMessage = {system?: undefined, user?: undefined, assistant: string, developer?: undefined}\\ntype DeveloperMessage = {system?: undefined, user?: undefined, assistant?: undefined, developer: string}\\ntype TypeSpecMessage = {system?: undefined, user?: undefined, assistant?: undefined, developer?: undefined, typeSpec: true}\\n\\ntype Message = SystemMessage | UserMessage | AssistantMessage | DeveloperMessage | TypeSpecMessage\\n\\ntype Prompt = string | Message | (Message | undefined)[]\\n\\ntype ApiKeys = {\\n\\topenai?: string | undefined\\n}\\n\\ntype Opts = {\\n\\tmodel?: 'gpt-4o'\\n}\\n\\ntype HandshakeData = {\\n\\tapiKeys: ApiKeys\\n\\twithinQuotum: boolean\\n}\\n\\nexport type ApiKeyChain = {\\n\\tpromptgrid: string | undefined\\n\\topenai: Promise<string | undefined>\\n}\\n\\nexport type Conversation = {\\n\\tuuid: string\\n\\tmessages: PromptMessageWithId[]\\n}\\n\\nclass AIClient {\\n\\tprotected config: EffectivePromptGunConfig\\n\\tprotected _apiKeyChain: ApiKeyChain | undefined\\n\\tprotected _conversation?: Conversation\\n\\n\\tconstructor(arg: string | PromptGunConfig) {\\n\\t\\tthis.config = effectivePromptGunConfig(arg)\\n\\t}\\n\\n\\tpublic createConversation() {\\n\\t\\tconst newClient = new AIConversation(this.config)\\n\\t\\tnewClient._apiKeyChain = this._apiKeyChain\\n\\t\\tnewClient._conversation = {uuid: randomUuid(), messages: []}\\n\\t\\treturn newClient\\n\\t}\\n\\n\\tpublic get apiKeyChain(): ApiKeyChain {\\n\\t\\tif (this._apiKeyChain === undefined) {\\n\\t\\t\\tthis._apiKeyChain = obtainAiClientData(this.config)\\n\\t\\t}\\n\\t\\treturn this._apiKeyChain\\n\\t}\\n\\n\\tpublic get conversation(): Conversation | undefined {\\n\\t\\treturn this._conversation\\n\\t}\\n\\n\\tchat<T extends undefined>(userMessage: string): BasicPrompt<T>\\n\\tchat<T extends undefined>(...messages: (Message | undefined)[]): BasicPrompt<T>\\n\\tchat<T extends undefined>(messages: (Message | undefined)[]): BasicPrompt<T>\\n\\tchat<T extends undefined>(toPrompt: (args?: T, typeSpecMessage?: TypeSpecMessage) => Prompt): BasicPrompt<T>\\n\\tchat<T>(toPrompt: (args: T, typeSpecMessage?: TypeSpecMessage) => Prompt, args: T): BasicPrompt<T>\\n\\tchat<T = undefined>(toPrompt: (args?: T, typeSpecMessage?: TypeSpecMessage) => Prompt, args?: T): BasicPrompt<T>\\n\\tchat<T = undefined>(\\n\\t\\targ1: (Message | undefined) | (Message | undefined)[] | ((args?: T, typeSpecMessage?: TypeSpecMessage) => Prompt) | string,\\n\\t\\targ2?: (Message | undefined) | T,\\n\\t\\t...arg3: (Message | undefined)[]\\n\\t): BasicPrompt<T> {\\n\\t\\tconst {\\n\\t\\t\\ttoPrompt,\\n\\t\\t\\targs,\\n\\t\\t} = (() => {\\n\\t\\t\\tif (typeof arg1 === 'function') {\\n\\t\\t\\t\\treturn {\\n\\t\\t\\t\\t\\ttoPrompt: arg1,\\n\\t\\t\\t\\t\\targs: arg2,\\n\\t\\t\\t\\t}\\n\\t\\t\\t} else if (typeof arg1 === 'string') {\\n\\t\\t\\t\\treturn {\\n\\t\\t\\t\\t\\ttoPrompt: () => arg1,\\n\\t\\t\\t\\t\\targs: undefined,\\n\\t\\t\\t\\t}\\n\\t\\t\\t} else if (Array.isArray(arg1)) {\\n\\t\\t\\t\\tconst effectiveMessages = arg1.length === 0\\n\\t\\t\\t\\t\\t? [{user: ''}]\\n\\t\\t\\t\\t\\t: arg1.filter(m => m !== undefined)\\n\\t\\t\\t\\treturn {\\n\\t\\t\\t\\t\\ttoPrompt: () => effectiveMessages,\\n\\t\\t\\t\\t\\targs: undefined,\\n\\t\\t\\t\\t}\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tconst messages: Message[] = [\\n\\t\\t\\t\\t\\targ1,\\n\\t\\t\\t\\t\\t...(arg2 !== undefined ? [arg2 as Message] : []),\\n\\t\\t\\t\\t\\t...arg3,\\n\\t\\t\\t\\t].filter(m => m !== undefined)\\n\\t\\t\\t\\tconst effectiveMessages = messages.length === 0\\n\\t\\t\\t\\t\\t? [{user: ''}]\\n\\t\\t\\t\\t\\t: messages\\n\\t\\t\\t\\treturn {\\n\\t\\t\\t\\t\\ttoPrompt: () => effectiveMessages,\\n\\t\\t\\t\\t\\targs: undefined,\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t})()\\n\\t\\treturn new BasicPrompt<T>(\\n\\t\\t\\tthis,\\n\\t\\t\\ttoPrompt,\\n\\t\\t\\targ2 as T,\\n\\t\\t\\tgetCallerFileNameAndLineNumber(),\\n\\t\\t\\tundefined,\\n\\t\\t\\tundefined,\\n\\t\\t\\tundefined,\\n\\t\\t\\tundefined,\\n\\t\\t\\tfalse,\\n\\t\\t)\\n\\t}\\n\\n\\timage(prompt: string): ImagePrompt {\\n\\t\\treturn new ImagePrompt(\\n\\t\\t\\tprompt,\\n\\t\\t\\tundefined,\\n\\t\\t\\tundefined,\\n\\t\\t\\tthis\\n\\t\\t)\\n\\t}\\n}\\n\\nexport class AIConversation extends AIClient {\\n\\tconstructor(arg: string | PromptGunConfig) {\\n\\t\\tsuper(arg)\\n\\t}\\n\\n\\tpublic copyConversation() {\\n\\t\\tif (this._conversation === undefined) {\\n\\t\\t\\tthrow new Error('This method only works on copy conversation: no conversation exists')\\n\\t\\t}\\n\\t\\tconst newClient = new AIConversation(this.config)\\n\\t\\tnewClient._apiKeyChain = this._apiKeyChain\\n\\t\\tnewClient._conversation = {\\n\\t\\t\\tuuid: randomUuid(),\\n\\t\\t\\tmessages: this._conversation.messages.map(m => ({\\n\\t\\t\\t\\t...m,\\n\\t\\t\\t\\tmessageUuid: randomUuid(),\\n\\t\\t\\t})),\\n\\t\\t}\\n\\t\\treturn newClient\\n\\t}\\n}\\n\\nexport class ImagePrompt implements Promise<Buffer> {\\n\\tconstructor(\\n\\t\\tprivate prompt: string,\\n\\t\\tprivate _model: OpenaiImageModelId | undefined,\\n\\t\\tprivate _imageSize: ImageSize | undefined,\\n\\t\\tprivate aiClient: AIClient,\\n\\t) {}\\n\\n\\tasync then<TResult1 = Buffer, TResult2 = never>(\\n\\t\\tonfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null | undefined,\\n\\t\\tonrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined\\n\\t): Promise<TResult1 | TResult2> {\\n\\t\\ttry {\\n\\t\\t\\tconst result = await this.getResponseAsString()\\n\\t\\t\\treturn nonNullish(onfulfilled)\\n\\t\\t\\t\\t? await onfulfilled(result)\\n\\t\\t\\t\\t: result as TResult1\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn await onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tasync catch<TResult = never>(\\n\\t\\tonrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined\\n\\t): Promise<Buffer | TResult> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponseAsString()\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tasync finally(onfinally?: (() => void) | null | undefined): Promise<Buffer> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponseAsString()\\n\\t\\t} finally {\\n\\t\\t\\tonfinally?.()\\n\\t\\t}\\n\\t}\\n\\n\\tget [Symbol.toStringTag](): string {\\n\\t\\treturn 'ImagePrompt'\\n\\t}\\n\\n\\tmodel(model: OpenaiImageModelId) {\\n\\t\\tthis._model = model\\n\\t\\treturn this\\n\\t}\\n\\n\\t/**\\n\\t * The size of the generated images. Must be one of `1024x1024`, `1536x1024`\\n\\t * (landscape), `1024x1536` (portrait), or `auto` (default value) for\\n\\t * `gpt-image-1`, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and\\n\\t * one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`.\\n\\t */\\n\\tsize(imageSize: ImageSize) {\\n\\t\\tthis._imageSize = imageSize\\n\\t\\treturn this\\n\\t}\\n\\n\\ttoFile(fileName: string): ImageFilePrompt {\\n\\t\\treturn new ImageFilePrompt(\\n\\t\\t\\tthis.prompt,\\n\\t\\t\\tthis._model,\\n\\t\\t\\tthis._imageSize,\\n\\t\\t\\tfileName,\\n\\t\\t\\tthis.aiClient\\n\\t\\t)\\n\\t}\\n\\n\\tprivate async getResponseAsString(): Promise<Buffer> {\\n\\t\\tconst apiToken = requireThat(await this.aiClient['apiKeyChain']!.openai)\\n\\t\\t\\t.canBeString()\\n\\t\\t\\t.andNothingElse({errorMessage: 'No OpenAI access token set'})\\n\\t\\treturn await promptOpenaiImageGen(\\n\\t\\t\\tapiToken,\\n\\t\\t\\tthis.prompt\\n\\t\\t)\\n\\t}\\n}\\n\\nexport class ImageFilePrompt implements Promise<File> {\\n\\tconstructor(\\n\\t\\tprivate prompt: string,\\n\\t\\tprivate _model: OpenaiImageModelId | undefined,\\n\\t\\tprivate _imageSize: ImageSize | undefined,\\n\\t\\tprivate fileName: string,\\n\\t\\tprivate aiClient: AIClient,\\n\\t) {}\\n\\n\\tasync then<TResult1 = File, TResult2 = never>(\\n\\t\\tonfulfilled?: ((value: File) => TResult1 | PromiseLike<TResult1>) | null | undefined,\\n\\t\\tonrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined\\n\\t): Promise<TResult1 | TResult2> {\\n\\t\\ttry {\\n\\t\\t\\tconst result = await this.getResponseAsFile()\\n\\t\\t\\treturn nonNullish(onfulfilled)\\n\\t\\t\\t\\t? await onfulfilled(result)\\n\\t\\t\\t\\t: result as TResult1\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn await onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tasync catch<TResult = never>(\\n\\t\\tonrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined\\n\\t): Promise<File | TResult> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponseAsFile()\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tasync finally(onfinally?: (() => void) | null | undefined): Promise<File> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponseAsFile()\\n\\t\\t} finally {\\n\\t\\t\\tonfinally?.()\\n\\t\\t}\\n\\t}\\n\\n\\tget [Symbol.toStringTag](): string {\\n\\t\\treturn 'ImageFilePrompt'\\n\\t}\\n\\n\\tmodel(model: OpenaiImageModelId) {\\n\\t\\tthis._model = model\\n\\t\\treturn this\\n\\t}\\n\\n\\t/**\\n\\t * The size of the generated images. Must be one of `1024x1024`, `1536x1024`\\n\\t * (landscape), `1024x1536` (portrait), or `auto` (default value) for\\n\\t * `gpt-image-1`, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and\\n\\t * one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`.\\n\\t */\\n\\tsize(imageSize: ImageSize) {\\n\\t\\tthis._imageSize = imageSize\\n\\t\\treturn this\\n\\t}\\n\\n\\tprivate async getResponseAsFile(): Promise<File> {\\n\\t\\tconst apiToken = requireThat(await this.aiClient['apiKeyChain']!.openai)\\n\\t\\t\\t.canBeString()\\n\\t\\t\\t.andNothingElse({errorMessage: 'No OpenAI access token set'})\\n\\t\\tconst byptes = await promptOpenaiImageGen(\\n\\t\\t\\tapiToken,\\n\\t\\t\\tthis.prompt,\\n\\t\\t\\tthis._model,\\n\\t\\t\\tthis._imageSize\\n\\t\\t)\\n\\t\\treturn new Promise<File>((resolve, reject) => {\\n\\t\\t\\twriteFile(this.fileName, byptes, (err: any) => {\\n\\t\\t\\t\\tif (err) {\\n\\t\\t\\t\\t\\treject(err)\\n\\t\\t\\t\\t\\treturn\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tresolve(\\n\\t\\t\\t\\t\\tnew File([byptes], this.fileName, { type: 'image/png' })\\n\\t\\t\\t\\t)\\n\\t\\t\\t})\\n\\t\\t})\\n\\t}\\n}\\n\\nexport let ai = new AIClient({})\\n\\nexport type PromptGunConfig = {\\n\\tpromptGridApiKey?: string\\n\\tapiKeys?: ApiKeys\\n\\t/**\\n\\t * Finishes submitting logs to promptgrid before completing a prompt's result stream,\\n\\t * so that chat logs of prompts before breakpoints or test ends will not be cut short.\\n\\t */\\n\\tdebugMode?: boolean\\n\\n\\t/**\\n\\t * Number of times to try a prompt before giving up. If the prompt fails,\\n\\t * the next attempt will be made with the same prompt with a delay of 1 second. Should\\n\\t * be an integer greater than or equal to 1. Default value: 1 (no retrying).\\n\\t */\\n\\tattemptsPerCall?: number\\n}\\n\\nexport type EffectivePromptGunConfig = {\\n\\tpromptGridApiKey?: string\\n\\tapiKeys?: ApiKeys\\n\\tdebugMode: boolean\\n\\tattemptsPerCall: number\\n}\\n\\nexport function setupAI(arg: string | PromptGunConfig) {\\n\\tconst config = effectivePromptGunConfig(arg)\\n\\tai['config'] = config\\n\\tai['_apiKeyChain'] = obtainAiClientData(config)\\n}\\n\\nexport function newAIClient(promptGridApiKey: string): AIClient\\nexport function newAIClient(config: PromptGunConfig): AIClient\\nexport function newAIClient(arg: string | PromptGunConfig): AIClient {\\n\\tconst config = effectivePromptGunConfig(arg)\\n\\treturn new AIClient(config)\\n}\\n\\nfunction effectivePromptGunConfig(arg: string | PromptGunConfig): EffectivePromptGunConfig {\\n\\tif (typeof arg === 'string') {\\n\\t\\treturn {\\n\\t\\t\\tpromptGridApiKey: effectivePromptGridApiKey(arg),\\n\\t\\t\\tdebugMode: false,\\n\\t\\t\\tattemptsPerCall: 1,\\n\\t\\t}\\n\\t}\\n\\treturn {\\n\\t\\tpromptGridApiKey: effectivePromptGridApiKey(arg.promptGridApiKey),\\n\\t\\tapiKeys: arg.apiKeys,\\n\\t\\tdebugMode: arg.debugMode ?? false,\\n\\t\\tattemptsPerCall: effectiveAttemptsPerCall(arg.attemptsPerCall),\\n\\t}\\n}\\n\\nfunction effectivePromptGridApiKey(rawPromptGridApiKey: string | undefined) {\\n\\treturn assertType(\\n\\t\\trawPromptGridApiKey,\\n\\t\\tspecType(rawPromptGridApiKey)\\n\\t\\t\\t.string()\\n\\t\\t\\t.orUndefined(),\\n\\t\\t{errorMessage: `Please provide a valid API key; got ${rawPromptGridApiKey}`}\\n\\t)\\n}\\n\\nfunction effectiveAttemptsPerCall(rawAttemptsPerCall: number | undefined): number {\\n\\tconst typedAttemptsPerCall = assertType(\\n\\t\\trawAttemptsPerCall,\\n\\t\\tspecType(rawAttemptsPerCall)\\n\\t\\t\\t.number()\\n\\t\\t\\t.orUndefined(),\\n\\t\\t{errorMessage: `Please provide a valid number of attempts per call; got ${rawAttemptsPerCall}`}\\n\\t) ?? 1\\n\\tif (typedAttemptsPerCall < 1) {\\n\\t\\tthrow new Error(`Please provide a valid number of attempts per call; minimum is 1; got ${typedAttemptsPerCall}`)\\n\\t}\\n\\treturn typedAttemptsPerCall\\n}\\n\\nexport function obtainAiClientData(config: PromptGunConfig) {\\n\\tconst promptGridApiKey = config.promptGridApiKey\\n\\tconst apiKeys = config.apiKeys\\n\\n\\treturn {\\n\\t\\tpromptgrid: promptGridApiKey,\\n\\t\\topenai: (async () => {\\n\\t\\t\\tif (apiKeys?.openai) {\\n\\t\\t\\t\\treturn apiKeys.openai\\n\\t\\t\\t}\\n\\t\\t\\tif (promptGridApiKey === undefined) {\\n\\t\\t\\t\\treturn undefined\\n\\t\\t\\t}\\n\\t\\t\\tconst response = await (async () => {\\n\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\treturn await fetch(\\n\\t\\t\\t\\t\\t\\t`${getPromptGridApiUrl()}/handshake`,\\n\\t\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\tmethod: 'POST',\\n\\t\\t\\t\\t\\t\\t\\theaders: {\\n\\t\\t\\t\\t\\t\\t\\t\\t'Content-Type': 'application/json',\\n\\t\\t\\t\\t\\t\\t\\t\\t'User-Agent': 'promptgun',\\n\\t\\t\\t\\t\\t\\t\\t\\t'Authorization': `Bearer ${promptGridApiKey}`,\\n\\t\\t\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t)\\n\\t\\t\\t\\t} catch (e) {\\n\\t\\t\\t\\t\\tthrow new Error('HTTP called failed when doing handshake')\\n\\t\\t\\t\\t}\\n\\t\\t\\t})()\\n\\t\\t\\tif (response.status !== 200) {\\n\\t\\t\\t\\tconst body = await response.text()\\n\\t\\t\\t\\tthrow new Error(`Handshake failed with status ${response.status}, body: ${body}`)\\n\\t\\t\\t}\\n\\t\\t\\tconst handshakeData = await response.json() as HandshakeData\\n\\t\\t\\treturn handshakeData.apiKeys.openai\\n\\t\\t})(),\\n\\t}\\n}\\n\\n// Create a map to store resolved prompt UUIDs\\nconst promptMappings = new Map<string, string>();\\n\\n// Function to generate a key for the promptMappings map\\nfunction createPromptMappingKey(filename: string, lineNumber: number): string {\\n\\treturn `${filename}:${lineNumber}`;\\n}\\n\\n// Function to safely generate the key, handling undefined values\\nfunction safeCreateMappingKey(filename: string | undefined, lineNumber: number | undefined): string | null {\\n\\tif (filename && lineNumber !== undefined) {\\n\\t\\treturn createPromptMappingKey(filename, lineNumber);\\n\\t}\\n\\treturn null;\\n}\\n\\nexport function promptAI(client?: AIClient): PromptBase {\\n\\tconst effectiveClient = client ?? ai\\n\\tif (effectiveClient['apiKeyChain'] === undefined) {\\n\\t\\tthrow new Error('No LLM set up. Call setupPromptGun first: ```import { setupPromptGun } from \\\\'promptgun\\\\';\\\\n\\\\nsetupPromptGun({openAI: \\\"YOUR_OPENAI_API_KEY\\\"});\\\\n```')\\n\\t}\\n\\treturn new PromptBase(effectiveClient, getCallerFileNameAndLineNumber())\\n}\\n\\nclass PromptBase {\\n\\tconstructor(\\n\\t\\tprivate aiClient: AIClient,\\n\\t\\tprivate callingCodeLine: CodeLine,\\n\\t) {}\\n\\n\\tcompleteChat<T extends undefined>(toPrompt: (args?: T, typeSpecMessage?: TypeSpecMessage) => Prompt): BasicPrompt<T>\\n\\tcompleteChat<T>(toPrompt: (args: T, typeSpecMessage?: TypeSpecMessage) => Prompt, args: T): BasicPrompt<T>\\n\\tcompleteChat<T = undefined>(toPrompt: (args?: T, typeSpecMessage?: TypeSpecMessage) => Prompt, args?: T): BasicPrompt<T>\\n\\tcompleteChat<T = undefined>(\\n\\t\\ttoPrompt: (args?: T, typeSpecMessage?: TypeSpecMessage) => Prompt,\\n\\t\\targs?: T,\\n\\t): BasicPrompt<T> {\\n\\t\\treturn new BasicPrompt<T>(\\n\\t\\t\\tthis.aiClient,\\n\\t\\t\\ttoPrompt,\\n\\t\\t\\targs as T,\\n\\t\\t\\tgetCallerFileNameAndLineNumber(),\\n\\t\\t\\tundefined,\\n\\t\\t\\tundefined,\\n\\t\\t\\tundefined,\\n\\t\\t\\tundefined,\\n\\t\\t\\tfalse,\\n\\t\\t)\\n\\t}\\n}\\n\\nclass BasicPrompt<PSArgs> implements AsyncGenerator<string>, Promise<string> {\\n\\tprivate readonly generator: AsyncGenerator<string>\\n\\tprivate promptName?: string;\\n\\tprivate _tools?: ToolDefinition[];\\n\\n\\tconstructor(\\n\\t\\tprivate aiClient: AIClient,\\n\\t\\tprivate promptSupplier: (args: PSArgs, typeSpecMessage?: TypeSpecMessage) => Prompt,\\n\\t\\tprivate promptSupplierArgs: PSArgs,\\n\\t\\tprivate callingCodeLine: CodeLine,\\n\\t\\tprivate _temperature: number | undefined,\\n\\t\\tprivate _topP: number | undefined,\\n\\t\\tprivate _serviceTier: ServiceTier | undefined,\\n\\t\\tprivate _model: AiModelId | undefined,\\n\\t\\tprivate _firstThink: boolean,\\n\\t) {\\n\\t\\tconst self = this;\\n\\t\\tthis.generator = (async function* () {\\n\\t\\t\\tyield* await executeLlmCall(\\n\\t\\t\\t\\tself.aiClient,\\n\\t\\t\\t\\t_model,\\n\\t\\t\\t\\tself.genericMessages,\\n\\t\\t\\t\\tfalse,\\n\\t\\t\\t\\tself.promptName,\\n\\t\\t\\t\\t_temperature,\\n\\t\\t\\t\\t_topP,\\n\\t\\t\\t\\t_serviceTier,\\n\\t\\t\\t\\tcallingCodeLine,\\n\\t\\t\\t\\tundefined,\\n\\t\\t\\t\\tself._tools,\\n\\t\\t\\t)\\n\\t\\t})()\\n\\t}\\n\\n\\tpublic name(name: string): this {\\n\\t\\tthis.promptName = name;\\n\\t\\treturn this;\\n\\t}\\n\\n\\tpublic model(model: AiModelId): this {\\n\\t\\tthis._model = model;\\n\\t\\treturn this;\\n\\t}\\n\\n\\t/**\\n\\t * If requesting data, the model is asked to write out a\\n\\t * reasoning, step by step, before any of the requested\\n\\t * JSON is outputted.\\n\\t */\\n\\tpublic firstThink(firstThink: boolean = true) {\\n\\t\\tthis._firstThink = firstThink\\n\\t\\treturn this\\n\\t}\\n\\n\\t/**\\n\\t * What sampling temperature to use, between 0 and 2.\\n\\t * Higher values like 0.8 will make the output more random,\\n\\t * while lower values like 0.2 will make it more focused\\n\\t * and deterministic.\\n\\t * We generally recommend altering this or <b>topP</b> but not both.\\n\\t */\\n\\tpublic temperature(temperature: number): this {\\n\\t\\tthis._temperature = temperature;\\n\\t\\treturn this;\\n\\t}\\n\\n\\t/**\\n\\t * An alternative to sampling with temperature, called nucleus\\n\\t * sampling, where the model considers the results of the\\n\\t * tokens with top_p probability mass.\\n\\t * So 0.1 means only the tokens comprising the top 10%\\n\\t * probability mass are considered.\\n\\t *\\n\\t * We generally recommend altering this or <b>temperature</b>\\n\\t * but not both.\\n\\t */\\n\\tpublic topP(topP: number): this {\\n\\t\\tthis._topP = topP;\\n\\t\\treturn this;\\n\\t}\\n\\n\\t/**\\n\\t * Using the flex tier will make your prompts run significantly slower in exchange for a discount.\\n\\t */\\n\\tpublic flex(useFlexTier = true) {\\n\\t\\tthis._serviceTier = useFlexTier ? 'flex' : undefined\\n\\t\\treturn this\\n\\t}\\n\\n\\t// Getters for getting the result\\n\\tpublic get result() {\\n\\t\\treturn this\\n\\t}\\n\\n\\tpublic get messages(): Message[] {\\n\\t\\treturn this.genericMessages\\n\\t\\t\\t.map(m => ({[m.role]: m.content} as unknown as Message))\\n\\t}\\n\\n\\tprivate get json() {\\n\\t\\treturn false\\n\\t}\\n\\n\\tprivate get genericMessages() {\\n\\t\\tconst prompt = this.promptSupplier(this.promptSupplierArgs, TypeSpecMarker)\\n\\t\\tconst {messages: genericPrompt, typeSpecIndex} = toGenericPrompt(prompt, TypeSpecMarker)\\n\\t\\tif (!this.json) {\\n\\t\\t\\treturn genericPrompt\\n\\t\\t}\\n\\n\\t\\tconst jsonSpecMessage = {\\n\\t\\t\\trole: 'user' as const,\\n\\t\\t\\tcontent: jsonSpec(this._model, this.json, this._firstThink)\\n\\t\\t}\\n\\n\\t\\t// If TypeSpecMessage was found, insert at that position\\n\\t\\tif (typeSpecIndex !== undefined) {\\n\\t\\t\\treturn [\\n\\t\\t\\t\\t...genericPrompt.slice(0, typeSpecIndex),\\n\\t\\t\\t\\tjsonSpecMessage,\\n\\t\\t\\t\\t...genericPrompt.slice(typeSpecIndex)\\n\\t\\t\\t]\\n\\t\\t}\\n\\n\\t\\t// Otherwise, place at the end of the message array\\n\\t\\treturn [\\n\\t\\t\\t...genericPrompt,\\n\\t\\t\\tjsonSpecMessage\\n\\t\\t];\\n\\t}\\n\\n\\t// Methods for the generator interface\\n\\n\\tnext(...[value]: [] | [any]): Promise<IteratorResult<string, any>> {\\n\\t\\treturn this.generator.next(value)\\n\\t}\\n\\n\\treturn(value: any): Promise<IteratorResult<string, any>> {\\n\\t\\treturn this.generator.return(value)\\n\\t}\\n\\n\\tthrow(e: any): Promise<IteratorResult<string, any>> {\\n\\t\\treturn this.generator.throw(e)\\n\\t}\\n\\n\\t[Symbol.asyncIterator](): AsyncGenerator<string, any, any> {\\n\\t\\treturn this\\n\\t}\\n\\n\\t// Methods for the Promise interface\\n\\n\\tasync then<TResult1 = string, TResult2 = never>(\\n\\t\\tonfulfilled?: ((value: string) => TResult1 | PromiseLike<TResult1>) | null | undefined,\\n\\t\\tonrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined\\n\\t): Promise<TResult1 | TResult2> {\\n\\t\\ttry {\\n\\t\\t\\tconst result = await this.getResponseAsString()\\n\\t\\t\\treturn nonNullish(onfulfilled)\\n\\t\\t\\t\\t? await onfulfilled(result)\\n\\t\\t\\t\\t: result as TResult1\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn await onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tasync catch<TResult = never>(\\n\\t\\tonrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined\\n\\t): Promise<string | TResult> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponseAsString()\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\tasync finally(onfinally?: (() => void) | null | undefined): Promise<string> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponseAsString()\\n\\t\\t} finally {\\n\\t\\t\\tonfinally?.()\\n\\t\\t}\\n\\t}\\n\\n\\tget [Symbol.toStringTag](): string {\\n\\t\\treturn 'BasicPrompt'\\n\\t}\\n\\n\\t// Other methods\\n\\tpublic get<Json extends AnyJson = AnyJson>(type: (value: EmptyTypeSpec<unknown>) => TypeSpec<Json>) {\\n\\t\\treturn new JsonPrompt<PSArgs, Json>(\\n\\t\\t\\tthis.aiClient,\\n\\t\\t\\tthis.promptSupplier,\\n\\t\\t\\tthis.promptSupplierArgs,\\n\\t\\t\\ttype,\\n\\t\\t\\tgetCallerFileNameAndLineNumber(),\\n\\t\\t\\tthis.promptName,\\n\\t\\t\\tthis._temperature,\\n\\t\\t\\tthis._topP,\\n\\t\\t\\tthis._serviceTier,\\n\\t\\t\\tthis._model,\\n\\t\\t\\tthis._firstThink,\\n\\t\\t\\tthis._tools,\\n\\t\\t)\\n\\t}\\n\\n\\tpublic getBoolean() {\\n\\t\\treturn this.get(o => o.boolean())\\n\\t}\\n\\n\\tpublic getString() {\\n\\t\\treturn this.get(o => o.string())\\n\\t}\\n\\n\\tpublic getNumber() {\\n\\t\\treturn this.get(o => o.number())\\n\\t}\\n\\n\\tpublic getObject<T_obj extends {}>(properties: (arg: TypeMemberSpec<{}>) => TypeMemberSpec<T_obj>) {\\n\\t\\treturn this.get(o => o\\n\\t\\t\\t.object(properties)\\n\\t\\t)\\n\\t}\\n\\n\\tpublic getArray<T_arr extends AnyJson>(element: (arg: EmptyTypeSpec<unknown>) => TypeSpec<T_arr>): JsonArrayPrompt<PSArgs, T_arr> {\\n\\t\\treturn new JsonArrayPrompt<PSArgs, T_arr>(\\n\\t\\t\\tthis.aiClient,\\n\\t\\t\\tthis.promptSupplier,\\n\\t\\t\\tthis.promptSupplierArgs,\\n\\t\\t\\to => o\\n\\t\\t\\t\\t.array<T_arr>(element),\\n\\t\\t\\tthis.callingCodeLine,\\n\\t\\t\\tthis.promptName,\\n\\t\\t\\tthis._temperature,\\n\\t\\t\\tthis._topP,\\n\\t\\t\\tthis._serviceTier,\\n\\t\\t\\tthis._model,\\n\\t\\t\\tthis._firstThink,\\n\\t\\t\\tthis._tools,\\n\\t\\t)\\n\\t}\\n\\n\\tpublic getAny() {\\n\\t\\treturn this.get(o => o.any())\\n\\t}\\n\\n\\tpublic tools(tools: ToolDefinition[]): this\\n\\tpublic tools(...tools: (ToolDefinition | undefined)[]): this\\n\\tpublic tools(...args: [ToolDefinition[]] | (ToolDefinition | undefined)[]): this {\\n\\t\\tconst normalizedTools = Array.isArray(args[0]) && args.length === 1\\n\\t\\t\\t? args[0].filter(tool => tool !== undefined)\\n\\t\\t\\t: args.filter(tool => tool !== undefined) as ToolDefinition[]\\n\\t\\tthis._tools = normalizedTools\\n\\t\\treturn this\\n\\t}\\n\\n\\tprivate async getResponseAsString(): Promise<string> {\\n\\t\\tlet result = ''\\n\\t\\tfor await (const chunk of this) {\\n\\t\\t\\tresult += chunk\\n\\t\\t}\\n\\t\\treturn result\\n\\t}\\n}\\n\\ntype JsonObject = {[key: string]: AnyJson}\\n\\ntype JsonArray = AnyJson[]\\n\\ntype AnyJson = string | null | boolean | number | JsonArray | JsonObject\\n\\ntype ToolFunction<T = any> = (args: T) => Promise<string> | string\\n\\ntype ToolDefinition<T = any> = {\\n\\tname: string\\n\\tdescription: string\\n\\tparameters: TypeSpec<T>\\n\\tfunction: ToolFunction<T>\\n}\\n\\nfunction typeSpecToJsonSchema(typeSpec: TypeSpec<any>): any {\\n\\tconst convertType = (type: any): any => {\\n\\t\\tif (Array.isArray(type)) {\\n\\t\\t\\t// Union types - for simplicity, take the first type\\n\\t\\t\\treturn convertType(type[0])\\n\\t\\t}\\n\\t\\t\\n\\t\\tswitch (type.type) {\\n\\t\\t\\tcase \\\"object\\\": {\\n\\t\\t\\t\\tconst properties: any = {}\\n\\t\\t\\t\\tconst required: string[] = []\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tfor (const [key, propSpec] of Object.entries(type.props)) {\\n\\t\\t\\t\\t\\tproperties[key] = convertType((propSpec as any).type)\\n\\t\\t\\t\\t\\tif (!(propSpec as any).optional) {\\n\\t\\t\\t\\t\\t\\trequired.push(key)\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\n\\t\\t\\t\\treturn {\\n\\t\\t\\t\\t\\ttype: \\\"object\\\",\\n\\t\\t\\t\\t\\tproperties,\\n\\t\\t\\t\\t\\trequired: required.length > 0 ? required : undefined\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tcase \\\"array\\\": {\\n\\t\\t\\t\\treturn {\\n\\t\\t\\t\\t\\ttype: \\\"array\\\",\\n\\t\\t\\t\\t\\titems: convertType(type.elementType)\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tcase \\\"string\\\": {\\n\\t\\t\\t\\treturn { type: \\\"string\\\" }\\n\\t\\t\\t}\\n\\t\\t\\tcase \\\"number\\\": {\\n\\t\\t\\t\\treturn { type: \\\"number\\\" }\\n\\t\\t\\t}\\n\\t\\t\\tcase \\\"boolean\\\": {\\n\\t\\t\\t\\treturn { type: \\\"boolean\\\" }\\n\\t\\t\\t}\\n\\t\\t\\tcase \\\"null\\\": {\\n\\t\\t\\t\\treturn { type: \\\"null\\\" }\\n\\t\\t\\t}\\n\\t\\t\\tcase \\\"undefined\\\": {\\n\\t\\t\\t\\treturn { type: \\\"null\\\" }\\n\\t\\t\\t}\\n\\t\\t\\tcase \\\"constant\\\": {\\n\\t\\t\\t\\treturn { const: type.value }\\n\\t\\t\\t}\\n\\t\\t\\tdefault: {\\n\\t\\t\\t\\treturn { type: \\\"string\\\" } // fallback\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\t\\n\\treturn convertType(typeSpec['type'])\\n}\\n\\nexport function defineTool<T>(config: {\\n\\tname: string\\n\\tdescription: string\\n\\tparameters: (spec: EmptyTypeSpec<unknown>) => TypeSpec<T>\\n\\tfunction: ToolFunction<T>\\n}): ToolDefinition<T> {\\n\\treturn {\\n\\t\\tname: config.name,\\n\\t\\tdescription: config.description,\\n\\t\\tparameters: config.parameters(specType(undefined as unknown)),\\n\\t\\tfunction: config.function\\n\\t}\\n}\\n\\nclass JsonPrompt<PSArgs, Json extends AnyJson = AnyJson> extends StreamedJsonChildElement<Json> implements AsyncGenerator<AnyJson>, Promise<Json> {\\n\\tprotected readonly stringGenerator: AsyncGenerator<string>\\n\\tprotected readonly partialJsonGenerator: AsyncGenerator<AnyJson>\\n\\tprotected _tools?: ToolDefinition[];\\n\\n\\tconstructor(\\n\\t\\tprotected aiClient: AIClient,\\n\\t\\tprotected promptSupplier: (args: PSArgs, typeSpecMessage?: TypeSpecMessage) => Prompt,\\n\\t\\tprotected promptSupplierArgs: PSArgs,\\n\\t\\tprotected jsonTypeSupplier: ((value: EmptyTypeSpec<unknown>) => TypeSpec<Json>) | undefined,\\n\\t\\tprotected callingCodeLine: CodeLine,\\n\\t\\tprotected promptName: string | undefined,\\n\\t\\tprotected _temperature: number | undefined,\\n\\t\\tprotected _topP: number | undefined,\\n\\t\\tprotected _serviceTier: ServiceTier | undefined,\\n\\t\\tprotected _model: AiModelId | undefined,\\n\\t\\tprotected _firstThink: boolean,\\n\\t\\ttools?: ToolDefinition[],\\n\\t) {\\n\\t\\tsuper()\\n\\t\\tconst thiss = this\\n\\t\\tthis._tools = tools\\n\\t\\t\\n\\t\\t// Create lazy generator that will only execute when accessed\\n\\t\\tconst lazyGenerator = (async function*() {\\n\\t\\t\\tyield* await executeLlmCall(\\n\\t\\t\\t\\taiClient,\\n\\t\\t\\t\\t_model,\\n\\t\\t\\t\\tthiss.genericMessages,\\n\\t\\t\\t\\tthiss.json,\\n\\t\\t\\t\\tpromptName,\\n\\t\\t\\t\\t_temperature,\\n\\t\\t\\t\\t_topP,\\n\\t\\t\\t\\t_serviceTier,\\n\\t\\t\\t\\tcallingCodeLine,\\n\\t\\t\\t\\tjsonTypeSupplier,\\n\\t\\t\\t\\tthiss._tools,\\n\\t\\t\\t)\\n\\t\\t})\\n\\t\\t\\n\\t\\t// Initialize generators lazily\\n\\t\\tlet flux: Flux<string> | undefined\\n\\t\\tlet jsonTokenFlux: Flux<any> | undefined\\n\\t\\tlet streamingJsonRootElement: any | undefined\\n\\t\\t\\n\\t\\tconst getFlux = () => {\\n\\t\\t\\tif (!flux) {\\n\\t\\t\\t\\tflux = Flux.fromGenerator(lazyGenerator())\\n\\t\\t\\t\\tjsonTokenFlux = new JsonTokenProcessor().processDataBuffer(flux)\\n\\t\\t\\t\\tstreamingJsonRootElement = new StreamedJsonParser().parse(jsonTokenFlux!)\\n\\t\\t\\t\\tif (jsonTypeSupplier !== undefined) {\\n\\t\\t\\t\\t\\tstreamingJsonRootElement\\n\\t\\t\\t\\t\\t\\t.onProperty(\\\"result\\\", (result: any) => result\\n\\t\\t\\t\\t\\t\\t\\t.onEachExcerpt((e: any) => {\\n\\t\\t\\t\\t\\t\\t\\t\\tif (e.token !== undefined) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tthis.push(e)\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\t\\t)\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tstreamingJsonRootElement\\n\\t\\t\\t\\t\\t\\t.onEachExcerpt((e: any) => {\\n\\t\\t\\t\\t\\t\\t\\tif (e.token !== undefined) {\\n\\t\\t\\t\\t\\t\\t\\t\\tthis.push(e)\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\treturn { flux: flux!, jsonTokenFlux: jsonTokenFlux!, streamingJsonRootElement: streamingJsonRootElement! }\\n\\t\\t}\\n\\t\\t\\n\\t\\tthis.stringGenerator = (async function*() {\\n\\t\\t\\tconst { jsonTokenFlux, streamingJsonRootElement } = getFlux()\\n\\t\\t\\tfor await (const jsonExcerpt of jsonTokenFlux) {\\n\\t\\t\\t\\tif (jsonExcerpt.token !== undefined) {\\n\\t\\t\\t\\t\\tstreamingJsonRootElement.push(jsonExcerpt)\\n\\t\\t\\t\\t} else if (jsonExcerpt.source !== undefined) {\\n\\t\\t\\t\\t\\tyield jsonExcerpt.source\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t})()\\n\\t\\tthis.partialJsonGenerator = (async function*() {\\n\\t\\t\\tlet accumulatedJson = ''\\n\\t\\t\\tfor await (const chunk of thiss.stringGenerator) {\\n\\t\\t\\t\\taccumulatedJson += chunk\\n\\t\\t\\t\\tconst partialJson = parsePartialJson<any>(accumulatedJson)\\n\\t\\t\\t\\tyield jsonTypeSupplier !== undefined\\n\\t\\t\\t\\t\\t? (partialJson as any)?.['result']\\n\\t\\t\\t\\t\\t: partialJson\\n\\t\\t\\t}\\n\\t\\t})()\\n\\t}\\n\\n\\t// Methods for the generator interface\\n\\n\\tnext(...[value]: [] | [any]): Promise<IteratorResult<AnyJson, any>> {\\n\\t\\treturn this.partialJsonGenerator.next(value)\\n\\t}\\n\\n\\treturn(value: any): Promise<IteratorResult<AnyJson, any>> {\\n\\t\\treturn this.partialJsonGenerator.return(value)\\n\\t}\\n\\n\\tthrow(e: any): Promise<IteratorResult<AnyJson, any>> {\\n\\t\\treturn this.partialJsonGenerator.throw(e)\\n\\t}\\n\\n\\t[Symbol.asyncIterator](): AsyncGenerator<AnyJson, any, any> {\\n\\t\\treturn this.partialJsonGenerator\\n\\t}\\n\\n\\t// Methods for the Promise interface\\n\\n\\toverride async then<TResult1 = Json, TResult2 = never>(\\n\\t\\tonfulfilled?: ((value: Json) => TResult1 | PromiseLike<TResult1>) | null | undefined,\\n\\t\\tonrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined\\n\\t): Promise<TResult1 | TResult2> {\\n\\t\\ttry {\\n\\t\\t\\tconst result = await this.getResponse()\\n\\t\\t\\treturn nonNullish(onfulfilled)\\n\\t\\t\\t\\t? await onfulfilled(result)\\n\\t\\t\\t\\t: result as unknown as TResult1\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn await onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\toverride async catch<TResult = never>(\\n\\t\\tonrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined\\n\\t): Promise<Json | TResult> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponse()\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\toverride async finally(onfinally?: (() => void) | null | undefined): Promise<Json> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponse()\\n\\t\\t} finally {\\n\\t\\t\\tonfinally?.()\\n\\t\\t}\\n\\t}\\n\\n\\toverride get [Symbol.toStringTag](): string {\\n\\t\\treturn 'JsonPrompt'\\n\\t}\\n\\n\\t// Other methods\\n\\n\\tpublic name(name: string): this {\\n\\t\\tthis.promptName = name;\\n\\t\\treturn this;\\n\\t}\\n\\n\\tpublic model(model: AiModelId): this {\\n\\t\\tthis._model = model;\\n\\t\\treturn this;\\n\\t}\\n\\n\\t/**\\n\\t * If requesting data, the model is asked to write out a\\n\\t * reasoning, step by step, before any of the requested\\n\\t * JSON is outputted.\\n\\t */\\n\\tpublic firstThink(firstThink: boolean = true) {\\n\\t\\tthis._firstThink = firstThink\\n\\t\\treturn this\\n\\t}\\n\\n\\t/**\\n\\t * What sampling temperature to use, between 0 and 2.\\n\\t * Higher values like 0.8 will make the output more random,\\n\\t * while lower values like 0.2 will make it more focused\\n\\t * and deterministic.\\n\\t * We generally recommend altering this or <b>topP</b> but not both.\\n\\t */\\n\\tpublic temperature(temperature: number): this {\\n\\t\\tthis._temperature = temperature;\\n\\t\\treturn this;\\n\\t}\\n\\n\\t/**\\n\\t * An alternative to sampling with temperature, called nucleus\\n\\t * sampling, where the model considers the results of the\\n\\t * tokens with top_p probability mass.\\n\\t * So 0.1 means only the tokens comprising the top 10%\\n\\t * probability mass are considered.\\n\\t *\\n\\t * We generally recommend altering this or <b>temperature</b>\\n\\t * but not both.\\n\\t */\\n\\tpublic topP(topP: number): this {\\n\\t\\tthis._topP = topP;\\n\\t\\treturn this;\\n\\t}\\n\\n\\t/**\\n\\t * Using the flex tier will make your prompts run significantly slower in exchange for a discount.\\n\\t */\\n\\tpublic flex(useFlexTier = true) {\\n\\t\\tthis._serviceTier = useFlexTier ? 'flex' : undefined\\n\\t\\treturn this\\n\\t}\\n\\n\\t// Getters for getting the result\\n\\tpublic get result() {\\n\\t\\treturn this\\n\\t}\\n\\n\\tpublic get messages(): Message[] {\\n\\t\\treturn this.genericMessages\\n\\t\\t\\t.map(m => ({[m.role]: m.content} as unknown as Message))\\n\\t}\\n\\n\\tprivate get genericMessages() {\\n\\t\\tconst prompt = this.promptSupplier(this.promptSupplierArgs, TypeSpecMarker)\\n\\t\\tconst {messages: genericPrompt, typeSpecIndex} = toGenericPrompt(prompt, TypeSpecMarker)\\n\\t\\tif (!this.json) {\\n\\t\\t\\treturn genericPrompt\\n\\t\\t}\\n\\n\\t\\tconst jsonSpecMessage = {\\n\\t\\t\\trole: 'user' as const,\\n\\t\\t\\tcontent: jsonSpec(this._model, this.json, this._firstThink)\\n\\t\\t}\\n\\n\\t\\t// If TypeSpecMessage was found, insert at that position\\n\\t\\tif (typeSpecIndex !== undefined) {\\n\\t\\t\\treturn [\\n\\t\\t\\t\\t...genericPrompt.slice(0, typeSpecIndex),\\n\\t\\t\\t\\tjsonSpecMessage,\\n\\t\\t\\t\\t...genericPrompt.slice(typeSpecIndex)\\n\\t\\t\\t]\\n\\t\\t}\\n\\n\\t\\t// Otherwise, place at the end of the message array\\n\\t\\treturn [\\n\\t\\t\\t...genericPrompt,\\n\\t\\t\\tjsonSpecMessage\\n\\t\\t];\\n\\t}\\n\\n\\tprivate get json() {\\n\\t\\treturn this.jsonTypeSupplier !== undefined\\n\\t\\t\\t? this.jsonTypeSupplier(specType(undefined as unknown))\\n\\t\\t\\t: true\\n\\t}\\n\\n\\tprotected async getResponse(): Promise<Json> {\\n\\t\\tconst stringResult = await this.getResponseAsString()\\n\\t\\tconst jsonTypeSupplier = this.jsonTypeSupplier\\n\\t\\tconst uncheckedPackedResult = parseJsonWithUsefulError(stringResult)\\n\\t\\tconst uncheckedResult = jsonTypeSupplier !== undefined\\n\\t\\t\\t? uncheckedPackedResult?.result\\n\\t\\t\\t: uncheckedPackedResult\\n\\t\\t\\n\\t\\t// Type checking is now handled in the retry loop, so we can trust the result\\n\\t\\treturn uncheckedResult as Json\\n\\t}\\n\\n\\tprivate _responseAsStringPromise?: Promise<string>\\n\\n\\tprotected getResponseAsString(): Promise<string> {\\n\\t\\tif (this._responseAsStringPromise === undefined) {\\n\\t\\t\\tthis._responseAsStringPromise = this._getResponseAsString()\\n\\t\\t}\\n\\t\\treturn this._responseAsStringPromise\\n\\t}\\n\\n\\tpublic tools(tools: ToolDefinition[]): this\\n\\tpublic tools(...tools: (ToolDefinition | undefined)[]): this\\n\\tpublic tools(...args: [ToolDefinition[]] | (ToolDefinition | undefined)[]): this {\\n\\t\\tconst normalizedTools = Array.isArray(args[0]) && args.length === 1\\n\\t\\t\\t? args[0].filter(tool => tool !== undefined)\\n\\t\\t\\t: args.filter(tool => tool !== undefined) as ToolDefinition[]\\n\\t\\tthis._tools = normalizedTools\\n\\t\\treturn this\\n\\t}\\n\\n\\tprotected async _getResponseAsString(): Promise<string> {\\n\\t\\tlet result = ''\\n\\t\\tfor await (const chunk of this.stringGenerator) {\\n\\t\\t\\tresult += chunk\\n\\t\\t}\\n\\t\\treturn result\\n\\t}\\n}\\n\\nexport class JsonArrayPrompt<PSArgs, T_arr extends AnyJson = AnyJson> extends JsonPrompt<PSArgs, T_arr[]> /*implements AsyncGenerator<T_arr>, Promise<T_arr[]>*/ {\\n\\tprotected readonly arrayElementGenerator: Flux<T_arr>\\n\\tconstructor(\\n\\t\\taiClient: AIClient,\\n\\t\\tpromptSupplier: (args: PSArgs, typeSpecMessage?: TypeSpecMessage) => Prompt,\\n\\t\\tpromptSupplierArgs: PSArgs,\\n\\t\\tjsonTypeSupplier: ((value: EmptyTypeSpec<unknown>) => TypeSpec<T_arr[]>) | undefined,\\n\\t\\tcallingCodeLine: CodeLine,\\n\\t\\tpromptName: string | undefined,\\n\\t\\t_temperature: number | undefined,\\n\\t\\t_topP: number | undefined,\\n\\t\\t_serviceTier: ServiceTier | undefined,\\n\\t\\t_model: AiModelId | undefined,\\n\\t\\t_firstThink: boolean,\\n\\t\\ttools?: ToolDefinition[],\\n\\t) {\\n\\t\\tsuper(\\n\\t\\t\\taiClient,\\n\\t\\t\\tpromptSupplier,\\n\\t\\t\\tpromptSupplierArgs,\\n\\t\\t\\tjsonTypeSupplier,\\n\\t\\t\\tcallingCodeLine,\\n\\t\\t\\tpromptName,\\n\\t\\t\\t_temperature,\\n\\t\\t\\t_topP,\\n\\t\\t\\t_serviceTier,\\n\\t\\t\\t_model,\\n\\t\\t\\t_firstThink,\\n\\t\\t\\ttools,\\n\\t\\t)\\n\\t\\tconst thiss = this\\n\\t\\tthis.arrayElementGenerator = Flux.create<T_arr>(\\n\\t\\t\\tasync (push, complete) => {\\n\\t\\t\\t\\tawait thiss\\n\\t\\t\\t\\t\\t.onElement(async element => {\\n\\t\\t\\t\\t\\t\\tpush(await element)\\n\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\tcomplete()\\n\\t\\t\\t}\\n\\t\\t)\\n\\t}\\n\\n\\t// Methods for the generator interface\\n\\n\\toverride next(...[value]: [] | [any]): Promise<IteratorResult<T_arr>> {\\n\\t\\treturn this.arrayElementGenerator.next(value)\\n\\t}\\n\\n\\toverride return(value: any): Promise<IteratorResult<T_arr, any>> {\\n\\t\\treturn this.arrayElementGenerator.return(value)\\n\\t}\\n\\n\\toverride throw(e: any): Promise<IteratorResult<T_arr, any>> {\\n\\t\\treturn this.arrayElementGenerator.throw(e)\\n\\t}\\n\\n\\toverride [Symbol.asyncIterator](): AsyncGenerator<T_arr, any, any> {\\n\\t\\treturn this.arrayElementGenerator\\n\\t}\\n\\n\\t// Methods for the Promise interface\\n\\n\\toverride async then<TResult1 = T_arr[], TResult2 = never>(\\n\\t\\tonfulfilled?: ((value: T_arr[]) => TResult1 | PromiseLike<TResult1>) | null | undefined,\\n\\t\\tonrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined\\n\\t): Promise<TResult1 | TResult2> {\\n\\t\\ttry {\\n\\t\\t\\tconst result = await this.getResponse()\\n\\t\\t\\treturn nonNullish(onfulfilled)\\n\\t\\t\\t\\t? await onfulfilled(result)\\n\\t\\t\\t\\t: result as unknown as TResult1\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn await onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\toverride async catch<TResult = never>(\\n\\t\\tonrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined\\n\\t): Promise<T_arr[] | TResult> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponse()\\n\\t\\t} catch (e) {\\n\\t\\t\\tif (nonNullish(onrejected)) {\\n\\t\\t\\t\\treturn onrejected(e)\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tthrow e\\n\\t\\t\\t}\\n\\t\\t}\\n\\t}\\n\\n\\toverride async finally(onfinally?: (() => void) | null | undefined): Promise<T_arr[]> {\\n\\t\\ttry {\\n\\t\\t\\treturn await this.getResponse()\\n\\t\\t} finally {\\n\\t\\t\\tonfinally?.()\\n\\t\\t}\\n\\t}\\n\\n\\toverride get [Symbol.toStringTag](): string {\\n\\t\\treturn 'JsonArrayPrompt'\\n\\t}\\n\\n\\t// Other methods\\n\\n\\t// protected override async getResponse(): Promise<T_arr[]> {\\n\\t// \\tconst array: T_arr[] = []\\n\\t// \\tfor await (const element of this.arrayElementGenerator) {\\n\\t// \\t\\tarray.push(element)\\n\\t// \\t}\\n\\t// \\treturn array\\n\\t// }\\n}\\n\\nfunction pickModel(modelId?: AiModelId): AiModelId {\\n\\treturn modelId ?? 'gpt-4o'\\n}\\n\\nfunction toGenericPrompt(prompt: string | Message | (Message | undefined)[], typeSpecMessage?: TypeSpecMessage): {messages: GenericPrompt, typeSpecIndex?: number} {\\n\\tconst toOpenAiMessage = (msg: Message | undefined): PromptMessage | null => {\\n\\t\\tif (msg === undefined) {\\n\\t\\t\\treturn null\\n\\t\\t}\\n\\t\\tif ('typeSpec' in msg) {\\n\\t\\t\\treturn null // TypeSpecMessage is just a placeholder\\n\\t\\t}\\n\\t\\treturn {\\n\\t\\t\\trole: msg.user !== undefined ? 'user' : (msg.system !== undefined ? 'system' : 'assistant'),\\n\\t\\t\\tcontent: requireDefined(msg.user ?? msg.system ?? msg.assistant),\\n\\t\\t}\\n\\t}\\n\\t\\n\\tif (typeof prompt === 'string') {\\n\\t\\treturn {messages: [{role: 'user' as const, content: prompt}]}\\n\\t} else if (!Array.isArray(prompt)) {\\n\\t\\tconst message = toOpenAiMessage(prompt)\\n\\t\\treturn {messages: message ? [message] : []}\\n\\t} else {\\n\\t\\tconst messages: PromptMessage[] = []\\n\\t\\tlet typeSpecIndex: number | undefined\\n\\t\\t\\n\\t\\tfor (let i = 0; i < prompt.length; i++) {\\n\\t\\t\\tconst msg = prompt[i]!\\n\\t\\t\\tif ('typeSpec' in msg) {\\n\\t\\t\\t\\ttypeSpecIndex = messages.length // Position where TypeSpec should be inserted\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tconst message = toOpenAiMessage(msg)\\n\\t\\t\\t\\tif (message) {\\n\\t\\t\\t\\t\\tmessages.push(message)\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t\\n\\t\\t// If typeSpecMessage was passed as parameter and no TypeSpecMessage found in array, use default behavior\\n\\t\\tif (typeSpecMessage && typeSpecIndex === undefined) {\\n\\t\\t\\t// typeSpecIndex remains undefined, will use default logic\\n\\t\\t}\\n\\t\\t\\n\\t\\treturn {messages, typeSpecIndex}\\n\\t}\\n}\\n\\nasync function* executeLlmCall(\\n\\taiClient: AIClient,\\n\\tmodel: AiModelId | undefined,\\n\\tgenericPromptWithJsonSpec: GenericPrompt,\\n\\tjson: boolean | TypeSpec<any>,\\n\\tpromptName: string | undefined,\\n\\ttemperature: number | undefined,\\n\\ttopP: number | undefined,\\n\\tserviceTier: ServiceTier = 'normal',\\n\\tcallingCodeLine: CodeLine,\\n\\tjsonTypeSupplier?: ((value: EmptyTypeSpec<unknown>) => TypeSpec<any>) | undefined,\\n\\ttools?: ToolDefinition[],\\n) {\\n\\tconst convSavePromises = new Map<string, {promise: Promise<void>, chunk?: string}>()\\n\\ttry {\\n\\t\\t// Find the relevant call in the stack trace (we need to skip internal calls)\\n\\t\\t// Typically this would be the first line after the executeLlmCall and other internal functions\\n\\t\\tconst {\\n\\t\\t\\tfileName: promptFilename,\\n\\t\\t\\tlineNumber: promptLineNumber,\\n\\t\\t} = callingCodeLine\\n\\n\\t\\t// Check if multiple promptLineNumbers exist for this filename\\n\\t\\tif (promptFilename && promptLineNumber !== undefined) {\\n\\t\\t\\tconst matchingPrompts = Array.from(promptMappings.keys())\\n\\t\\t\\t\\t.filter(key => key.startsWith(`${promptFilename}:`))\\n\\t\\t\\t\\t.map(key => parseInt(key.split(':')![1]!, 10));\\n\\n\\t\\t\\t// If there are multiple prompts for the same file, throw an error\\n\\t\\t\\tif (matchingPrompts.length > 1 && !promptName) {\\n\\t\\t\\t\\tthrow new Error(`Multiple prompts found in ${promptFilename}. Please specify a name using .name() method.`);\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\tconst promptProfile = {id: promptName, callingCodeLine}\\n\\n\\t\\t// Create a unique conversation ID\\n\\t\\tconst conversationUuid = aiClient.conversation?.uuid ?? randomUuid()\\n\\n\\t\\tconst saveLoop: {\\n\\t\\t\\tcurrentSave?: {\\n\\t\\t\\t\\tuuid: string\\n\\t\\t\\t\\tcallback: () => Promise<void>\\n\\t\\t\\t}\\n\\t\\t\\tsave?: {\\n\\t\\t\\t\\tuuid: string\\n\\t\\t\\t\\tcallback: () => Promise<void>\\n\\t\\t\\t}\\n\\t\\t} = {}\\n\\t\\tconst saveConv = (conversationData: ConversationData, chunk?: string) => {\\n\\t\\t\\tconst uuid = randomUuid()\\n\\t\\t\\tconst callback = async () => {\\n\\t\\t\\t\\tif (aiClient.conversation !== undefined) {\\n\\t\\t\\t\\t\\tfor (const newMsg of conversationData.messages) {\\n\\t\\t\\t\\t\\t\\tconst existing = aiClient.conversation.messages.find(m => m.messageUuid === newMsg.messageUuid)\\n\\t\\t\\t\\t\\t\\tif (existing !== undefined) {\\n\\t\\t\\t\\t\\t\\t\\tif (existing.role !== newMsg.role) {\\n\\t\\t\\t\\t\\t\\t\\t\\tthrow new Error('Illegal state')\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\texisting.content = newMsg.content\\n\\t\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\t\\taiClient.conversation.messages.push(newMsg)\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tsaveLoop.currentSave = saveLoop.save\\n\\t\\t\\t\\tsaveLoop.save = undefined\\n\\t\\t\\t\\tawait saveConversation(\\n\\t\\t\\t\\t\\tconversationData,\\n\\t\\t\\t\\t\\taiClient['apiKeyChain']!.promptgrid\\n\\t\\t\\t\\t)\\n\\t\\t\\t\\tawait new Promise(resolve => setTimeout(resolve, 100))\\n\\t\\t\\t\\tawait (saveLoop.save as (typeof saveLoop)['save'])?.callback()\\n\\t\\t\\t\\tsaveLoop.currentSave = undefined\\n\\t\\t\\t}\\n\\t\\t\\tif (saveLoop.save !== undefined) {\\n\\t\\t\\t\\tconvSavePromises.delete(saveLoop.save.uuid)\\n\\t\\t\\t}\\n\\t\\t\\tsaveLoop.save = {uuid, callback}\\n\\t\\t\\tif (saveLoop.currentSave === undefined) {\\n\\t\\t\\t\\tconvSavePromises.set(uuid, {chunk, promise: callback().then()})\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\tlet genericPromptWithJsonSpecAndConversationHistory = [\\n\\t\\t\\t...(aiClient.conversation?.messages ?? []),\\n\\t\\t\\t...genericPromptWithJsonSpec,\\n\\t\\t] as (PromptMessage & Partial<PromptMessageWithId>)[]\\n\\n\\t\\t// Send the conversation start and messages to PromptGrid\\n\\t\\tsaveConv({\\n\\t\\t\\tconversationUuid,\\n\\t\\t\\tprompt: promptProfile,\\n\\t\\t\\tmessages: genericPromptWithJsonSpecAndConversationHistory\\n\\t\\t\\t\\t.map(message => ({\\n\\t\\t\\t\\t\\tmessageUuid: message.messageUuid ?? randomUuid(),\\n\\t\\t\\t\\t\\trole: message.role,\\n\\t\\t\\t\\t\\tcontent: message.content || ''\\n\\t\\t\\t\\t})),\\n\\t\\t});\\n\\n\\t\\t// Now add an 'assistant' message that will be updated as the response streams in\\n\\t\\tlet responseMessageId = randomUuid()\\n\\t\\tsaveConv({\\n\\t\\t\\tconversationUuid,\\n\\t\\t\\tprompt: promptProfile,\\n\\t\\t\\tmessages: [\\n\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\tmessageUuid: responseMessageId,\\n\\t\\t\\t\\t\\trole: 'assistant',\\n\\t\\t\\t\\t\\tcontent: '' // Start with empty content that will be updated\\n\\t\\t\\t\\t}\\n\\t\\t\\t]\\n\\t\\t})\\n\\n\\t\\tlet incomplete = true\\n\\t\\tlet attempts = 1\\n\\t\\twhile (incomplete) {\\n\\t\\t\\ttry {\\n\\t\\t\\t\\tconst apiToken = requireThat(await aiClient['apiKeyChain']!.openai).canBeString().andNothingElse({errorMessage: 'No OpenAI access token set'})\\n\\t\\t\\t\\tconst openaiTools = tools?.map(tool => ({\\n\\t\\t\\t\\t\\ttype: 'function' as const,\\n\\t\\t\\t\\t\\tfunction: {\\n\\t\\t\\t\\t\\t\\tname: tool.name,\\n\\t\\t\\t\\t\\t\\tdescription: tool.description,\\n\\t\\t\\t\\t\\t\\tparameters: typeSpecToJsonSchema(tool.parameters)\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}))\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tconst flux = promptOpenai(\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\tmodel: pickModel(model),\\n\\t\\t\\t\\t\\t\\tprompt: genericPromptWithJsonSpecAndConversationHistory,\\n\\t\\t\\t\\t\\t\\tapiToken,\\n\\t\\t\\t\\t\\t\\ttemperature,\\n\\t\\t\\t\\t\\t\\ttopP,\\n\\t\\t\\t\\t\\t\\trequireJsonResponse: json !== false,\\n\\t\\t\\t\\t\\t\\tserviceTier,\\n\\t\\t\\t\\t\\t\\ttools: openaiTools,\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t)\\n\\n\\t\\t\\t\\tlet accumulatedContent = '';\\n\\t\\t\\t\\tlet toolCallsToExecute: ToolCall[] = []\\n\\n\\t\\t\\t\\tconst generator = flux\\n\\t\\t\\t\\t\\t.doOnEach(chunk => {\\n\\t\\t\\t\\t\\t\\tif (chunk.type === 'content') {\\n\\t\\t\\t\\t\\t\\t\\t// Regular text content\\n\\t\\t\\t\\t\\t\\t\\taccumulatedContent += chunk.content\\n\\n\\t\\t\\t\\t\\t\\t\\t// Send the updated content to PromptGrid\\n\\t\\t\\t\\t\\t\\t\\tsaveConv({\\n\\t\\t\\t\\t\\t\\t\\t\\tconversationUuid,\\n\\t\\t\\t\\t\\t\\t\\t\\tprompt: promptProfile,\\n\\t\\t\\t\\t\\t\\t\\t\\tmessages: [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tmessageUuid: responseMessageId,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\trole: 'assistant',\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tcontent: accumulatedContent,\\n\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t}, chunk.content)\\n\\t\\t\\t\\t\\t\\t} else if (chunk.type === 'toolCalls') {\\n\\t\\t\\t\\t\\t\\t\\t// Tool calls detected\\n\\t\\t\\t\\t\\t\\t\\ttoolCallsToExecute = chunk.toolCalls\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t})\\n\\n\\t\\t\\t\\t// Process all chunks first\\n\\t\\t\\t\\tfor await (const chunk of generator) {\\n\\t\\t\\t\\t\\tif (chunk.type === 'content') {\\n\\t\\t\\t\\t\\t\\tyield chunk.content\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t// If we have tool calls to execute, execute them and continue\\n\\t\\t\\t\\tif (toolCallsToExecute.length > 0 && tools) {\\n\\t\\t\\t\\t\\t// Execute each tool call\\n\\t\\t\\t\\t\\tconst toolResults = []\\n\\t\\t\\t\\t\\tfor (const toolCall of toolCallsToExecute) {\\n\\t\\t\\t\\t\\t\\tconst tool = tools.find(t => t.name === toolCall.name)\\n\\t\\t\\t\\t\\t\\tif (tool) {\\n\\t\\t\\t\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\t\\t\\t\\tconst args = toolCall.arguments.trim() === '' ? {} : JSON.parse(toolCall.arguments)\\n\\t\\t\\t\\t\\t\\t\\t\\tconst result = await tool.function(args)\\n\\t\\t\\t\\t\\t\\t\\t\\ttoolResults.push({\\n\\t\\t\\t\\t\\t\\t\\t\\t\\ttool_call_id: toolCall.id,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\trole: 'tool' as const,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tcontent: result\\n\\t\\t\\t\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\t\\t\\t} catch (error) {\\n\\t\\t\\t\\t\\t\\t\\t\\ttoolResults.push({\\n\\t\\t\\t\\t\\t\\t\\t\\t\\ttool_call_id: toolCall.id,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\trole: 'tool' as const,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tcontent: `Error: ${error instanceof Error ? error.message : String(error)}`\\n\\t\\t\\t\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\t\\ttoolResults.push({\\n\\t\\t\\t\\t\\t\\t\\t\\ttool_call_id: toolCall.id,\\n\\t\\t\\t\\t\\t\\t\\t\\trole: 'tool' as const,\\n\\t\\t\\t\\t\\t\\t\\t\\tcontent: `Error: Tool ${toolCall.name} not found`\\n\\t\\t\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t// Add tool call message to conversation\\n\\t\\t\\t\\t\\tconst toolCallMessage = {\\n\\t\\t\\t\\t\\t\\tmessageUuid: responseMessageId,\\n\\t\\t\\t\\t\\t\\trole: 'assistant' as const,\\n\\t\\t\\t\\t\\t\\tcontent: accumulatedContent || '',\\n\\t\\t\\t\\t\\t\\ttool_calls: toolCallsToExecute.map(tc => ({\\n\\t\\t\\t\\t\\t\\t\\tid: tc.id,\\n\\t\\t\\t\\t\\t\\t\\ttype: 'function' as const,\\n\\t\\t\\t\\t\\t\\t\\tfunction: {\\n\\t\\t\\t\\t\\t\\t\\t\\tname: tc.name,\\n\\t\\t\\t\\t\\t\\t\\t\\targuments: tc.arguments\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t}))\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t// Save tool calls as assistant message\\n\\t\\t\\t\\t\\tconst toolCallsDescription = toolCallMessage.tool_calls.map(tc => \\n\\t\\t\\t\\t\\t\\t`${tc.function.name}(${tc.function.arguments})`\\n\\t\\t\\t\\t\\t).join('\\\\n')\\n\\t\\t\\t\\t\\tsaveConv({\\n\\t\\t\\t\\t\\t\\tconversationUuid,\\n\\t\\t\\t\\t\\t\\tprompt: promptProfile,\\n\\t\\t\\t\\t\\t\\tmessages: [{\\n\\t\\t\\t\\t\\t\\t\\tmessageUuid: responseMessageId,\\n\\t\\t\\t\\t\\t\\t\\trole: 'assistant',\\n\\t\\t\\t\\t\\t\\t\\tcontent: toolCallMessage.content + (toolCallMessage.content ? '\\\\n\\\\n' : '') + toolCallsDescription\\n\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t// Save all tool responses as user messages in a single saveConv call\\n\\t\\t\\t\\t\\tconst toolResultMessages = toolResults.map(toolResult => {\\n\\t\\t\\t\\t\\t\\t// Find the corresponding tool call to get the tool name\\n\\t\\t\\t\\t\\t\\tconst toolName = toolCallsToExecute\\n\\t\\t\\t\\t\\t\\t\\t.find(tc => tc.id === toolResult.tool_call_id)!\\n\\t\\t\\t\\t\\t\\t\\t.name\\n\\t\\t\\t\\t\\t\\treturn {\\n\\t\\t\\t\\t\\t\\t\\tmessageUuid: randomUuid(),\\n\\t\\t\\t\\t\\t\\t\\trole: 'user' as const,\\n\\t\\t\\t\\t\\t\\t\\tcontent: `${toolName}: ${toolResult.content}`\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\tsaveConv({\\n\\t\\t\\t\\t\\t\\tconversationUuid,\\n\\t\\t\\t\\t\\t\\tprompt: promptProfile,\\n\\t\\t\\t\\t\\t\\tmessages: toolResultMessages\\n\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t// Add tool results to conversation history and make new request\\n\\t\\t\\t\\t\\tgenericPromptWithJsonSpecAndConversationHistory = [\\n\\t\\t\\t\\t\\t\\t...genericPromptWithJsonSpecAndConversationHistory,\\n\\t\\t\\t\\t\\t\\ttoolCallMessage,\\n\\t\\t\\t\\t\\t\\t...toolResults\\n\\t\\t\\t\\t\\t] as (PromptMessage & Partial<PromptMessageWithId>)[]\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t// Reset for next iteration\\n\\t\\t\\t\\t\\taccumulatedContent = ''\\n\\t\\t\\t\\t\\ttoolCallsToExecute = []\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t// Continue the loop to make another request\\n\\t\\t\\t\\t\\tresponseMessageId = randomUuid()\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t// If this is a JSON prompt with type validation, validate after completion\\n\\t\\t\\t\\tif (jsonTypeSupplier !== undefined) {\\n\\t\\t\\t\\t\\t// Then validate the complete JSON response\\n\\t\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\t\\tconst uncheckedPackedResult = parseJsonWithUsefulError(accumulatedContent)\\n\\t\\t\\t\\t\\t\\tconst uncheckedResult = uncheckedPackedResult?.result ?? uncheckedPackedResult\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t// Attempt type checking\\n\\t\\t\\t\\t\\t\\tassertType(\\n\\t\\t\\t\\t\\t\\t\\tuncheckedResult,\\n\\t\\t\\t\\t\\t\\t\\tjsonTypeSupplier(specType(uncheckedResult)),\\n\\t\\t\\t\\t\\t\\t\\t{juggleBetweenNullAndUndefined: true},\\n\\t\\t\\t\\t\\t\\t)\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t// If we get here, validation passed\\n\\t\\t\\t\\t\\t\\tincomplete = false\\n\\t\\t\\t\\t\\t} catch (typeError) {\\n\\t\\t\\t\\t\\t\\t// Try fallback validation (AI might have forgotten the wrapper)\\n\\t\\t\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\t\\t\\tconst uncheckedPackedResult = parseJsonWithUsefulError(accumulatedContent)\\n\\t\\t\\t\\t\\t\\t\\tassertType(\\n\\t\\t\\t\\t\\t\\t\\t\\tuncheckedPackedResult,\\n\\t\\t\\t\\t\\t\\t\\t\\tjsonTypeSupplier(specType(uncheckedPackedResult)),\\n\\t\\t\\t\\t\\t\\t\\t\\t{juggleBetweenNullAndUndefined: true},\\n\\t\\t\\t\\t\\t\\t\\t)\\n\\t\\t\\t\\t\\t\\t\\tincomplete = false\\n\\t\\t\\t\\t\\t\\t} catch (fallbackError) {\\n\\t\\t\\t\\t\\t\\t\\t// Type validation failed, treat as a retriable error\\n\\t\\t\\t\\t\\t\\t\\tconst errorMessage = typeError instanceof Error ? typeError.message : String(typeError)\\n\\t\\t\\t\\t\\t\\t\\tthrow new Error(`JSON response failed type validation: ${errorMessage}`)\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t// No type validation needed, we're done\\n\\t\\t\\t\\t\\tincomplete = false\\n\\t\\t\\t\\t}\\n\\t\\t\\t} catch (e) {\\n\\t\\t\\t\\tif (attempts >= (aiClient['config'].attemptsPerCall)) {\\n\\t\\t\\t\\t\\tthrow e\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tawait new Promise(resolve => setTimeout(resolve, 1000))\\n\\t\\t\\t\\tconsole.warn(`AI call failed, retrying (${attempts}/${aiClient['config'].attemptsPerCall})`, e)\\n\\t\\t\\t} finally {\\n\\t\\t\\t\\tattempts++\\n\\t\\t\\t}\\n\\t\\t}\\n\\t} finally {\\n\\t\\tif (aiClient['config'].debugMode) {\\n\\t\\t\\tconst promises = Array.from(convSavePromises.values()).map(c => c.promise)\\n\\t\\t\\tawait Promise.all(promises)\\n\\t\\t}\\n\\t}\\n}\\n\\nfunction jsonSpec(\\n\\tmodel: AiModelId | undefined,\\n\\tjson: true | TypeSpec<any>,\\n\\tfirstThink: boolean,\\n): string {\\n\\tswitch (model) {\\n\\t\\tdefault: {\\n\\t\\t\\tif (json === true) {\\n\\t\\t\\t\\treturn 'TYPE SPEC :: IGNORE ALL PREVIOUS TYPE SPECS\\\\n\\\\nIn your next message only, respond with JSON'\\n\\t\\t\\t}\\n\\t\\t\\tconst propSpec = (json as TypeSpec<any>)\\n\\t\\t\\tconst jsonInPrompt = new EmptyTypeSpec([], undefined as unknown)\\n\\t\\t\\t\\t.object(o => {\\n\\t\\t\\t\\t\\tlet newO = o\\n\\t\\t\\t\\t\\tif (firstThink) {\\n\\t\\t\\t\\t\\t\\tnewO = newO.hasString('reasoning', 'Elaborate your reasoning here. Think step by step. Give your thinking steps in a numbered list or in markdown with headers if the task requires it.')\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\treturn newO.has('result', () => new FullPropTypeSpec(propSpec['type'], propSpec['value']))\\n\\t\\t\\t\\t})\\n\\t\\t\\treturn `TYPE SPEC :: IGNORE ALL PREVIOUS TYPE SPECS\\\\n\\\\n`\\n\\t\\t\\t\\t+ `In its next message only, the assistant will respond with JSON matching the Typescript type below.\\\\n`\\n\\t\\t\\t\\t+ '- strictNullChecks, exactOptionalPropertyTypes are both on\\\\n'\\n\\t\\t\\t\\t+ `- a value can ONLY be null if explicitly stated, e.g. 'string | null'\\\\n`\\n\\t\\t\\t\\t+ '- optional properties (e.g. `{foo?: string}`) can only be achieved by not including it, NOT by setting them to null\\\\n'\\n\\t\\t\\t\\t// + '- examples:\\\\n'\\n\\t\\t\\t\\t// + ' - type `{foo: string}`\\\\n'\\n\\t\\t\\t\\t// + ' - GOOD: `{\\\"foo\\\": \\\"bar\\\"}`\\\\n'\\n\\t\\t\\t\\t// + ' - BAD: `{\\\"foo\\\": null}`\\\\n'\\n\\t\\t\\t\\t// + ' - type: `{foo: string | null}`\\\\n'\\n\\t\\t\\t\\t// + ' - GOOD: `{\\\"foo\\\": \\\"bar\\\"}`\\\\n'\\n\\t\\t\\t\\t// + ' - GOOD: `{\\\"foo\\\": null}`\\\\n'\\n\\t\\t\\t\\t// + ' - BAD: `{}`\\\\n'\\n // + ' - type: `{foo?: string}`\\\\n'\\n\\t\\t\\t\\t// + ' - GOOD: `{\\\"foo\\\": \\\"bar\\\"}`\\\\n'\\n\\t\\t\\t\\t// + ' - GOOD: `{}`\\\\n'\\n\\t\\t\\t\\t// + ' - BAD: `{\\\"foo\\\": null}`\\\\n'\\n\\t\\t\\t\\t+ '\\\\n'\\n + 'The type:\\\\n'\\n + `${describeType(jsonInPrompt)}`\\n\\t\\t}\\n\\t}\\n}\\n\\nexport type { JsonExcerpt } from './json-streaming/JsonExcerpt.js'\\nexport type { StreamedJsonElement, ElementType, PropType } from './json-streaming/StreamedJsonElement.js'\\nexport type { Token, TokenType } from './json-streaming/types.js'\\nexport type {\\n\\tBaseType,\\n\\tTypeType,\\n\\tNullType,\\n\\tBooleanType,\\n\\tStringType,\\n\\tNumberType,\\n\\tObjectType,\\n\\tArrayType,\\n\\tConstantType,\\n\\tCombine,\\n\\tType,\\n\\tUndefinedType,\\n} from './type-spec/type-spec.js'\\nexport {\\n\\tEmptyTypeSpec,\\n\\tTypeSpec,\\n\\tFullTypeSpec,\\n\\tTypeMemberSpec,\\n\\tFullPropTypeSpec,\\n\\tEmptyPropTypeSpec,\\n\\tPropTypeSpec,\\n} from './type-spec/type-spec.js'\\n// Helper constant to create a TypeSpecMessage\\nexport const TypeSpecMarker = {typeSpec: true} as const\\n\\nexport { AIClient, BasicPrompt, JsonPrompt, PromptBase, StreamedJsonChildElement, StreamedJsonRootElement }\\nexport type { ApiKeys as AccessTokens, AnyJson, AssistantMessage, DeveloperMessage, HandshakeData, JsonArray, JsonObject, Message, Opts, Prompt, SystemMessage, UserMessage, TypeSpecMessage, ToolDefinition, ToolFunction }\\nexport type { AiModelId } from './ai-inference/AiModelId.js'\\nexport { AiModel } from './ai-inference/AiModel.js'\\nexport { parsePartialJson } from './parse-partial-json/parsePartialJson.js'\\nexport type { DeepPartial } from './parse-partial-json/parsePartialJson.js'\\nexport type { ImageSize } from './ai-inference/openai/promptOpenaiImageGen.js'\\nexport type { OpenaiImageModelId } from './ai-inference/openai/OpenaiImageModelId.js'\\nexport { OpenaiImageModel } from './ai-inference/openai/OpenaiImageModel.js'\\nexport type { GenericPrompt, PromptMessage, ServiceTier, PromptMessageWithId, Role }\\n\\nexport type CodeLine = {\\n\\tstacktraceFrame: string\\n\\tfileName: string\\n\\tlineNumber: number\\n\\tfunctionName?: string\\n}\\n\\nexport function getCallerFileNameAndLineNumber(): CodeLine {\\n\\tconst error = new Error()\\n\\tconst stacktrace = error.stack ?? ''\\n\\tconst stack = stacktrace\\n\\t\\t.split('\\\\n')\\n\\t\\t.map(l => l.trim())\\n\\t\\t.filter(l => l.startsWith('at '))\\n\\tconst frame = stack[2]!\\n\\tconst hasFunctionNameInFrameWithFileNameInParenthesis = frame.match(/[^(]+\\\\([^)]+\\\\)/)\\n\\tconst {\\n\\t\\tfunctionName,\\n\\t\\tfileName,\\n\\t\\tlineNumber,\\n\\t} = hasFunctionNameInFrameWithFileNameInParenthesis\\n\\t\\t? frame.match('at (?<functionName>[^(]*) \\\\((?<scheme>.*://)?(?<fileName>[^:]*):(?<lineNumber>[0-9]+):(?<colNumber>[0-9]+)\\\\)')!.groups!\\n\\t\\t: frame.match('at (?<scheme>.*://)?(?<fileName>[^:]*):(?<lineNumber>[0-9]+):(?<colNumber>[0-9]+)')!.groups!\\n\\treturn {\\n\\t\\tstacktraceFrame: requireThat(frame).canBeString().andNothingElse(),\\n\\t\\tfileName: requireThat(fileName).canBeString().andNothingElse(),\\n\\t\\tlineNumber: requireThat(parseInt(lineNumber!)).canBeNumber().andNothingElse(),\\n\\t\\tfunctionName: requireThat(functionName).canBeString().canBeUndefined().andNothingElse(),\\n\\t}\\n}\\n\\ntype PromptMessageWithId = PromptMessage & {\\n\\tmessageUuid: string\\n}\\n\\n// Define a type for conversation data\\ninterface ConversationData {\\n\\tconversationUuid: string\\n\\tprompt: {\\n\\t\\tid: string | undefined\\n\\t\\tcallingCodeLine: CodeLine\\n\\t}\\n\\tmessages: PromptMessageWithId[]\\n}\\n\\n// Function to save conversation using HTTP PUT\\nasync function saveConversation(\\n\\tconversationData: ConversationData,\\n\\tapiKey: string | undefined,\\n) {\\n\\ttry {\\n\\t\\tif (apiKey === undefined) {\\n\\t\\t\\treturn\\n\\t\\t}\\n\\t\\tconst response = await fetch(`${getPromptGridApiUrl()}/api/conversations`, {\\n\\t\\t\\tmethod: 'PUT',\\n\\t\\t\\theaders: {\\n\\t\\t\\t\\t'Content-Type': 'application/json',\\n\\t\\t\\t\\t'Authorization': `Bearer ${apiKey}`\\n\\t\\t\\t},\\n\\t\\t\\tbody: JSON.stringify(conversationData),\\n\\t\\t});\\n\\n\\t\\tif (!response.ok) {\\n\\t\\t\\tthrow new Error(`Got ${response.status} when attempting to save conversation, with body: ${await response.text()}`);\\n\\t\\t}\\n\\t} catch (error) {\\n\\t\\tconsole.error('Error saving conversation', error);\\n\\t}\\n}\\n\\n\",\"import {AiModelId} from '../AiModelId.ts'\\nimport {PlatformSpecificPromptRequest} from '../model.js'\\nimport {Flux} from 'monoflux'\\n\\nexport type ToolCall = {\\n id: string\\n name: string\\n arguments: string\\n}\\n\\nexport type ContentChunk = {\\n type: 'content'\\n content: string\\n}\\n\\nexport type ToolCallsChunk = {\\n type: 'toolCalls'\\n toolCalls: ToolCall[]\\n}\\n\\nexport type PromptChunk = ContentChunk | ToolCallsChunk\\n\\nfunction errorMessage(bodyText: string) {\\n try {\\n const body = JSON.parse(bodyText) as { error: { message: string } }\\n return body.error.message\\n } catch (e) {\\n return bodyText\\n }\\n}\\n\\nexport function promptOpenai(\\n {\\n model,\\n prompt,\\n apiToken,\\n temperature,\\n topP,\\n requireJsonResponse,\\n serviceTier,\\n tools,\\n }: PlatformSpecificPromptRequest<boolean> & {\\n tools?: {\\n type: 'function'\\n function: {\\n name: string\\n description: string\\n parameters: any\\n }\\n }[]\\n }\\n): Flux<PromptChunk> {\\n return Flux.fromGeneratorFunction(async function* () {\\n const abortController = new AbortController()\\n const response = await fetch(\\n `https://api.openai.com/v1/chat/completions`,\\n {\\n headers: {\\n 'Content-Type': 'application/json',\\n 'Accept': 'application/json',\\n 'Authorization': `Bearer ${apiToken}`\\n },\\n method: 'POST',\\n signal: abortController.signal,\\n body: JSON.stringify({\\n model,\\n messages: prompt,\\n stream: true,\\n temperature,\\n top_p: topP,\\n response_format: requireJsonResponse ? {\\n type: 'json_object'\\n } : undefined,\\n service_tier: serviceTier === 'flex' ? 'flex' : 'default',\\n tools,\\n } satisfies OpenAiRequestBody)\\n }\\n )\\n if (response.status < 200 || response.status >= 300) {\\n const message = errorMessage(await response.text())\\n throw new Error(`OpenAPI reported: ${message}`)\\n }\\n if (response.body === null) {\\n throw new Error('illegal state')\\n }\\n let jsonBuffer = ''\\n let accumulatedToolCalls: Record<string, { id: string; name: string; arguments: string }> = {}\\n \\n yield* Flux\\n .fromReadableStream(response.body, () => abortController.abort())\\n .map(value => textDecoder.decode(value, {stream: true}))\\n .flatMap(value =>\\n value\\n .replaceAll('data: [DONE]', '')\\n .replace(/^data: /, '')\\n .split('data: ')\\n )\\n .map(\\n value => value\\n .replace(/[\\\\n ]*$/, '')\\n .trim()\\n )\\n .flatMap(value => {\\n jsonBuffer += value\\n try {\\n const json = JSON.parse(jsonBuffer) as ChatCompletionChunk\\n jsonBuffer = ''\\n return [json]\\n } catch (e) {\\n return [] as ChatCompletionChunk[]\\n }\\n })\\n .map(chunk => chunk.choices[0]!)\\n .flatMap(choice => {\\n \\n // Handle tool calls accumulation\\n if (choice.delta.tool_calls) {\\n for (const toolCall of choice.delta.tool_calls) {\\n if (toolCall.id && toolCall.function?.name) {\\n // First chunk with id and name\\n accumulatedToolCalls[toolCall.id] = {\\n id: toolCall.id,\\n name: toolCall.function.name,\\n arguments: toolCall.function.arguments || ''\\n }\\n } else if (toolCall.id && accumulatedToolCalls[toolCall.id]) {\\n // Subsequent chunks with more arguments\\n accumulatedToolCalls[toolCall.id]!.arguments += toolCall.function?.arguments || ''\\n } else if (toolCall.index !== undefined && toolCall.function?.arguments) {\\n // Handle streaming by index when id is not present\\n const existingEntry = Object.values(accumulatedToolCalls)[toolCall.index]\\n if (existingEntry) {\\n existingEntry.arguments += toolCall.function.arguments\\n }\\n }\\n }\\n }\\n \\n // If we're finishing with tool calls, emit them\\n if (choice.finish_reason === 'tool_calls') {\\n return [{\\n type: 'toolCalls' as const,\\n toolCalls: Object.values(accumulatedToolCalls)\\n }] as PromptChunk[]\\n }\\n \\n // If we have regular content, emit it\\n if (choice.delta.content) {\\n return [{\\n type: 'content' as const,\\n content: choice.delta.content\\n }] as PromptChunk[]\\n }\\n \\n // Check if we're done\\n if (choice.finish_reason && choice.finish_reason !== 'tool_calls') {\\n return [] as PromptChunk[]\\n }\\n \\n return [] as PromptChunk[]\\n })\\n .filter<PromptChunk>(item => item !== undefined && item !== null)\\n })\\n}\\n\\nconst textDecoder = new TextDecoder()\\n\\ntype OpenAiRequestBody = {\\n model: AiModelId\\n messages: {\\n role: 'developer' | 'system' | 'user' | 'assistant' | 'tool'\\n content: string | string[] | null\\n tool_call_id?: string\\n }[]\\n stream: boolean\\n temperature?: number\\n top_p?: number\\n response_format?: {\\n type: 'json_object' | 'text'\\n }\\n service_tier?: 'default' | 'flex'\\n tools?: {\\n type: 'function'\\n function: {\\n name: string\\n description: string\\n parameters: any\\n }\\n }[]\\n}\\n\\ntype ChatCompletionChunk = {\\n id: string\\n choices: {\\n id: number\\n delta: {\\n refusal?: string\\n content?: string\\n role?: string\\n tool_calls?: {\\n id?: string\\n index?: number\\n type?: 'function'\\n function?: {\\n name?: string\\n arguments?: string\\n }\\n }[]\\n }\\n finish_reason?: string | 'tool_calls'\\n }[]\\n // usage: {\\n // completion_tokens: number\\n // prompt_tokens: number\\n // total_tokens: number\\n // completion_tokens_details: {\\n // accepted_prediction_tokens: number\\n // audio_tokens: number\\n // reasoning_tokens: number\\n // rejected_prediction_tokens: number\\n // }\\n // prompt_tokens_details: {\\n // audio_tokens: number\\n // cached_tokens: number\\n // }\\n // } | null\\n}\\n\",\"export type Combine<Current, New> = unknown extends Current\\n ? New\\n : (Current & New) extends never\\n ? Current | New\\n : (Current & New)\\n\\ntype Simplify<T> = {\\n [K in keyof T]: Simplify<T[K]>\\n}\\n\\nexport type Opts = {\\n ignoreUnknownProps?: boolean\\n logValueIfWrong?: boolean\\n errorMessage?: string\\n}\\n\\ntype Problem = {\\n path: string\\n expectedType?: Type[]\\n expectedProp?: string\\n value: unknown\\n unknownProp?: string\\n}\\n\\nclass ComplexTypeError extends Error {\\n public readonly data: any\\n public readonly httpStatus = 400\\n\\n constructor(problems: Problem[], message?: string) {\\n const data = problems\\n .map(problem => {\\n if (problem.expectedProp) {\\n return {\\n expectedProp: (problem.path + '.').replace(/^root\\\\./, '') + problem.expectedProp\\n }\\n } else if (problem.expectedType) {\\n return {\\n expectedType: problem.expectedType.map(typeToString).join(' | '),\\n path: problem.path,\\n insteadGot: problem.value\\n }\\n } else if (problem.unknownProp) {\\n return {\\n unknownProp: (problem.path + '.').replace(/^root\\\\./, '') + problem.unknownProp\\n }\\n } else {\\n throw new Error('illegal state')\\n }\\n })\\n super(message ?? `Value is of the wrong format: ${JSON.stringify(data, null, 2)}`)\\n this.data = data\\n }\\n}\\n\\n/**\\n * Way to assert the shape of a type both in runtime and in the\\n * type system.\\n *\\n * Usage example:\\n *\\n * ```typescript\\n * const inputValue = ['foo', 'bar'] as unknown\\n *\\n * assert(\\n * inputValue,\\n * t => t\\n * .canBeArray(t => t\\n * .canBeObject(t => t\\n * .canHaveString('foo')\\n * .canHaveString('bar')\\n * )\\n * )\\n * )\\n *\\n * let safeInputvalue = inputValue\\n *\\n * safeInputvalue = [{}] // typescript disapproves\\n * safeInputvalue = [{foo: 'bla', bar: 'bla'}] // typescript approves\\n * ```\\n */\\nexport function requireThat(\\n value: unknown\\n): TypeSpec<unknown> {\\n return new TypeSpec<unknown>([], value)\\n}\\n\\nfunction checkIsOneOf(value: unknown, types: Type[], path: string, opts: Opts): Problem[] {\\n const problemsPerType = types\\n .map(type => checkIs(value, type, path, opts))\\n if (problemsPerType.some(list => list.length === 0)) {\\n return []\\n } else {\\n const typeProblemsOnThisPath = problemsPerType\\n .flatMap(list => list.filter(t => t.expectedType !== undefined && t.path === path))\\n if (typeProblemsOnThisPath.length > 0) {\\n return [{\\n expectedType: typeProblemsOnThisPath\\n .flatMap(problem => problem.expectedType!),\\n path,\\n value\\n }]\\n }\\n return problemsPerType.flatMap(list => list)\\n }\\n}\\n\\nfunction checkIs(value: unknown, type: Type, path: string, opts: Opts): Problem[] {\\n const {ignoreUnknownProps = true} = opts\\n switch (type.type) {\\n case 'array': {\\n if (!Array.isArray(value)) {\\n return [{expectedType: [type], path, value}]\\n }\\n if (value.length === 0) {\\n return []\\n }\\n return checkIsOneOf(value[0], type.elementType, path + '[..]', opts)\\n }\\n case 'boolean': {\\n if (typeof value !== 'boolean') {\\n return [{expectedType: [type], path, value}]\\n }\\n return []\\n }\\n case 'undefined': {\\n return value === undefined\\n ? []\\n : [{expectedType: [type], path, value}]\\n }\\n case 'object': {\\n if (typeof value !== 'object' || value === null) {\\n return [{expectedType: [type], path, value}]\\n }\\n const problems: Problem[] = []\\n for (const key in type.props) {\\n const prop = type.props[key]!\\n if (!(key in value)) {\\n if (!prop.optional) {\\n problems.push({expectedProp: key, path, value})\\n }\\n continue\\n }\\n const typeAccountingOptionality: Type[] = prop.optional\\n ? [...prop.type, {type: 'undefined'}]\\n : prop.type\\n problems.push(...checkIsOneOf(value[key as keyof typeof value], typeAccountingOptionality, path + `.${key}`, opts))\\n }\\n if (!ignoreUnknownProps) {\\n for (const key in value) {\\n if (!(key in type.props)) {\\n problems.push({unknownProp: key, path, value})\\n }\\n }\\n }\\n return problems\\n }\\n case 'string': {\\n return typeof value === 'string'\\n ? []\\n : [{expectedType: [type], path, value}]\\n }\\n case 'null': {\\n return value === null\\n ? []\\n : [{expectedType: [type], path, value}]\\n }\\n case 'number': {\\n return typeof value === 'number'\\n ? []\\n : [{expectedType: [type], path, value}]\\n }\\n case 'constant': {\\n return value === type.value && !Number.isNaN(value)\\n ? []\\n : [{expectedType: [type], path, value}]\\n }\\n }\\n}\\n\\nexport class TypeSpec<T> {\\n public readonly type: Type[]\\n private readonly value: unknown\\n\\n constructor(type: Type[] = [], value: unknown) {\\n this.type = type\\n this.value = value\\n }\\n\\n canBeArray<T_arr = unknown>(assertTypeOfArray: (arg: TypeSpec<unknown>) => TypeSpec<T_arr>) {\\n const elementSpec = assertTypeOfArray(new TypeSpec<unknown>([], this.value))\\n const arraySpec = new TypeSpec<unknown>(\\n [{type: 'array', elementType: elementSpec.type}],\\n this.value\\n )\\n return new TypeSpec<Combine<T, T_arr[]>>([...this.type, ...arraySpec.type], this.value)\\n }\\n\\n canBeObject<T_obj extends {}>(assertTypeOfObject: (arg: TypeSpec<{}>) => TypeSpec<T_obj>) {\\n const objectSpec = assertTypeOfObject(new TypeSpec([{type: 'object', props: {}}], this.value))\\n return new TypeSpec<Combine<T, T_obj>>([...this.type, ...objectSpec.type], this.value)\\n }\\n\\n hasString<Key extends string>(propertyName: Key): TypeSpec<Combine<T, Record<Key, string>>> {\\n return this.hasProperty(\\n propertyName,\\n type => type.canBeString()\\n )\\n }\\n\\n canHaveProperty<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: TypeSpec<unknown>) => TypeSpec<T_prop | undefined>\\n ): TypeSpec<Combine<T, Partial<Record<Key, T_prop>>>> {\\n return this.hasProperty(propertyName, assertTypeOfProperty, true)\\n }\\n\\n hasProperty<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: TypeSpec<unknown>) => TypeSpec<T_prop>,\\n optional: false\\n ): TypeSpec<Combine<T, Partial<Record<Key, T_prop>>>>\\n hasProperty<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: TypeSpec<unknown>) => TypeSpec<T_prop>,\\n optional?: boolean\\n ): TypeSpec<Combine<T, Record<Key, T_prop>>>\\n hasProperty<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: TypeSpec<unknown>) => TypeSpec<T_prop>,\\n optional = false\\n ): TypeSpec<Combine<T, Record<Key, T_prop> | Partial<Record<Key, T_prop>>>> {\\n const old = this.type.length === 1\\n ? this.type[0]!\\n : undefined\\n if (old === undefined || old.type !== 'object') {\\n throw new Error('illegal state')\\n }\\n const {type: propertyType} = assertTypeOfProperty(new TypeSpec([], this.value))\\n return new TypeSpec<Combine<T, Record<Key, T_prop>>>([{\\n ...old,\\n props: {\\n ...old.props,\\n [propertyName]: {\\n optional,\\n type: propertyType\\n }\\n }\\n }], this.value)\\n }\\n\\n canBeString() {\\n return new TypeSpec<Combine<T, string>>([...this.type, {type: 'string'}], this.value)\\n }\\n\\n canBeNumber() {\\n return new TypeSpec<Combine<T, number>>([...this.type, {type: 'number'}], this.value)\\n }\\n\\n canBeBoolean() {\\n return new TypeSpec<Combine<T, boolean>>([...this.type, {type: 'boolean'}], this.value)\\n }\\n\\n canBeConstant<Value extends (string | number | boolean)>(value: Value) {\\n return new TypeSpec<Combine<T, Value>>([...this.type, {type: 'constant', value}], this.value)\\n }\\n\\n canBeNull(): TypeSpec<Combine<T, null>> {\\n return new TypeSpec<Combine<T, null>>([...this.type, {type: 'null'}], this.value)\\n }\\n\\n canBeUndefined(): TypeSpec<Combine<T, undefined>> {\\n return new TypeSpec<Combine<T, undefined>>([...this.type, {type: 'undefined'}], this.value)\\n }\\n\\n public andNothingElse(\\n opts: Opts = {}\\n ): T {\\n const problems = checkIsOneOf(this.value, this.type, 'root', opts)\\n if (problems.length > 0) {\\n throw new ComplexTypeError(problems, opts.errorMessage)\\n }\\n return this.value as T\\n }\\n\\n public orDefaultTo<Value>(\\n value: Value,\\n opts: Opts = {}\\n ): T | Value {\\n const problems = checkIsOneOf(this.value, this.type, 'root', opts)\\n if (problems.length > 0) {\\n return value\\n }\\n return this.value as T\\n }\\n\\n public describe(): string {\\n return describe(this.type)\\n }\\n}\\n\\nfunction describe(type: Type | Type[], indentLevel = 0): string {\\n if (Array.isArray(type)) {\\n return type.map(t => describe(t, indentLevel)).join(' | ')\\n }\\n switch (type.type) {\\n case 'array': {\\n return `${describe(type.elementType, indentLevel)}[]`\\n }\\n case 'boolean': {\\n return 'boolean'\\n }\\n case 'undefined': {\\n return 'undefined'\\n }\\n case 'object': {\\n return `{\\\\n`\\n +\\n Object.keys(type.props).map(\\n key => `${indent(indentLevel + 1)}${key}: ${describe(type.props[key]!.type, indentLevel + 1)}`\\n ).join(',\\\\n')\\n + `\\\\n${indent(indentLevel)}}`\\n }\\n case 'string': {\\n return 'string'\\n }\\n case 'null': {\\n return 'null'\\n }\\n case 'number': {\\n return 'number'\\n }\\n case 'constant': {\\n return `\\\"${type.value}\\\"`\\n }\\n }\\n}\\n\\nfunction indent(depth: number) {\\n let indent = ''\\n for (let i = 0; i < depth; i++) {\\n indent += ' '\\n }\\n return indent\\n}\\n\\nexport type TypeType = 'undefined' | 'null' | 'boolean' | 'string' | 'number' | 'object' | 'array' | 'constant'\\n\\nexport type BaseType<TT extends TypeType> = {\\n type: TT\\n}\\n\\nexport type UndefinedType = BaseType<'undefined'>\\nexport type NullType = BaseType<'null'>\\nexport type BooleanType = BaseType<'boolean'>\\nexport type StringType = BaseType<'string'>\\nexport type NumberType = BaseType<'number'>\\nexport type ObjectType = BaseType<'object'> & {\\n props: Record<string, {\\n optional: boolean\\n type: Type[]\\n }>\\n}\\nexport type ArrayType = BaseType<'array'> & {\\n elementType: Type[]\\n}\\nexport type ConstantType<Value extends (string | number | boolean)> = BaseType<'constant'> & {\\n value: Value\\n}\\n\\nexport type Type =\\n UndefinedType\\n | NullType\\n | BooleanType\\n | StringType\\n | NumberType\\n | ObjectType\\n | ArrayType\\n | ConstantType<any>\\n\\nfunction typeToString(type: Type) {\\n return type.type === 'constant'\\n ? `'${type.value}'`\\n : type.type\\n}\\n\",\"import { requireThat } from \\\"./require-that/requireThat.js\\\";\\nimport {config} from 'dotenv'\\n\\nlet promptGridApiKey: string;\\nexport function getPromptGridApiKey() {\\n if (!promptGridApiKey) {\\n config()\\n const rawValue = process.env['PROMPTGRID_API_KEY']\\n promptGridApiKey = requireThat(rawValue)\\n .canBeString()\\n .andNothingElse({errorMessage: `PromptGrid API key invalid: ${rawValue}`})\\n }\\n return promptGridApiKey;\\n}\\n\\nlet promptGridApiUrl: string;\\n\\nexport function getPromptGridApiUrl() {\\n if (!promptGridApiUrl) {\\n config()\\n let url = backendUrlNotTriviallyIdentifiableInMinifiedCode()\\n const rawValue = process.env['PROMPTGRID_API_URL'] ?? url\\n promptGridApiUrl = requireThat(rawValue)\\n .canBeString()\\n .andNothingElse({errorMessage: `PromptGrid API URL invalid: ${rawValue}`})\\n }\\n return promptGridApiUrl;\\n}\\n\\n/**\\n * @returns https://api.promptgrid.ai\\n */\\nfunction backendUrlNotTriviallyIdentifiableInMinifiedCode() {\\n let url = 't'\\n url = url + 'ps'\\n url = 'ht' + url\\n url = url + ':'\\n url = url + '/'\\n url = url + '/ap'\\n url = url + 'i.pr'\\n let url2 = 'i'\\n url2 = 'd.a' + url2\\n url2 = 'gri' + url2\\n url = url + 'ompt'\\n return url + url2\\n}\\n\",\"export enum TokenType {\\n START_OBJECT = 'START_OBJECT',\\n END_OBJECT = 'END_OBJECT',\\n START_ARRAY = 'START_ARRAY',\\n END_ARRAY = 'END_ARRAY',\\n FIELD_NAME = 'FIELD_NAME',\\n VALUE_STRING = 'VALUE_STRING',\\n VALUE_NUMBER_INT = 'VALUE_NUMBER_INT',\\n VALUE_NUMBER_FLOAT = 'VALUE_NUMBER_FLOAT',\\n VALUE_TRUE = 'VALUE_TRUE',\\n VALUE_FALSE = 'VALUE_FALSE',\\n VALUE_NULL = 'VALUE_NULL',\\n COMMA = 'COMMA',\\n}\\n\\nexport class Token {\\n constructor(\\n public type: TokenType,\\n public source: string,\\n public value?: string | number,\\n public fieldName?: string,\\n public maybeIncomplete: boolean = false\\n ) {}\\n}\\n\",\"import {Token, TokenType} from './types.js'\\nimport {JsonExcerpt} from './JsonExcerpt.js'\\nimport {Flux} from 'monoflux'\\n\\n\\nexport class JsonTokenProcessor {\\n private jsonBuffer: string = ''\\n private highestOffsetParsed: number = -1\\n\\n public static toJsonTokenFlux(\\n dataBufferFlux: Flux<string>\\n ): Flux<JsonExcerpt> {\\n return new JsonTokenProcessor().processDataBuffer(dataBufferFlux)\\n }\\n\\n public processDataBuffer(deltaContentFlux: Flux<string>): Flux<JsonExcerpt> {\\n return deltaContentFlux.flatMap(content => this.getExcerpts(content))\\n }\\n\\n public getExcerpts(source: string): JsonExcerpt[] {\\n this.jsonBuffer += source\\n\\n const excerpts: JsonExcerpt[] = []\\n\\n const jsonParser = new JsonParser(this.jsonBuffer)\\n\\n let token: Token | undefined\\n while ((token = this.nextToken(jsonParser))) {\\n if (jsonParser.currentTokenLocation().getCharOffset() > this.highestOffsetParsed && !token.maybeIncomplete) {\\n excerpts.push({token})\\n this.highestOffsetParsed = jsonParser\\n .currentTokenLocation()\\n .getCharOffset()\\n }\\n }\\n\\n excerpts.push({source})\\n\\n return excerpts\\n }\\n\\n private nextToken(jsonParser: JsonParser): Token | undefined {\\n const result = jsonParser.nextToken()\\n return typeof result !== 'string' ? result : undefined\\n }\\n}\\n\\nclass JsonParser {\\n private position: number = 0\\n private currentTokenType: TokenType | undefined\\n private parentFieldName: string | undefined\\n private currentValue: any = null\\n private context: ContextType[] = []\\n\\n constructor(private readonly content: string) {}\\n\\n nextToken(): Token | 'token-incomplete' | 'string-ended' {\\n const startPosition = this.position\\n\\n if (this.position >= this.content.length) {\\n return 'string-ended'\\n }\\n\\n // Skip whitespace\\n while (\\n this.position < this.content.length &&\\n /\\\\s/.test(this.content[this.position]!)\\n ) {\\n this.position++\\n }\\n\\n if (this.position >= this.content.length) {\\n return 'string-ended'\\n }\\n\\n const source = (position: number) =>\\n this.content.substring(startPosition, position)\\n\\n const char = this.content[this.position]!\\n\\n switch (char) {\\n case '{':\\n this.position++\\n this.currentTokenType = TokenType.START_OBJECT\\n this.pushContext('object')\\n return new Token(\\n this.currentTokenType,\\n source(this.position),\\n undefined,\\n this.parentFieldName,\\n )\\n case '}': {\\n this.position++\\n this.currentTokenType = TokenType.END_OBJECT\\n const token = new Token(this.currentTokenType, source(this.position), undefined, this.parentFieldName)\\n this.parentFieldName = undefined\\n this.popContext('object')\\n if (this.currentContextType === 'field') {\\n this.popContext('field')\\n }\\n return token\\n }\\n case '[':\\n this.position++\\n this.currentTokenType = TokenType.START_ARRAY\\n this.pushContext('array')\\n return new Token(this.currentTokenType, source(this.position), undefined, this.parentFieldName)\\n case ']': {\\n this.position++\\n this.currentTokenType = TokenType.END_ARRAY\\n const token = new Token(this.currentTokenType, source(this.position), undefined, this.parentFieldName)\\n this.parentFieldName = undefined\\n this.popContext('array')\\n if (this.currentContextType === 'field') {\\n this.popContext('field')\\n }\\n return token\\n }\\n case '\\\"':\\n // Check if this is a field name (followed by colon)\\n if (this.currentContextType === 'object') {\\n this.currentTokenType = TokenType.FIELD_NAME\\n\\n let startPos = ++this.position\\n let endPos = this.content.indexOf('\\\"', startPos)\\n while (endPos >= 0 && this.content[endPos - 1] === '\\\\\\\\') {\\n endPos = this.content.indexOf('\\\"', endPos + 1)\\n }\\n if (endPos === -1) {\\n return 'token-incomplete'\\n }\\n const value = this.content.substring(startPos, endPos)\\n endPos++\\n while (endPos < this.content.length && /\\\\s/.test(this.content[endPos]!)) {\\n endPos++\\n }\\n if (endPos === this.content.length) {\\n return 'token-incomplete'\\n }\\n if (this.content[endPos]! !== ':') {\\n throw new Error('Expected token \\\\':\\\\'')\\n }\\n endPos++\\n\\n this.position = endPos\\n const token = new Token(\\n this.currentTokenType,\\n source(this.position),\\n value,\\n undefined\\n )\\n this.parentFieldName = value\\n this.pushContext('field')\\n return token\\n } else {\\n this.currentTokenType = TokenType.VALUE_STRING\\n\\n\\n // Parse string\\n let startPos = ++this.position\\n let endPos = this.content.indexOf('\\\"', startPos)\\n while (endPos > 0 && this.content[endPos - 1] === '\\\\\\\\') {\\n endPos = this.content.indexOf('\\\"', endPos + 1)\\n }\\n\\n if (endPos === -1) {\\n return 'token-incomplete'\\n }\\n\\n const value = this.content.substring(startPos, endPos)\\n this.position = endPos + 1\\n\\n this.currentValue = value\\n const token = new Token(\\n this.currentTokenType,\\n source(this.position),\\n value,\\n this.currentTokenType === TokenType.VALUE_STRING\\n ? this.parentFieldName\\n : undefined\\n )\\n this.parentFieldName = undefined;\\n if (this.currentContextType === 'field') {\\n this.popContext('field')\\n }\\n return token\\n }\\n case 't': {\\n const nextFourChars = this.content.substring(\\n this.position,\\n this.position + 4\\n )\\n if (nextFourChars === 'true') {\\n this.position += 4\\n this.currentTokenType = TokenType.VALUE_TRUE\\n this.currentValue = true\\n if (this.currentContextType === 'field') {\\n this.popContext('field')\\n }\\n return new Token(\\n this.currentTokenType,\\n source(this.position),\\n this.currentValue,\\n this.parentFieldName\\n )\\n } else if (nextFourChars.length < 4) {\\n return 'token-incomplete'\\n }\\n break\\n }\\n case 'f': {\\n const nextFiveChars = this.content.substring(\\n this.position,\\n this.position + 5\\n )\\n if (nextFiveChars === 'false') {\\n this.position += 5\\n this.currentTokenType = TokenType.VALUE_FALSE\\n this.currentValue = false\\n if (this.currentContextType === 'field') {\\n this.popContext('field')\\n }\\n return new Token(\\n this.currentTokenType,\\n source(this.position),\\n this.currentValue,\\n this.parentFieldName\\n )\\n } else if (nextFiveChars.length < 5) {\\n return 'token-incomplete'\\n }\\n break\\n }\\n case 'n': {\\n const nextFourChars = this.content.substring(\\n this.position,\\n this.position + 4\\n )\\n if (nextFourChars === 'null') {\\n this.position += 4\\n this.currentTokenType = TokenType.VALUE_NULL\\n this.currentValue = null\\n if (this.currentContextType === 'field') {\\n this.popContext('field')\\n }\\n return new Token(\\n this.currentTokenType,\\n source(this.position),\\n this.currentValue,\\n this.parentFieldName\\n )\\n } else if (nextFourChars.length < 4) {\\n return 'token-incomplete'\\n }\\n break\\n }\\n case ',': {\\n this.position++\\n this.currentTokenType = TokenType.COMMA\\n return new Token(\\n this.currentTokenType,\\n source(this.position),\\n undefined,\\n undefined,\\n false\\n )\\n }\\n default:\\n if (/[0-9-]/.test(char)) {\\n // Parse number\\n let numStr = ''\\n let hasDecimal = false\\n\\n while (\\n this.position < this.content.length &&\\n (/[0-9]/.test(this.content[this.position]!) ||\\n this.content[this.position] === '-' ||\\n this.content[this.position] === '.' ||\\n this.content[this.position] === 'e' ||\\n this.content[this.position] === 'E' ||\\n this.content[this.position] === '+')\\n ) {\\n if (this.content[this.position] === '.') {\\n hasDecimal = true\\n }\\n numStr += this.content[this.position++]\\n }\\n\\n if (hasDecimal) {\\n this.currentTokenType = TokenType.VALUE_NUMBER_FLOAT\\n this.currentValue = parseFloat(numStr)\\n } else {\\n this.currentTokenType = TokenType.VALUE_NUMBER_INT\\n this.currentValue = parseInt(numStr, 10)\\n }\\n const mayBeIncomplete = this.position >= this.content.length\\n\\n if (this.currentContextType === 'field') {\\n this.popContext('field')\\n }\\n return new Token(\\n this.currentTokenType,\\n source(this.position),\\n this.currentValue,\\n this.parentFieldName,\\n // cannot tell from number itself whether the number token is incomplete\\n mayBeIncomplete\\n )\\n }\\n }\\n\\n throw new JsonParseException('Invalid JSON at position ' + this.position)\\n }\\n\\n currentTokenLocation(): { getCharOffset: () => number } {\\n return {\\n getCharOffset: () => this.position\\n }\\n }\\n\\n private get currentContextType() {\\n return this.context[this.context.length - 1]\\n }\\n\\n private pushContext(contextType: ContextType) {\\n this.context.push(contextType)\\n }\\n\\n private popContext(contextType: ContextType) {\\n if (this.context.length === 0) {\\n throw new Error('Cannot pop context, context empty')\\n }\\n const currentContext = this.currentContextType\\n if (currentContext !== contextType) {\\n throw new Error(`Cannot pop context \\\\`${contextType}\\\\', current context '${currentContext}'`)\\n }\\n this.context.pop()\\n }\\n}\\n\\ntype ContextType = 'object' | 'array' | 'field'\\n\\nclass JsonParseException extends Error {\\n constructor(message: string) {\\n super(message)\\n this.name = 'JsonParseException'\\n }\\n}\\n\",\"import {Token, TokenType} from './types.js'\\nimport {JsonExcerpt} from './JsonExcerpt.js'\\nimport {Flux} from 'monoflux'\\nimport {AnyJson} from '../index.js'\\nimport {nonNullish} from '../util/nonNullish.js'\\n\\ntype MultiMap<K, V> = Map<K, V[]>;\\n\\ninterface CompletetionSubscription {\\n consumer: (value: any) => void;\\n expectedTokenType?: Set<TokenType> | undefined;\\n}\\n\\nexport type ElementType<ArrayType extends AnyJson> =\\n ArrayType extends readonly (infer ElementType)[] ? ElementType : never;\\n\\nexport type PropType<ObjectType extends AnyJson, PropName extends string> =\\n ObjectType extends Record<PropName, infer PropType extends AnyJson> ? PropType : never;\\n\\nexport abstract class StreamedJsonElement<T extends AnyJson> implements Promise<T> {\\n protected readonly receivedJson: string[] = [];\\n private readonly propertyCallbacks: MultiMap<string, (value: StreamedJsonElement<any>) => void> = new Map();\\n private onElementCallbacks: Set<(value: StreamedJsonElement<any>) => void> = new Set();\\n private onCompleteCallbacks: Set<CompletetionSubscription> = new Set();\\n private onEachExcerptCallbacks: Set<(value: JsonExcerpt) => void> = new Set();\\n private currentToken?: Token;\\n private state: State = new Begin();\\n private receivedExcerpts: JsonExcerpt[] = [];\\n\\n public onElement(callback: (value: StreamedJsonElement<ElementType<T>>) => void): this {\\n this.onElementCallbacks.add(callback);\\n return this;\\n }\\n\\n public onProperty<P extends string>(propertyName: P, callback: (element: StreamedJsonElement<PropType<T, P>>) => void): this {\\n if (!this.propertyCallbacks.has(propertyName)) {\\n this.propertyCallbacks.set(propertyName, []);\\n }\\n this.propertyCallbacks.get(propertyName)!.push(callback);\\n return this;\\n }\\n\\n /**\\n * @deprecated Does not work right now because FIELD_NAME\\n * token comes after string value is already streaming\\n */\\n public onJsonStringProperty<P extends string>(propertyName: P, callback: (element :StreamedJsonElement<PropType<T, P>>) => void): this {\\n if (!this.propertyCallbacks.has(propertyName)) {\\n this.propertyCallbacks.set(propertyName, []);\\n }\\n\\n this.propertyCallbacks.get(propertyName)!.push(content => {\\n const processor = new JsonTokenProcessor();\\n let seenFirst = false;\\n const stringBuffer: string[] = [];\\n const jsonElement = new StreamedJsonChildElement<PropType<T, P>>();\\n\\n content.onEachExcerpt(jsonStringExcerpt => {\\n if (jsonStringExcerpt.source !== undefined) {\\n stringBuffer.push(jsonStringExcerpt.source);\\n }\\n const allData = stringBuffer.join('');\\n const excerptWithHoleEscapeTokens = this.endsOnUnevenNumberOfBackslashes(allData)\\n ? allData.substring(0, allData.length - 1)\\n : allData;\\n\\n stringBuffer.length = 0;\\n const unescapedExcerpt = excerptWithHoleEscapeTokens.replace(/\\\\\\\\\\\"/g, '\\\"');\\n const unescapedExcerptWithoutOpeningQuote = seenFirst\\n ? unescapedExcerpt\\n : unescapedExcerpt.substring(1);\\n\\n const isLastOfJsonString = jsonStringExcerpt.token != null;\\n const unescapedExcerptWithoutClosingQuote = isLastOfJsonString\\n ? unescapedExcerptWithoutOpeningQuote.substring(0, unescapedExcerptWithoutOpeningQuote.length - 1)\\n : unescapedExcerptWithoutOpeningQuote;\\n\\n const jsonExcerpts = processor.getExcerpts(unescapedExcerptWithoutClosingQuote);\\n jsonExcerpts.forEach(excerpt => jsonElement.push(excerpt));\\n });\\n\\n callback(jsonElement);\\n });\\n\\n return this;\\n }\\n\\n public onEachExcerpt(callback: (value: JsonExcerpt) => void): this {\\n this.onEachExcerptCallbacks.add(callback);\\n this.receivedExcerpts.forEach(callback);\\n return this;\\n }\\n\\n // Promise methods\\n\\n async then<TResult1 = T, TResult2 = never>(\\n onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined,\\n onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined\\n ): Promise<TResult1 | TResult2> {\\n try {\\n const result = await this.getResponseAsPromise()\\n return nonNullish(onfulfilled)\\n ? await onfulfilled(result)\\n : result as unknown as TResult1\\n } catch (e) {\\n if (nonNullish(onrejected)) {\\n return await onrejected(e)\\n } else {\\n throw e\\n }\\n }\\n }\\n\\n async catch<TResult = never>(\\n onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined\\n ): Promise<T | TResult> {\\n try {\\n return await this.getResponseAsPromise()\\n } catch (e) {\\n if (nonNullish(onrejected)) {\\n return onrejected(e)\\n } else {\\n throw e\\n }\\n }\\n }\\n\\n async finally(onfinally?: (() => void) | null | undefined): Promise<T> {\\n try {\\n return await this.getResponseAsPromise()\\n } finally {\\n onfinally?.()\\n }\\n }\\n\\n get [Symbol.toStringTag](): string {\\n return 'StreamedJsonElement'\\n }\\n\\n\\n // other methods\\n\\n private getResponseAsPromise(): Promise<T> {\\n return new Promise(resolve => {\\n this.onCompleteAs(resolve)\\n })\\n }\\n\\n /**\\n * @param onComplete - a callback that will receive the complete JSON\\n * string for this element once it's done streaming\\n */\\n private onComplete(onComplete: (value: string) => void): void {\\n this._onComplete(this.toAsync(onComplete), undefined);\\n }\\n\\n private _onComplete(onComplete: (value: any) => void, expectedTokenType?: Set<TokenType>): void {\\n this.onCompleteCallbacks.add({\\n consumer: onComplete,\\n expectedTokenType\\n });\\n }\\n\\n public onCompleteAsync(onComplete: (value: string) => Promise<void>): void {\\n this._onComplete(onComplete, undefined);\\n }\\n\\n public onCompleteAs<T>(onComplete: (value: T) => void): void {\\n this.onCompleteAsAsync(this.toAsync(onComplete));\\n }\\n\\n public onCompleteAsAsync<T>(\\n onComplete: (value: T) => Promise<void>\\n ): void {\\n this._onComplete(\\n (jsonStringValue: string) => {\\n const jsonString = jsonStringValue.replace(/,$/, '')\\n const deserializedValue = (() => {\\n try {\\n return JSON.parse(jsonString)\\n } catch (e: any) {\\n e.message = `${e.message}. JSON string was: ${jsonString}`\\n throw e\\n }\\n })()\\n return onComplete(deserializedValue);\\n },\\n undefined\\n );\\n }\\n\\n public onCompleteAsString(onComplete: (value: string) => void): void {\\n this._onComplete(\\n this.toAsync(onComplete),\\n new Set([TokenType.VALUE_STRING, TokenType.VALUE_NULL])\\n );\\n }\\n\\n public onCompleteAsStringAsync(onComplete: (value: string) => Promise<void>): void {\\n this._onComplete(\\n onComplete,\\n new Set([TokenType.VALUE_STRING, TokenType.VALUE_NULL])\\n );\\n }\\n\\n public onCompleteAsInt(onComplete: (value: number) => void): void {\\n this._onComplete(\\n this.toAsync(onComplete),\\n new Set([TokenType.VALUE_NUMBER_INT, TokenType.VALUE_NULL])\\n );\\n }\\n\\n public onCompleteAsIntAsync(onComplete: (value: number) => Promise<void>): void {\\n this._onComplete(\\n onComplete,\\n new Set([TokenType.VALUE_NUMBER_INT, TokenType.VALUE_NULL])\\n );\\n }\\n\\n public onCompleteAsNumber(onComplete: (value: number) => void): void {\\n this._onComplete(\\n this.toAsync(onComplete),\\n new Set([TokenType.VALUE_NUMBER_INT, TokenType.VALUE_NUMBER_FLOAT, TokenType.VALUE_NULL])\\n );\\n }\\n\\n public onCompleteAsNumberAsync(onComplete: (value: number) => Promise<void>): void {\\n this._onComplete(\\n onComplete,\\n new Set([TokenType.VALUE_NUMBER_INT, TokenType.VALUE_NUMBER_FLOAT, TokenType.VALUE_NULL])\\n );\\n }\\n\\n public onCompleteAsBoolean(onComplete: (value: boolean) => void): void {\\n this._onComplete(\\n this.toAsync(onComplete),\\n new Set([TokenType.VALUE_TRUE, TokenType.VALUE_FALSE, TokenType.VALUE_NULL])\\n );\\n }\\n\\n public onCompleteAsBooleanAsync(onComplete: (value: boolean) => Promise<void>): void {\\n this._onComplete(\\n onComplete,\\n new Set([TokenType.VALUE_TRUE, TokenType.VALUE_FALSE, TokenType.VALUE_NULL])\\n );\\n }\\n\\n public whenComplete(): Promise<string> {\\n return new Promise<string>(resolve => {\\n this.onComplete(value => resolve(value));\\n });\\n }\\n\\n public asJsonFlux(): Flux<string> {\\n return Flux.create<string>((push, complete) => {\\n this.onEachExcerpt(excerpt => {\\n if (excerpt.source) {\\n push(excerpt.source);\\n }\\n });\\n this._onComplete(async () => complete());\\n });\\n }\\n\\n public whenCompleteAs<T>(): Promise<T> {\\n return new Promise<T>(resolve => {\\n this.onCompleteAs(resolve);\\n });\\n }\\n\\n public async push(excerpt: JsonExcerpt): Promise<void> {\\n const token = excerpt.token;\\n\\n this.onEachExcerptCallbacks.forEach(callback => callback(excerpt));\\n\\n if (this.isState(InNested)) {\\n return (this.state as InNested).child.push(excerpt);\\n }\\n\\n if (!token) {\\n return;\\n }\\n\\n const tokenType = token.type;\\n this.currentToken = token;\\n\\n if (this.isState(Begin)) {\\n switch (tokenType) {\\n case TokenType.START_OBJECT: {\\n if (this.onElementCallbacks.size > 0) {\\n throw new Error(\\\"registered onElement for object\\\");\\n }\\n this.state = new InObject();\\n this.receivedJson.push(token.source);\\n return;\\n }\\n\\n case TokenType.START_ARRAY: {\\n if (this.propertyCallbacks.size > 0) {\\n throw new Error(\\\"registered onProperty for array\\\");\\n }\\n this.state = new InArray();\\n this.receivedJson.push(token.source);\\n return;\\n }\\n\\n case TokenType.VALUE_STRING:\\n case TokenType.VALUE_NUMBER_INT:\\n case TokenType.VALUE_NUMBER_FLOAT:\\n case TokenType.VALUE_TRUE:\\n case TokenType.VALUE_FALSE:\\n case TokenType.VALUE_NULL:\\n this.receivedJson.push(token.source);\\n return this.end();\\n\\n default:\\n throw new UnexpectedTokenException(token);\\n }\\n } else if (this.isState(InObject)) {\\n switch (tokenType) {\\n case TokenType.FIELD_NAME: {\\n this.receivedJson.push(token.source);\\n return;\\n }\\n\\n case TokenType.END_OBJECT: {\\n this.receivedJson.push(token.source);\\n return this.end();\\n }\\n\\n case TokenType.START_OBJECT:\\n case TokenType.START_ARRAY:\\n case TokenType.VALUE_STRING:\\n case TokenType.VALUE_NUMBER_INT:\\n case TokenType.VALUE_NUMBER_FLOAT:\\n case TokenType.VALUE_TRUE:\\n case TokenType.VALUE_FALSE:\\n case TokenType.VALUE_NULL: {\\n const child = new StreamedJsonChildElement();\\n child.onComplete(resultingJson => {\\n this.receivedJson.push(resultingJson);\\n this.state = new InObject();\\n })\\n this.state = new InPropertyValue(child);\\n this.propertyCallbacks.get(token.fieldName!)\\n ?.forEach(callback => {\\n callback(child)\\n });\\n return child.push(excerpt);\\n }\\n\\n case TokenType.COMMA: {\\n this.receivedJson.push(token.source);\\n return;\\n }\\n\\n default:\\n throw new UnexpectedTokenException(token);\\n }\\n } else if (this.isState(InArray)) {\\n switch (tokenType) {\\n case TokenType.END_ARRAY: {\\n this.receivedJson.push(token.source);\\n return this.end();\\n }\\n\\n case TokenType.START_OBJECT:\\n case TokenType.START_ARRAY:\\n case TokenType.VALUE_STRING:\\n case TokenType.VALUE_NUMBER_INT:\\n case TokenType.VALUE_NUMBER_FLOAT:\\n case TokenType.VALUE_TRUE:\\n case TokenType.VALUE_FALSE:\\n case TokenType.VALUE_NULL: {\\n const child = new StreamedJsonChildElement();\\n child.onComplete(resultingJson => {\\n this.receivedJson.push(resultingJson);\\n this.state = new InArray();\\n })\\n this.onElementCallbacks.forEach(callback => callback(child));\\n this.state = new InArrayElement(child);\\n return child.push(excerpt);\\n }\\n\\n case TokenType.COMMA: {\\n this.receivedJson.push(token.source);\\n return;\\n }\\n\\n default:\\n throw new UnexpectedTokenException(token);\\n }\\n }\\n\\n throw new Error(\\\"Unknown state\\\");\\n }\\n\\n protected async end(): Promise<void> {\\n if (this.currentToken === undefined) {\\n throw new Error('Illegal state')\\n }\\n\\n this.onCompleteCallbacks.forEach(subscription => {\\n const expectedTokenType = subscription.expectedTokenType;\\n const completeValue = (() => {\\n if (expectedTokenType === undefined) {\\n return this.receivedJson.join('');\\n }\\n if (!expectedTokenType.has(this.currentToken!.type)) {\\n throw new Error(`Expected token type ${Array.from(expectedTokenType).join(', ')} but got ${this.currentToken!.type}`);\\n }\\n return this.currentToken!.value\\n })()\\n subscription.consumer(completeValue);\\n });\\n }\\n\\n private isState(stateClass: typeof Begin | typeof InArray | typeof InObject | typeof InNested): boolean {\\n return this.state instanceof stateClass;\\n }\\n\\n private endsOnUnevenNumberOfBackslashes(data: string): boolean {\\n let count = 0;\\n for (let i = data.length - 1; i >= 0; i--) {\\n if (data[i] === '\\\\\\\\') {\\n count++;\\n } else {\\n break;\\n }\\n }\\n return count % 2 === 1;\\n }\\n\\n private toAsync<T>(consumer: (value: T) => void): (value: T) => Promise<void> {\\n return async (value: T) => {\\n consumer(value);\\n };\\n }\\n}\\n\\n// State classes\\nabstract class State {\\n}\\n\\nclass InNested extends State {\\n constructor(public readonly child: StreamedJsonChildElement<AnyJson>) {\\n super();\\n }\\n}\\n\\nclass Begin extends State {\\n}\\n\\nclass InArray extends State {\\n}\\n\\nclass InArrayElement extends InNested {\\n constructor(child: StreamedJsonChildElement<AnyJson>) {\\n super(child);\\n }\\n}\\n\\nclass InObject extends State {\\n}\\n\\nclass InPropertyValue extends InNested {\\n constructor(child: StreamedJsonChildElement<AnyJson>) {\\n super(child);\\n }\\n}\\n\\nclass UnexpectedTokenException extends Error {\\n constructor(token: Token) {\\n super(`Unexpected token: ${token.type}`);\\n this.name = \\\"UnexpectedTokenException\\\";\\n }\\n}\\n\\n// Mock JsonTokenProcessor for onJsonStringProperty\\nclass JsonTokenProcessor {\\n getExcerpts(data: string): JsonExcerpt[] {\\n return [{source: data}];\\n }\\n}\\n\\nexport class StreamedJsonChildElement<T extends AnyJson> extends StreamedJsonElement<T> {\\n constructor() {\\n super();\\n }\\n}\\n\",\"export function nonNullish<T>(value: T | undefined | null): value is T\\n{\\n return value !== undefined && value !== null;\\n}\",\"import {JsonExcerpt} from './JsonExcerpt.js';\\nimport {StreamedJsonElement} from './StreamedJsonElement.js';\\nimport {Flux} from \\\"monoflux\\\";\\nimport {AnyJson} from '../index.js'\\n\\nexport class StreamedJsonRootElement<T extends AnyJson> extends StreamedJsonElement<T> {\\n protected readonly jsonTokenFlux: Flux<JsonExcerpt>\\n constructor(jsonTokenFlux: Flux<JsonExcerpt>) {\\n super();\\n const thiss = this\\n this.jsonTokenFlux = Flux.fromGeneratorFunction(async function* () {\\n let lastTokenExcerpt: JsonExcerpt | undefined = undefined;\\n for await (const excerpt of jsonTokenFlux) {\\n if (excerpt.token !== undefined) {\\n if (lastTokenExcerpt?.token?.maybeIncomplete && lastTokenExcerpt.token.type === excerpt.token.type && !excerpt.token.maybeIncomplete) {\\n await thiss.push(excerpt)\\n }\\n lastTokenExcerpt = excerpt.token;\\n }\\n if (excerpt.token === undefined || !excerpt.token.maybeIncomplete) {\\n await thiss.push(excerpt)\\n }\\n yield excerpt;\\n }\\n if (lastTokenExcerpt?.token?.maybeIncomplete) {\\n await thiss.push(lastTokenExcerpt)\\n }\\n })\\n }\\n\\n override whenComplete(): Promise<string> {\\n return this.jsonTokenFlux\\n .then(() => this.receivedJson.join(''));\\n }\\n\\n override asJsonFlux(): Flux<string> {\\n return this.jsonTokenFlux\\n .map(excerpt => excerpt.source)\\n .filter(source => source !== undefined)\\n }\\n}\\n\",\"import { JsonExcerpt } from './JsonExcerpt.js'\\nimport { StreamedJsonRootElement } from './StreamedJsonRootElement.js'\\nimport {Flux} from \\\"monoflux\\\";\\n\\nexport class StreamedJsonParser {\\n parse(jsonTokenFlux: Flux<JsonExcerpt>): StreamedJsonRootElement<any> {\\n return new StreamedJsonRootElement(jsonTokenFlux)\\n }\\n}\\n\",\"export function parseJsonWithUsefulError(completedJson: string) {\\n try {\\n return JSON.parse(completedJson)\\n } catch (e) {\\n throw new Error(`Failed to parse JSON with error '${(e as Error).message}'. JSON was: ${completedJson}`)\\n }\\n}\",\"import {parseJsonWithUsefulError} from '../util/parseJsonWithUsefulError.js'\\n\\ntype Scope = '{' | '['\\n | '\\\"prop' | '\\\"prop\\\"' | '\\\"prop\\\":'\\n | 'n' | 'nu' | 'nul'\\n | 't' | 'tr' | 'tru'\\n | 'f' | 'fa' | 'fal' | 'fals'\\n | '\\\"value'\\n | 'number.'\\n\\nexport type DeepPartial<T> = T extends object ? {\\n [P in keyof T]?: DeepPartial<T[P]>;\\n} : T;\\n\\nexport function parsePartialJson<T>(partialJson: string): DeepPartial<T> | undefined {\\n if (partialJson.trim() === '') {\\n return undefined\\n }\\n const opened: Scope[] = []\\n let escaped = false\\n const pushScope = (scope: Scope) => opened.push(scope)\\n const popScope = (...expect: Scope[]) => {\\n const lastOpened = opened[opened.length - 1]\\n if (lastOpened === undefined || !expect.includes(lastOpened)) {\\n throw new Error('illegal state')\\n }\\n opened.pop()\\n }\\n const illegalState = () => {\\n return new Error(`Illegal state (json: ${partialJson})`)\\n }\\n for (const char of partialJson) {\\n const scope = opened.length > 0 ? opened[opened.length - 1]! : null\\n let nextEscapedValue = false\\n if (char === '\\\"') {\\n if (scope === null) {\\n pushScope('\\\"value')\\n } else if (scope === '[' || scope === null) {\\n pushScope('\\\"value')\\n } else if (scope === '{') {\\n pushScope('\\\"prop')\\n } else if (scope === '\\\"prop\\\":') {\\n popScope('\\\"prop\\\":')\\n pushScope('\\\"value')\\n } else if (scope === '\\\"prop') {\\n if (!escaped) {\\n popScope('\\\"prop')\\n pushScope('\\\"prop\\\"')\\n }\\n } else if (scope === '\\\"value') {\\n if (!escaped) {\\n popScope('\\\"value')\\n }\\n } else throw illegalState()\\n } else if (char === '[') {\\n if (scope === '[' || scope === null) {\\n pushScope('[')\\n } else if (scope === '\\\"prop\\\":') {\\n popScope('\\\"prop\\\":')\\n pushScope('[')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState()\\n } else if (char === '{') {\\n if (scope === null || scope === '[' || scope === '\\\"prop\\\":') {\\n pushScope('{');\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState();\\n } else if (char === '\\\\\\\\') {\\n if (scope === '\\\"prop' || scope === '\\\"value') {\\n if (!escaped) {\\n nextEscapedValue = true;\\n }\\n } else throw illegalState();\\n } else if (char === ':') {\\n if (scope === '\\\"prop\\\"') {\\n popScope('\\\"prop\\\"');\\n pushScope('\\\"prop\\\":');\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState();\\n } else if (char === 'n') {\\n if (scope === '\\\"prop\\\":') {\\n popScope('\\\"prop\\\":');\\n pushScope('n');\\n } else if (scope === '[' || scope === null) {\\n pushScope('n')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState();\\n } else if (char === 'u') {\\n if (scope === 'n') {\\n popScope('n');\\n pushScope('nu');\\n } else if (scope === 'tr') {\\n popScope('tr');\\n pushScope('tru');\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState();\\n } else if (char === 'l') {\\n if (scope === 'nu') {\\n popScope('nu');\\n pushScope('nul');\\n } else if (scope === 'nul') {\\n popScope('nul');\\n } else if (scope === 'fa') {\\n popScope('fa');\\n pushScope('fal');\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState();\\n } else if (char === 't') {\\n if (scope === '\\\"prop\\\":') {\\n popScope('\\\"prop\\\":');\\n pushScope('t');\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else if (scope === '[' || scope === null) {\\n pushScope('t')\\n } else throw illegalState();\\n } else if (char === 'r') {\\n if (scope === 't') {\\n popScope('t');\\n pushScope('tr');\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState();\\n } else if (char === 'e') {\\n if (scope === 'tru') {\\n popScope('tru');\\n } else if (scope === 'fals') {\\n popScope('fals');\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState();\\n } else if (char === 'f') {\\n if (scope === '\\\"prop\\\":') {\\n popScope('\\\"prop\\\":')\\n pushScope('f')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else if (scope === '[' || scope === null) {\\n pushScope('f')\\n } else throw illegalState()\\n } else if (char === 'a') {\\n if (scope === 'f') {\\n popScope('f')\\n pushScope('fa')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState()\\n } else if (char === 's') {\\n if (scope === 'fal') {\\n popScope('fal')\\n pushScope('fals')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState()\\n } else if (char === '.') {\\n if (scope === '\\\"prop\\\":') {\\n popScope('\\\"prop\\\":')\\n pushScope('number.')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else if (scope === '{') {\\n pushScope('number.')\\n } else if (scope === '[' || scope === null) {\\n pushScope('number.')\\n } else throw illegalState()\\n } else if (char.match(/[0-9]/)) {\\n if (scope === 'number.') {\\n popScope('number.')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else if (scope === '\\\"prop\\\":') {\\n popScope('\\\"prop\\\":')\\n } else if (scope === '{' || scope === '[' || scope === null) {\\n // do nothing\\n } else throw illegalState()\\n } else if (char === '}') {\\n if (scope === '{') {\\n popScope('{')\\n } else if (scope === 'number.') {\\n popScope('number.')\\n popScope('{')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState()\\n } else if (char === ']') {\\n if (scope === '[') {\\n popScope('[')\\n } else if (scope === '\\\"prop' || scope === '\\\"value') {\\n // do nothing\\n } else throw illegalState()\\n } else if (char === ',') {\\n if (scope === 'number.') {\\n popScope('number.')\\n } else {\\n // do nothing\\n }\\n }\\n escaped = nextEscapedValue\\n }\\n const closeEverything = opened\\n .reverse()\\n .map(opener => {\\n switch (opener) {\\n case '{': return '}'\\n case '[': return ']'\\n case '\\\"prop': return '\\\": null'\\n case '\\\"prop\\\"': return ': null'\\n case '\\\"prop\\\":': return ' null'\\n case 'n': return 'ull'\\n case 'nu': return 'll'\\n case 'nul': return 'l'\\n case 't': return 'rue'\\n case 'tr': return 'ue'\\n case 'tru': return 'e'\\n case 'f': return 'alse'\\n case 'fa': return 'lse'\\n case 'fal': return 'se'\\n case 'fals': return 'e'\\n case '\\\"value': return '\\\"'\\n case 'number.': return '0'\\n default: throw illegalState()\\n }\\n })\\n .join('')\\n const partialJsonWithoutEndingOnEscapeSign = escaped\\n ? partialJson.substring(0, partialJson.length - 1)\\n : partialJson\\n const partialJsonWithoutEndingComma = partialJsonWithoutEndingOnEscapeSign\\n .replace(/( |\\\\n|,)+$/, '')\\n const completedJson = partialJsonWithoutEndingComma + closeEverything\\n return parseJsonWithUsefulError(completedJson)\\n}\",\"export function requireDefined<T>(value: T | undefined): T {\\n if (value === undefined) {\\n throw new Error('Value is undefined');\\n }\\n return value;\\n}\",\"import validate from './validate.js';\\nconst byteToHex = [];\\nfor (let i = 0; i < 256; ++i) {\\n byteToHex.push((i + 0x100).toString(16).slice(1));\\n}\\nexport function unsafeStringify(arr, offset = 0) {\\n return (byteToHex[arr[offset + 0]] +\\n byteToHex[arr[offset + 1]] +\\n byteToHex[arr[offset + 2]] +\\n byteToHex[arr[offset + 3]] +\\n '-' +\\n byteToHex[arr[offset + 4]] +\\n byteToHex[arr[offset + 5]] +\\n '-' +\\n byteToHex[arr[offset + 6]] +\\n byteToHex[arr[offset + 7]] +\\n '-' +\\n byteToHex[arr[offset + 8]] +\\n byteToHex[arr[offset + 9]] +\\n '-' +\\n byteToHex[arr[offset + 10]] +\\n byteToHex[arr[offset + 11]] +\\n byteToHex[arr[offset + 12]] +\\n byteToHex[arr[offset + 13]] +\\n byteToHex[arr[offset + 14]] +\\n byteToHex[arr[offset + 15]]).toLowerCase();\\n}\\nfunction stringify(arr, offset = 0) {\\n const uuid = unsafeStringify(arr, offset);\\n if (!validate(uuid)) {\\n throw TypeError('Stringified UUID is invalid');\\n }\\n return uuid;\\n}\\nexport default stringify;\\n\",\"import { randomFillSync } from 'crypto';\\nconst rnds8Pool = new Uint8Array(256);\\nlet poolPtr = rnds8Pool.length;\\nexport default function rng() {\\n if (poolPtr > rnds8Pool.length - 16) {\\n randomFillSync(rnds8Pool);\\n poolPtr = 0;\\n }\\n return rnds8Pool.slice(poolPtr, (poolPtr += 16));\\n}\\n\",\"import { randomUUID } from 'crypto';\\nexport default { randomUUID };\\n\",\"import native from './native.js';\\nimport rng from './rng.js';\\nimport { unsafeStringify } from './stringify.js';\\nfunction v4(options, buf, offset) {\\n if (native.randomUUID && !buf && !options) {\\n return native.randomUUID();\\n }\\n options = options || {};\\n const rnds = options.random ?? options.rng?.() ?? rng();\\n if (rnds.length < 16) {\\n throw new Error('Random bytes length must be >= 16');\\n }\\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\\n if (buf) {\\n offset = offset || 0;\\n if (offset < 0 || offset + 16 > buf.length) {\\n throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);\\n }\\n for (let i = 0; i < 16; ++i) {\\n buf[offset + i] = rnds[i];\\n }\\n return buf;\\n }\\n return unsafeStringify(rnds);\\n}\\nexport default v4;\\n\",\"import {AnyJson} from '../index.js'\\n\\nexport type Combine<Current, New> = unknown extends Current\\n ? New\\n : (Current & New) extends never\\n ? Current | New\\n : (Current & New)\\n\\n\\ntype Test = {foo: string} extends unknown ? true : false\\n\\ntype Bla = Combine<{foo: string}, {bar: string}>\\n\\ntype Simplify<T> = {\\n [K in keyof T]: Simplify<T[K]>\\n}\\n\\nexport type AssertTypeOpts = {\\n ignoreUnknownProps?: boolean\\n logValueIfWrong?: boolean\\n errorMessage?: string\\n juggleBetweenNullAndUndefined?: boolean\\n}\\n\\ntype Problem = {\\n path: string\\n expectedType?: Type[]\\n expectedProp?: string\\n value: unknown\\n unknownProp?: string\\n}\\n\\ntype Juggle = {value: unknown}\\n\\ntype UnionTypeConformity = {types: Type[], value: unknown, problems: Problem[], juggleTo?: Juggle}\\n\\ntype TypeConformity = {type: Type, value: unknown, problems: Problem[], juggleTo?: Juggle}\\n\\nclass ComplexTypeError extends Error {\\n public readonly data: any\\n public readonly httpStatus = 400\\n constructor(problems: Problem[], message?: string) {\\n const data = problems\\n .map(problem => {\\n if (problem.expectedProp) {\\n return {\\n expectedProp: (problem.path + '.').replace(/^root\\\\./, '') + problem.expectedProp\\n }\\n } else if (problem.expectedType) {\\n return {\\n expectedType: problem.expectedType.map(typeToString).join(' | '),\\n path: problem.path,\\n insteadGot: problem.value,\\n }\\n } else if (problem.unknownProp) {\\n return {\\n unknownProp: (problem.path + '.').replace(/^root\\\\./, '') + problem.unknownProp\\n }\\n } else {\\n throw new Error('illegal state')\\n }\\n })\\n super(message ?? `Value is of the wrong format: ${JSON.stringify(data, null, 2)}`)\\n this.data = data\\n }\\n}\\n\\n/**\\n * Way to assert the shape of a type both in runtime and in the\\n * type system.\\n *\\n * Usage example:\\n *\\n * ```typescript\\n * const inputValue = ['foo', 'bar'] as unknown\\n *\\n * assert(\\n * inputValue,\\n * t => t\\n * .canBeArray(t => t\\n * .canBeObject(t => t\\n * .canHaveString('foo')\\n * .canHaveString('bar')\\n * )\\n * )\\n * )\\n *\\n * let safeInputvalue = inputValue\\n *\\n * safeInputvalue = [{}] // typescript disapproves\\n * safeInputvalue = [{foo: 'bla', bar: 'bla'}] // typescript approves\\n * ```\\n */\\nexport function specType(\\n value: unknown,\\n): EmptyTypeSpec<unknown> {\\n return new EmptyTypeSpec<unknown>([], value)\\n}\\n\\nfunction conformsPerfectly(typeConformities: TypeConformity[]) {\\n return typeConformities.some(evaluation => evaluation.problems.length === 0 && evaluation.juggleTo === undefined)\\n}\\n\\nfunction juggleThatWouldMakeValueConform(evaluations: TypeConformity[]) {\\n const typeConformitiesThatPassWithJuggle = evaluations.filter(e => e.problems.length === 0 && e.juggleTo !== undefined)\\n if (typeConformitiesThatPassWithJuggle.length > 1) {\\n throw new Error('Illegal State')\\n }\\n return typeConformitiesThatPassWithJuggle[0]?.juggleTo\\n}\\n\\nfunction checkIsOneOf(value: unknown, types: Type[], path: string, opts: AssertTypeOpts): UnionTypeConformity {\\n const evaluations = types\\n .map(type => checkIs(value, type, path, opts))\\n if (conformsPerfectly(evaluations)) {\\n return {types, value, problems: []}\\n }\\n const juggleTo = juggleThatWouldMakeValueConform(evaluations)\\n if (juggleTo !== undefined) {\\n return {types, value, problems: [], juggleTo}\\n }\\n const typeProblemsOnThisPath = evaluations.flatMap(\\n evaluation => evaluation.problems\\n .filter(t => t.expectedType !== undefined && t.path === path)\\n )\\n if (typeProblemsOnThisPath.length > 0) {\\n return {\\n types,\\n value,\\n problems: [{\\n expectedType: typeProblemsOnThisPath\\n .flatMap(problem => problem.expectedType!),\\n path,\\n value\\n }],\\n }\\n }\\n return {\\n types,\\n value,\\n problems: evaluations.flatMap(list => list.problems)\\n }\\n}\\n\\nfunction checkIs(value: unknown, type: Type, path: string, opts: AssertTypeOpts): TypeConformity {\\n const {\\n ignoreUnknownProps = true,\\n juggleBetweenNullAndUndefined = false,\\n } = opts\\n const {\\n problems = [],\\n juggleTo,\\n } = ((): {problems?: Problem[], juggleTo?: Juggle} => {\\n switch (type.type) {\\n case \\\"array\\\": {\\n if (!Array.isArray(value)) {\\n return {problems: [{expectedType: [type], path, value}]}\\n }\\n if (value.length === 0) {\\n return {}\\n }\\n const elementConformities = value\\n .map(\\n element => checkIsOneOf(element, type.elementType, path + '[..]', opts)\\n )\\n const juggleTo = (() => {\\n if (elementConformities.filter(c => c.juggleTo).length === 0) {\\n return undefined\\n }\\n return {\\n value: elementConformities.map(\\n c => c.juggleTo === undefined ? c.value : c.juggleTo.value\\n )\\n }\\n })()\\n const problems = elementConformities.flatMap(c => c.problems)\\n return {problems, juggleTo}\\n }\\n case \\\"boolean\\\": {\\n if (typeof value !== 'boolean') {\\n return {problems: [{expectedType: [type], path, value}]}\\n }\\n return {}\\n }\\n case \\\"undefined\\\": {\\n if (value === undefined) {\\n return {}\\n }\\n if (juggleBetweenNullAndUndefined && value === null) {\\n return {juggleTo: {value: undefined}}\\n }\\n return {problems: [{expectedType: [type], path, value}]}\\n }\\n case \\\"object\\\": {\\n if (typeof value !== 'object' || value === null) {\\n return {problems: [{expectedType: [type], path, value}]}\\n }\\n const problems: Problem[] = []\\n const juggles: {key: string, juggleTo: unknown}[] = []\\n for (const key in type.props) {\\n const prop = type.props[key]!\\n const typeConformity = checkIsOneOf(\\n key in value\\n ? value[key as keyof typeof value]\\n : undefined,\\n prop.optional\\n ? [...prop.type, {type: 'undefined'}]\\n : prop.type,\\n path + `.${key}`,\\n opts\\n )\\n if (typeConformity.juggleTo !== undefined) {\\n juggles.push({key, juggleTo: typeConformity.juggleTo.value})\\n }\\n problems.push(...typeConformity.problems)\\n }\\n if (!ignoreUnknownProps) {\\n for (const key in value) {\\n if (!(key in type.props)) {\\n problems.push({unknownProp: key, path, value})\\n }\\n }\\n }\\n return {\\n problems,\\n juggleTo: (() => {\\n if (juggles.length === 0) {\\n return undefined\\n }\\n const newValue = {...value}\\n for (const juggle of juggles) {\\n (newValue as any)[juggle.key] = juggle.juggleTo\\n }\\n return {value: newValue}\\n })()\\n }\\n }\\n case \\\"string\\\": {\\n return {\\n problems: typeof value === 'string'\\n ? []\\n : [{expectedType: [type], path, value}],\\n }\\n }\\n case \\\"null\\\": {\\n if (value === null) {\\n return {}\\n }\\n if (juggleBetweenNullAndUndefined && value === undefined) {\\n return {juggleTo: {value: null}}\\n }\\n return {problems: [{expectedType: [type], path, value}]}\\n }\\n case \\\"number\\\": {\\n return {\\n problems: typeof value === 'number'\\n ? []\\n : [{expectedType: [type], path, value}],\\n }\\n }\\n case 'constant': {\\n return {\\n problems: value === type.value\\n ? []\\n : [{expectedType: [type], path, value}],\\n }\\n }\\n }\\n })()\\n return {type, value, problems, juggleTo}\\n}\\n\\nexport abstract class TypeSpec<T> {\\n constructor(\\n protected readonly type: Type[],\\n protected readonly value: unknown,\\n protected readonly _: T = undefined as any// type holder\\n ) {}\\n}\\n\\nexport class EmptyTypeSpec<T> extends TypeSpec<T> {\\n array<T_arr = unknown>(element: (arg: EmptyTypeSpec<unknown>) => TypeSpec<T_arr>) {\\n const elementSpec = element(new EmptyTypeSpec<unknown>([], this.value))\\n const arraySpec = new FullTypeSpec<unknown>(\\n [{type: 'array', elementType: elementSpec['type']}],\\n this.value\\n )\\n return new FullTypeSpec<Combine<T, T_arr[]>>([...this.type, ...arraySpec['type']], this.value)\\n }\\n\\n object<T_obj extends {}>(properties: (arg: TypeMemberSpec<{}>) => TypeMemberSpec<T_obj>) {\\n const objectSpec = properties(new TypeMemberSpec<{}>([{type: 'object', props: {}}], this.value))\\n return new FullTypeSpec<Combine<T, T_obj>>([...this.type, ...objectSpec['type']], this.value)\\n }\\n\\n string() {\\n return new FullTypeSpec<Combine<T, string>>([...this.type, {type: 'string'}], this.value)\\n }\\n\\n number() {\\n return new FullTypeSpec<Combine<T, number>>([...this.type, {type: 'number'}], this.value)\\n }\\n\\n boolean() {\\n return new FullTypeSpec<Combine<T, boolean>>([...this.type, {type: 'boolean'}], this.value)\\n }\\n\\n constant<Value extends (string | number | boolean)>(value: Value, ...otherValues: Value[]) {\\n return new FullPropTypeSpec<Combine<T, Value>>(\\n [\\n ...this.type,\\n {type: 'constant', value},\\n ...(otherValues ?? []).map(value => ({type: 'constant' as const, value}))\\n ],\\n this.value\\n )\\n }\\n\\n null() {\\n return new FullTypeSpec<Combine<T, null>>([...this.type, {type: 'null'}], this.value)\\n }\\n\\n undefined() {\\n return new FullTypeSpec<Combine<T, undefined>>([...this.type, {type: 'undefined'}], this.value)\\n }\\n\\n any() {\\n return new FullTypeSpec<Combine<T, AnyJson>>([], this.value)\\n }\\n}\\n\\nexport class FullTypeSpec<T> extends TypeSpec<T> {\\n orArray<T_arr = unknown>(element: (arg: TypeSpec<unknown>) => TypeSpec<T_arr>) {\\n const elementSpec = element(new FullTypeSpec<unknown>([], this.value))\\n const arraySpec = new FullTypeSpec<unknown>(\\n [{type: 'array', elementType: elementSpec['type']}],\\n this.value\\n )\\n return new FullTypeSpec<Combine<T, T_arr[]>>([...this.type, ...arraySpec.type], this.value)\\n }\\n\\n orObject<T_obj extends {}>(properties: (arg: TypeMemberSpec<{}>) => TypeMemberSpec<T_obj>) {\\n const objectSpec = properties(new TypeMemberSpec<{}>([{type: 'object', props: {}}], this.value))\\n return new FullTypeSpec<Combine<T, T_obj>>([...this.type, ...objectSpec['type']], this.value)\\n }\\n\\n orString() {\\n return new FullTypeSpec<Combine<T, string>>([...this.type, {type: 'string'}], this.value)\\n }\\n\\n orNumber() {\\n return new FullTypeSpec<Combine<T, number>>([...this.type, {type: 'number'}], this.value)\\n }\\n\\n orBoolean() {\\n return new FullTypeSpec<Combine<T, boolean>>([...this.type, {type: 'boolean'}], this.value)\\n }\\n\\n orConstant<Value extends (string | number | boolean)>(value: Value, ...otherValues: Value[]) {\\n return new FullPropTypeSpec<Combine<T, Value>>(\\n [\\n ...this.type,\\n {type: 'constant', value},\\n ...(otherValues ?? []).map(value => ({type: 'constant' as const, value}))\\n ],\\n this.value\\n )\\n }\\n\\n orNull() {\\n return new FullTypeSpec<Combine<T, null>>([...this.type, {type: 'null'}], this.value)\\n }\\n\\n orUndefined() {\\n return new FullTypeSpec<Combine<T, undefined>>([...this.type, {type: 'undefined'}], this.value)\\n }\\n}\\n\\nexport class TypeMemberSpec<T> {\\n constructor(\\n protected readonly type: Type[],\\n private readonly value: unknown\\n ) {}\\n\\n mayHave<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: EmptyPropTypeSpec<unknown>) => PropTypeSpec<T_prop>,\\n hint?: string,\\n ): TypeMemberSpec<Combine<T, Partial<Record<Key, T_prop>>>> {\\n return this.has(propertyName, assertTypeOfProperty, true, hint)\\n }\\n\\n canHaveString<Key extends string>(propertyName: Key, hint?: string): TypeMemberSpec<Combine<T, Partial<Record<Key, string>>>> {\\n return this.mayHave(propertyName, type => type.string(), hint)\\n }\\n\\n canHaveNumber<Key extends string>(propertyName: Key, hint?: string): TypeMemberSpec<Combine<T, Partial<Record<Key, number>>>> {\\n return this.mayHave(propertyName, type => type.number(), hint)\\n }\\n\\n canHaveBoolean<Key extends string>(propertyName: Key, hint?: string): TypeMemberSpec<Combine<T, Partial<Record<Key, boolean>>>> {\\n return this.mayHave(propertyName, type => type.boolean(), hint)\\n }\\n\\n canHaveConstant<Key extends string, Value extends (string | number | boolean)>(\\n propertyName: Key,\\n [firstConstant, ...otherConstants]: [Value, ...Value[]],\\n hint?: string\\n ): TypeMemberSpec<Combine<T, Partial<Record<Key, Value>>>> {\\n return this.mayHave(\\n propertyName,\\n type => type.constant(firstConstant, ...otherConstants),\\n hint,\\n )\\n }\\n\\n has<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: EmptyPropTypeSpec<unknown>) => PropTypeSpec<T_prop>,\\n optional: false,\\n comment?: string,\\n ): TypeMemberSpec<Combine<T, Record<Key, T_prop>>>\\n has<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: EmptyPropTypeSpec<unknown>) => PropTypeSpec<T_prop>,\\n comment?: string,\\n ): TypeMemberSpec<Combine<T, Record<Key, T_prop>>>\\n has<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: EmptyPropTypeSpec<unknown>) => PropTypeSpec<T_prop>,\\n optional?: boolean,\\n comment?: string,\\n ): TypeMemberSpec<Combine<T, Partial<Record<Key, T_prop>>>>\\n has<Key extends string, T_prop>(\\n propertyName: Key,\\n assertTypeOfProperty: (arg: EmptyPropTypeSpec<unknown>) => PropTypeSpec<T_prop>,\\n arg3: boolean | string = false,\\n arg4?: string,\\n ): TypeMemberSpec<Combine<T, Record<Key, T_prop> | Partial<Record<Key, T_prop>>>> {\\n const {\\n optional,\\n comment,\\n }: {optional: boolean, comment: string | undefined} = (() => {\\n if (typeof arg3 === 'string') {\\n return {\\n optional: false,\\n comment: arg3,\\n }\\n } else {\\n return {\\n optional: arg3,\\n comment: arg4,\\n }\\n }\\n })()\\n const old = this.type.length === 1\\n ? this.type[0]!\\n : undefined\\n if (old === undefined || old.type !== 'object') {\\n throw new Error('illegal state')\\n }\\n const propertyTypeSpec = assertTypeOfProperty(new EmptyPropTypeSpec([], this.value))\\n const propertyType = propertyTypeSpec['type']\\n const commentsFromPropTypeSpec = propertyTypeSpec['_comments']\\n return new TypeMemberSpec<Combine<T, Record<Key, T_prop>>>([{\\n ...old,\\n props: {\\n ...old.props,\\n [propertyName]: {\\n optional,\\n type: propertyType,\\n comment: (() => {\\n const comments = [\\n ...commentsFromPropTypeSpec,\\n ...(comment !== undefined ? [comment] : []),\\n ]\\n return comments.length > 0\\n ? comments.join('. ')\\n : undefined\\n })(),\\n }\\n }\\n }], this.value)\\n }\\n\\n hasString<Key extends string>(propertyName: Key, comment?: string): TypeMemberSpec<Combine<T, Record<Key, string>>> {\\n return this.has(\\n propertyName,\\n type => type.string(),\\n false,\\n comment,\\n )\\n }\\n\\n hasNumber<Key extends string>(propertyName: Key, comment?: string): TypeMemberSpec<Combine<T, Record<Key, number>>> {\\n return this.has(\\n propertyName,\\n type => type.number(),\\n false,\\n comment,\\n )\\n }\\n\\n hasBoolean<Key extends string>(propertyName: Key, comment?: string): TypeMemberSpec<Combine<T, Record<Key, boolean>>> {\\n return this.has(\\n propertyName,\\n type => type.boolean(),\\n false,\\n comment,\\n )\\n }\\n\\n hasConstant<Key extends string, Value extends (string | number | boolean)>(propertyName: Key, ...constants: [Value, ...Value[]]): TypeMemberSpec<Combine<T, Record<Key, Value>>>\\n hasConstant<Key extends string, Value extends (string | number | boolean)>(propertyName: Key, [firstConstant, ...otherConstants]: [Value, ...Value[]], comment?: string): TypeMemberSpec<Combine<T, Record<Key, Value>>>\\n hasConstant<Key extends string, Value extends (string | number | boolean)>(\\n propertyName: Key,\\n arg2: Value | [Value, ...Value[]],\\n arg3?: Value | string,\\n ...otherArgs: Value[]\\n ): TypeMemberSpec<Combine<T, Record<Key, Value>>> {\\n const {\\n constants,\\n comment,\\n }: {constants: [Value, ...Value[]], comment?: string} = (() => {\\n if (Array.isArray(arg2)) {\\n return {\\n constants: arg2,\\n comment: arg3 as string | undefined,\\n }\\n } else {\\n return {\\n constants: [\\n arg2,\\n ...(arg3 !== undefined ? [arg3 as Value] : []),\\n ...otherArgs\\n ],\\n comment: undefined,\\n }\\n }\\n })()\\n return this.has(\\n propertyName,\\n type => type.constant(...constants),\\n false,\\n comment,\\n )\\n }\\n}\\n\\nexport abstract class PropTypeSpec<T> extends TypeSpec<T> {\\n constructor(\\n type: Type[],\\n value: unknown,\\n private _comments: string[] = [],\\n ) {\\n super(type, value)\\n }\\n\\n /**\\n * Give a comment to the LLM about this property\\n */\\n withComment(message: string) {\\n return new FullPropTypeSpec<Combine<T, string>>(this.type, this.value, [...this._comments, message])\\n }\\n}\\n\\nexport class EmptyPropTypeSpec<T> extends PropTypeSpec<T> {\\n array<T_arr = unknown>(element: (arg: EmptyTypeSpec<unknown>) => TypeSpec<T_arr>) {\\n const elementSpec = element(new EmptyTypeSpec<unknown>([], this.value))\\n const arraySpec = new FullTypeSpec<unknown>(\\n [{type: 'array', elementType: elementSpec['type']}],\\n this.value\\n )\\n return new FullPropTypeSpec<Combine<T, T_arr[]>>([...this.type, ...arraySpec['type']], this.value)\\n }\\n\\n object<T_obj extends {}>(properties: (arg: TypeMemberSpec<{}>) => TypeMemberSpec<T_obj>) {\\n const objectSpec = properties(new TypeMemberSpec<{}>([{type: 'object', props: {}}], this.value))\\n return new FullPropTypeSpec<Combine<T, T_obj>>([...this.type, ...objectSpec['type']], this.value)\\n }\\n\\n string() {\\n return new FullPropTypeSpec<Combine<T, string>>([...this.type, {type: 'string'}], this.value)\\n }\\n\\n number() {\\n return new FullPropTypeSpec<Combine<T, number>>([...this.type, {type: 'number'}], this.value)\\n }\\n\\n boolean() {\\n return new FullPropTypeSpec<Combine<T, boolean>>([...this.type, {type: 'boolean'}], this.value)\\n }\\n\\n constant<Value extends (string | number | boolean)>(...values: [Value, ...Value[]]) {\\n return new FullPropTypeSpec<Combine<T, Value>>(\\n [\\n ...this.type,\\n ...values.map(value => ({type: 'constant' as const, value}))\\n ],\\n this.value\\n )\\n }\\n\\n null() {\\n return new FullPropTypeSpec<Combine<T, null>>([...this.type, {type: 'null'}], this.value)\\n }\\n\\n undefined() {\\n return new FullPropTypeSpec<Combine<T, undefined>>([...this.type, {type: 'undefined'}], this.value)\\n }\\n}\\n\\nexport class FullPropTypeSpec<T> extends PropTypeSpec<T> {\\n orArray<T_arr = unknown>(element: (arg: TypeSpec<unknown>) => TypeSpec<T_arr>) {\\n const elementSpec = element(new FullTypeSpec<unknown>([], this.value))\\n const arraySpec = new FullTypeSpec<unknown>(\\n [{type: 'array', elementType: elementSpec['type']}],\\n this.value\\n )\\n return new FullPropTypeSpec<Combine<T, T_arr[]>>([...this.type, ...arraySpec['type']], this.value)\\n }\\n\\n orObject<T_obj extends {}>(properties: (arg: TypeMemberSpec<{}>) => TypeMemberSpec<T_obj>) {\\n const objectSpec = properties(new TypeMemberSpec<{}>([{type: 'object', props: {}}], this.value))\\n return new FullPropTypeSpec<Combine<T, T_obj>>([...this.type, ...objectSpec['type']], this.value)\\n }\\n\\n orString() {\\n return new FullPropTypeSpec<Combine<T, string>>([...this.type, {type: 'string'}], this.value)\\n }\\n\\n orNumber() {\\n return new FullPropTypeSpec<Combine<T, number>>([...this.type, {type: 'number'}], this.value)\\n }\\n\\n orBoolean() {\\n return new FullPropTypeSpec<Combine<T, boolean>>([...this.type, {type: 'boolean'}], this.value)\\n }\\n\\n orConstant<Value extends (string | number | boolean)>(...values: [Value, ...Value[]]) {\\n return new FullPropTypeSpec<Combine<T, Value>>(\\n [\\n ...this.type,\\n ...values.map(value => ({type: 'constant' as const, value}))\\n ],\\n this.value\\n )\\n }\\n\\n orNull() {\\n return new FullPropTypeSpec<Combine<T, null>>([...this.type, {type: 'null'}], this.value)\\n }\\n\\n orUndefined() {\\n return new FullPropTypeSpec<Combine<T, undefined>>([...this.type, {type: 'undefined'}], this.value)\\n }\\n}\\n\\nexport function assertType<T>(\\n value: unknown,\\n typeSpec: TypeSpec<T>,\\n opts: AssertTypeOpts = {}\\n): T {\\n const {problems, juggleTo} = checkIsOneOf(value, typeSpec['type'], 'root', opts)\\n if (problems.length > 0) {\\n throw new ComplexTypeError(problems, opts.errorMessage)\\n }\\n return juggleTo !== undefined\\n ? juggleTo.value as T\\n : value as T\\n}\\n\\nexport function describeType(typeSpec: TypeSpec<any>): string {\\n return describe(typeSpec['type'])\\n}\\n\\nexport function describe(type: Type[] | Type, indentLevel = 0): string {\\n if (Array.isArray(type)) {\\n return type.map(t => describe(t, indentLevel)).join(' | ')\\n }\\n switch (type.type) {\\n case \\\"array\\\": {\\n return `${describe(type.elementType, indentLevel)}[]`\\n }\\n case \\\"boolean\\\": {\\n return 'boolean'\\n }\\n case \\\"undefined\\\": {\\n return 'undefined'\\n }\\n case \\\"object\\\": {\\n const keys = Object.keys(type.props)\\n return `{\\\\n`\\n +\\n keys.map((key, i) => {\\n const propSpec = type.props[key]!\\n const value = describe(\\n propSpec.type,\\n indentLevel + 1\\n )\\n const comma = i < keys.length - 1 ? ',' : ''\\n const comment = propSpec.comment !== undefined ? ` // ${propSpec.comment}` : ''\\n return propSpec.optional\\n ? `${indent(indentLevel + 1)}${key}?: ${value}${comma}${comment}\\\\n`\\n : `${indent(indentLevel + 1)}${key}: ${value}${comma}${comment}\\\\n`\\n }).join('')\\n + `${indent(indentLevel)}}`\\n }\\n case \\\"string\\\": {\\n return 'string'\\n }\\n case \\\"null\\\": {\\n return 'null'\\n }\\n case \\\"number\\\": {\\n return 'number'\\n }\\n case 'constant': {\\n return `\\\"${type.value}\\\"`\\n }\\n }\\n}\\n\\nfunction indent(depth: number) {\\n let indent = ''\\n for (let i = 0; i < depth; i++) {\\n indent += ' '\\n }\\n return indent\\n}\\n\\nexport type TypeType = 'undefined' | 'null' | 'boolean' | 'string' | 'number' | 'object' | 'array' | 'constant'\\n\\nexport type BaseType<TT extends TypeType> = {\\n type: TT\\n}\\n\\nexport type UndefinedType = BaseType<'undefined'>\\nexport type NullType = BaseType<'null'>\\nexport type BooleanType = BaseType<'boolean'>\\nexport type StringType = BaseType<'string'>\\nexport type NumberType = BaseType<'number'>\\nexport type ObjectType = BaseType<'object'> & {\\n props: Record<string, {\\n optional: boolean\\n type: Type[]\\n comment: string | undefined\\n }>\\n}\\nexport type ArrayType = BaseType<'array'> & {\\n elementType: Type[]\\n}\\nexport type ConstantType<Value extends (string | number | boolean)> = BaseType<'constant'> & {\\n value: Value\\n}\\n\\nexport type Type = UndefinedType | NullType | BooleanType | StringType | NumberType | ObjectType | ArrayType | ConstantType<any>\\n\\nfunction typeToString(type: Type) {\\n return type.type === 'constant'\\n ? `'${type.value}'`\\n : type.type\\n}\\n\",\"import {OpenaiImageModelId} from './OpenaiImageModelId.js'\\n\\ntype OpenAIImageResponse = {\\n data: Array<{\\n b64_json?: string\\n url?: string\\n revised_prompt?: string\\n }>\\n}\\n\\nexport async function promptOpenaiImageGen(\\n apiKey: string,\\n prompt: string,\\n model: OpenaiImageModelId = 'gpt-image-1',\\n size?: ImageSize,\\n) {\\n const response = await fetch('https://api.openai.com/v1/images/generations', {\\n method: 'POST',\\n headers: {\\n 'Content-Type': 'application/json',\\n 'Authorization': `Bearer ${apiKey}`\\n },\\n body: JSON.stringify({\\n model,\\n prompt,\\n size,\\n })\\n })\\n\\n if (!response.ok) {\\n const errorData = await response.json() as Record<string, unknown>\\n throw new Error(`OpenAI API error: ${response.status} ${JSON.stringify(errorData)}`)\\n }\\n\\n const result = await response.json() as OpenAIImageResponse\\n \\n // Ensure we have a valid response structure\\n if (!result.data?.[0]?.b64_json) {\\n throw new Error('Invalid response structure from OpenAI API')\\n }\\n \\n const image_base64 = result.data[0].b64_json\\n \\n // Handle both Node.js and browser environments\\n return Uint8Array.from(atob(image_base64), c => c.charCodeAt(0)) as any\\n}\\n\\nexport type ImageSize =\\n | '1024x1024'\\n | '1536x1024'\\n | '1024x1536'\\n | '256x256'\\n | '512x512'\\n | '1792x1024'\\n | '1024x1792'\",\"export const AiModel = {\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.0015/1K tokens | \\\\$0.0020/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-3.5-turbo)\\n */\\n gpt_3_5_turbo: 'gpt-3.5-turbo',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.0005/1K tokens | \\\\$0.0015/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-3.5-turbo-0125)\\n */\\n gpt_3_5_turbo_0125: 'gpt-3.5-turbo-0125',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.0010/1K tokens | \\\\$0.0020/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-3.5-turbo-1106)\\n */\\n gpt_3_5_turbo_1106: 'gpt-3.5-turbo-1106',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.003/1K tokens | \\\\$0.004/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-3.5-turbo-16k)\\n */\\n gpt_3_5_turbo_16k: 'gpt-3.5-turbo-16k',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.0015/1K tokens | \\\\$0.0020/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-3.5-turbo-instruct)\\n */\\n gpt_3_5_turbo_instruct: 'gpt-3.5-turbo-instruct',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.0015/1K tokens | \\\\$0.0020/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-3.5-turbo-instruct-0914)\\n */\\n gpt_3_5_turbo_instruct_0914: 'gpt-3.5-turbo-instruct-0914',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.03/1K tokens | \\\\$0.06/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4)\\n */\\n gpt_4: 'gpt-4',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.01/1K tokens | \\\\$0.03/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4-0125-preview)\\n */\\n gpt_4_0125_preview: 'gpt-4-0125-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.03/1K tokens | \\\\$0.06/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4-0613)\\n */\\n gpt_4_0613: 'gpt-4-0613',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.01/1K tokens | \\\\$0.03/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4-1106-preview)\\n */\\n gpt_4_1106_preview: 'gpt-4-1106-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.01/1K tokens | \\\\$0.03/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4-turbo)\\n */\\n gpt_4_turbo: 'gpt-4-turbo',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.01/1K tokens | \\\\$0.03/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4-turbo-2024-04-09)\\n */\\n gpt_4_turbo_2024_04_09: 'gpt-4-turbo-2024-04-09',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.01/1K tokens | \\\\$0.03/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4-turbo-preview)\\n */\\n gpt_4_turbo_preview: 'gpt-4-turbo-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4.1)\\n */\\n gpt_4_1: 'gpt-4.1',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4.1-2025-04-14)\\n */\\n gpt_4_1_2025_04_14: 'gpt-4.1-2025-04-14',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4.1-mini)\\n */\\n gpt_4_1_mini: 'gpt-4.1-mini',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4.1-mini-2025-04-14)\\n */\\n gpt_4_1_mini_2025_04_14: 'gpt-4.1-mini-2025-04-14',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○ | Low |\\n * | Speed | ○○○○○ | Very Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4.1-nano)\\n */\\n gpt_4_1_nano: 'gpt-4.1-nano',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○ | Low |\\n * | Speed | ○○○○○ | Very Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4.1-nano-2025-04-14)\\n */\\n gpt_4_1_nano_2025_04_14: 'gpt-4.1-nano-2025-04-14',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.005/1K tokens | \\\\$0.015/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o)\\n */\\n gpt_4o: 'gpt-4o',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.005/1K tokens | \\\\$0.015/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-2024-05-13)\\n */\\n gpt_4o_2024_05_13: 'gpt-4o-2024-05-13',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.005/1K tokens | \\\\$0.015/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-2024-08-06)\\n */\\n gpt_4o_2024_08_06: 'gpt-4o-2024-08-06',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.005/1K tokens | \\\\$0.015/1K tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-2024-11-20)\\n */\\n gpt_4o_2024_11_20: 'gpt-4o-2024-11-20',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-audio-preview)\\n */\\n gpt_4o_audio_preview: 'gpt-4o-audio-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-audio-preview-2024-10-01)\\n */\\n gpt_4o_audio_preview_2024_10_01: 'gpt-4o-audio-preview-2024-10-01',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-audio-preview-2024-12-17)\\n */\\n gpt_4o_audio_preview_2024_12_17: 'gpt-4o-audio-preview-2024-12-17',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-audio-preview-2025-06-03)\\n */\\n gpt_4o_audio_preview_2025_06_03: 'gpt-4o-audio-preview-2025-06-03',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.150/1M tokens | \\\\$0.600/1M tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini)\\n */\\n gpt_4o_mini: 'gpt-4o-mini',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$0.150/1M tokens | \\\\$0.600/1M tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-2024-07-18)\\n */\\n gpt_4o_mini_2024_07_18: 'gpt-4o-mini-2024-07-18',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-audio-preview)\\n */\\n gpt_4o_mini_audio_preview: 'gpt-4o-mini-audio-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-audio-preview-2024-12-17)\\n */\\n gpt_4o_mini_audio_preview_2024_12_17: 'gpt-4o-mini-audio-preview-2024-12-17',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-realtime-preview)\\n */\\n gpt_4o_mini_realtime_preview: 'gpt-4o-mini-realtime-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-realtime-preview-2024-12-17)\\n */\\n gpt_4o_mini_realtime_preview_2024_12_17: 'gpt-4o-mini-realtime-preview-2024-12-17',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-search-preview)\\n */\\n gpt_4o_mini_search_preview: 'gpt-4o-mini-search-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-search-preview-2025-03-11)\\n */\\n gpt_4o_mini_search_preview_2025_03_11: 'gpt-4o-mini-search-preview-2025-03-11',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Audio | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-transcribe)\\n */\\n gpt_4o_mini_transcribe: 'gpt-4o-mini-transcribe',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-mini-tts)\\n */\\n gpt_4o_mini_tts: 'gpt-4o-mini-tts',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-realtime-preview)\\n */\\n gpt_4o_realtime_preview: 'gpt-4o-realtime-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-realtime-preview-2024-10-01)\\n */\\n gpt_4o_realtime_preview_2024_10_01: 'gpt-4o-realtime-preview-2024-10-01',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text/Audio | Text/Audio |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-realtime-preview-2024-12-17)\\n */\\n gpt_4o_realtime_preview_2024_12_17: 'gpt-4o-realtime-preview-2024-12-17',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-realtime-preview-2025-06-03)\\n */\\n gpt_4o_realtime_preview_2025_06_03: 'gpt-4o-realtime-preview-2025-06-03',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-search-preview)\\n */\\n gpt_4o_search_preview: 'gpt-4o-search-preview',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-search-preview-2025-03-11)\\n */\\n gpt_4o_search_preview_2025_03_11: 'gpt-4o-search-preview-2025-03-11',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Audio | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-4o-transcribe)\\n */\\n gpt_4o_transcribe: 'gpt-4o-transcribe',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-5)\\n */\\n gpt_5: 'gpt-5',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-5-2025-08-07)\\n */\\n gpt_5_2025_08_07: 'gpt-5-2025-08-07',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-5-chat-latest)\\n */\\n gpt_5_chat_latest: 'gpt-5-chat-latest',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-5-mini)\\n */\\n gpt_5_mini: 'gpt-5-mini',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-5-mini-2025-08-07)\\n */\\n gpt_5_mini_2025_08_07: 'gpt-5-mini-2025-08-07',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-5-nano)\\n */\\n gpt_5_nano: 'gpt-5-nano',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-5-nano-2025-08-07)\\n */\\n gpt_5_nano_2025_08_07: 'gpt-5-nano-2025-08-07',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/gpt-image-1)\\n */\\n gpt_image_1: 'gpt-image-1',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○○ | Very High |\\n * | Speed | ○○ | Slow |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$15.00/1M tokens | \\\\$60.00/1M tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o1)\\n */\\n o1: 'o1',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○○ | Very High |\\n * | Speed | ○○ | Slow |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$15.00/1M tokens | \\\\$60.00/1M tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o1-2024-12-17)\\n */\\n o1_2024_12_17: 'o1-2024-12-17',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$3.00/1M tokens | \\\\$12.00/1M tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o1-mini)\\n */\\n o1_mini: 'o1-mini',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | \\\\$3.00/1M tokens | \\\\$12.00/1M tokens |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o1-mini-2024-09-12)\\n */\\n o1_mini_2024_09_12: 'o1-mini-2024-09-12',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○○ | Very High |\\n * | Speed | ○○ | Slow |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o1-pro)\\n */\\n o1_pro: 'o1-pro',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○○ | Very High |\\n * | Speed | ○○ | Slow |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o1-pro-2025-03-19)\\n */\\n o1_pro_2025_03_19: 'o1-pro-2025-03-19',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○○ | Very High |\\n * | Speed | ○○ | Slow |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o3)\\n */\\n o3: 'o3',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○○ | Very High |\\n * | Speed | ○○ | Slow |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o3-2025-04-16)\\n */\\n o3_2025_04_16: 'o3-2025-04-16',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o3-deep-research)\\n */\\n o3_deep_research: 'o3-deep-research',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o3-deep-research-2025-06-26)\\n */\\n o3_deep_research_2025_06_26: 'o3-deep-research-2025-06-26',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o3-mini)\\n */\\n o3_mini: 'o3-mini',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○○ | High |\\n * | Speed | ○○○ | Moderate |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o3-mini-2025-01-31)\\n */\\n o3_mini_2025_01_31: 'o3-mini-2025-01-31',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o3-pro)\\n */\\n o3_pro: 'o3-pro',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o3-pro-2025-06-10)\\n */\\n o3_pro_2025_06_10: 'o3-pro-2025-06-10',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o4-mini)\\n */\\n o4_mini: 'o4-mini',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o4-mini-2025-04-16)\\n */\\n o4_mini_2025_04_16: 'o4-mini-2025-04-16',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o4-mini-deep-research)\\n */\\n o4_mini_deep_research: 'o4-mini-deep-research',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ? | ? |\\n * | Speed | ? | ? |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/o4-mini-deep-research-2025-06-26)\\n */\\n o4_mini_deep_research_2025_06_26: 'o4-mini-deep-research-2025-06-26',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/omni-moderation-2024-09-26)\\n */\\n omni_moderation_2024_09_26: 'omni-moderation-2024-09-26',\\n /**\\n * | Attribute | Rating | Value |\\n * |----------------|-----------------|----------------|\\n * | Intelligence | ○○○ | Moderate |\\n * | Speed | ○○○○ | Fast |\\n * | | Input | Output |\\n * | Type | Text | Text |\\n * | Price | Unknown | Unknown |\\n * \\n * Note, this documentation is auto-generated and may contain errors. For the most accurate information, please refer to the official documentation.\\n * [Official doc](https://platform.openai.com/docs/models/omni-moderation-latest)\\n */\\n omni_moderation_latest: 'omni-moderation-latest'\\n} as const\\n\",\"export const OpenaiImageModel = {\\n dall_e_2: 'dall-e-2',\\n dall_e_3: 'dall-e-3',\\n gpt_image_1: 'gpt-image-1',\\n} as const\"],\"mappings\":\"oiBAAA,IAAaA,EAAb,MAAaC,EACQC,UACAC,SACAC,aACTC,GAAU,EAElB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