promptgun 1.1.3 → 1.1.4
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.d.ts +0 -1
- 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\",\"ne\",\"at\",\"fe\",\"Object\",\"defineProperty\",\"Flux_1\",\"ut\",\"enumerable\",\"get\",\"import_monoflux\",\"de\",\"useTypeSpecMessage\",\"model\",\"startsWith\",\"promptOpenai\",\"openAiRequest\",\"apiToken\",\"httpRequest\",\"url\",\"method\",\"headers\",\"Accept\",\"Authorization\",\"slice\",\"body\",\"Ne\",\"abortController\",\"AbortController\",\"response\",\"fetch\",\"signal\",\"JSON\",\"stringify\",\"status\",\"message\",\"bodyText\",\"parse\",\"errorMessage\",\"text\",\"buffer\",\"abort\",\"textDecoder\",\"decode\",\"parts\",\"split\",\"pop\",\"part\",\"trim\",\"eventText\",\"lines\",\"data\",\"line\",\"substring\",\"TextDecoder\",\"ComplexTypeError\",\"httpStatus\",\"problems\",\"problem\",\"expectedProp\",\"path\",\"replace\",\"expectedType\",\"typeToString\",\"join\",\"insteadGot\",\"unknownProp\",\"super\",\"requireThat\",\"TypeSpec\",\"checkIsOneOf\",\"types\",\"opts\",\"problemsPerType\",\"type\",\"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\",\"has\",\"canBeString\",\"hasNumber\",\"canBeNumber\",\"canHaveProperty\",\"assertTypeOfProperty\",\"old\",\"propertyType\",\"canBeBoolean\",\"canBeConstant\",\"canBeNull\",\"canBeUndefined\",\"andNothingElse\",\"orDefaultTo\",\"describe\",\"indentLevel\",\"keys\",\"indent\",\"depth\",\"config\",\"getPromptGridApiUrl\",\"rawValue\",\"url2\",\"backendUrlNotTriviallyIdentifiableInMinifiedCode\",\"Token\",\"source\",\"fieldName\",\"maybeIncomplete\",\"JsonTokenProcessor\",\"_JsonTokenProcessor\",\"jsonBuffer\",\"highestOffsetParsed\",\"toJsonTokenFlux\",\"dataBufferFlux\",\"processDataBuffer\",\"deltaContentFlux\",\"content\",\"getExcerpts\",\"token\",\"excerpts\",\"jsonParser\",\"JsonParser\",\"nextToken\",\"currentTokenLocation\",\"getCharOffset\",\"position\",\"currentTokenType\",\"parentFieldName\",\"currentValue\",\"context\",\"startPosition\",\"test\",\"char\",\"pushContext\",\"popContext\",\"currentContextType\",\"startPos\",\"endPos\",\"indexOf\",\"nextFourChars\",\"nextFiveChars\",\"numStr\",\"hasDecimal\",\"parseFloat\",\"parseInt\",\"mayBeIncomplete\",\"JsonParseException\",\"contextType\",\"currentContext\",\"name\",\"nonNullish\",\"StreamedJsonElement\",\"receivedJson\",\"propertyCallbacks\",\"Map\",\"onElementCallbacks\",\"Set\",\"onCompleteCallbacks\",\"onEachExcerptCallbacks\",\"currentToken\",\"state\",\"Begin\",\"receivedExcerpts\",\"onElement\",\"add\",\"onProperty\",\"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\",\"dt\",\"whenCompleteAs\",\"isState\",\"InNested\",\"child\",\"tokenType\",\"size\",\"InObject\",\"InArray\",\"end\",\"UnexpectedTokenException\",\"resultingJson\",\"InPropertyValue\",\"InArrayElement\",\"subscription\",\"completeValue\",\"from\",\"stateClass\",\"count\",\"State\",\"StreamedJsonRootElement\",\"jsonTokenFlux\",\"yt\",\"lastTokenExcerpt\",\"StreamedJsonParser\",\"parseJsonWithUsefulError\",\"completedJson\",\"parsePartialJson\",\"partialJson\",\"opened\",\"escaped\",\"pushScope\",\"scope\",\"popScope\",\"expect\",\"lastOpened\",\"includes\",\"illegalState\",\"nextEscapedValue\",\"match\",\"closeEverything\",\"reverse\",\"opener\",\"requireDefined\",\"byteToHex\",\"toString\",\"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\",\"hasBoolean\",\"hasConstant\",\"arg2\",\"otherArgs\",\"constants\",\"PropTypeSpec\",\"withComment\",\"_FullPropTypeSpec\",\"assertType\",\"typeSpec\",\"describeType\",\"propSpec\",\"comma\",\"promptOpenaiImageGen\",\"apiKey\",\"prompt\",\"ok\",\"errorData\",\"json\",\"b64_json\",\"atob\",\"charCodeAt\",\"writeFile\",\"typeSpecToJsonSchema\",\"convertType\",\"every\",\"enum\",\"anyOf\",\"required\",\"entries\",\"convertedType\",\"description\",\"additionalProperties\",\"items\",\"const\",\"genericLLMCallToOpenAiCall\",\"temperature\",\"topP\",\"requireJsonResponse\",\"jsonSchema\",\"serviceTier\",\"tools\",\"input\",\"item\",\"llmPlatformConversationItem\",\"llmPlatform\",\"call_id\",\"functionCallId\",\"output\",\"role\",\"top_p\",\"format\",\"schema\",\"strict\",\"service_tier\",\"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_audio\",\"gpt_audio_2025_08_28\",\"gpt_image_1\",\"gpt_realtime\",\"gpt_realtime_2025_08_28\",\"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\",\"messages\",\"apiKeyChain\",\"obtainAiClientData\",\"conversation\",\"chat\",\"arg1\",\"toPrompt\",\"effectiveMessages\",\"user\",\"m\",\"BasicPrompt\",\"getCallerFileNameAndLineNumber\",\"image\",\"ImagePrompt\",\"_AIConversation\",\"copyConversation\",\"_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\",\"_BasicPrompt\",\"promptSupplier\",\"promptSupplierArgs\",\"_temperature\",\"_topP\",\"_serviceTier\",\"_firstThink\",\"_strict\",\"promptName\",\"_tools\",\"_checks\",\"_genericPrompt\",\"computeGenericPrompt\",\"self\",\"executeLlmCall\",\"effectiveModel\",\"stringGenerator\",\"chunk\",\"RETRY_SIGNAL\",\"copy\",\"firstThink\",\"flex\",\"useFlexTier\",\"check\",\"attempts\",\"checks\",\"promptItemToMessage\",\"TypeSpecMarker\",\"genericPrompt\",\"typeSpecIndex\",\"toGenericPrompt\",\"jsonSpecContent\",\"jsonSpec\",\"jsonSpecMessage\",\"JsonPrompt\",\"getBoolean\",\"o\",\"getString\",\"getNumber\",\"getObject\",\"getArray\",\"JsonArrayPrompt\",\"getAny\",\"normalizedTools\",\"tool\",\"defineTool\",\"parameters\",\"function\",\"_JsonPrompt\",\"jsonTypeSupplier\",\"computePrompt\",\"streamingJsonRootElement\",\"getFlux\",\"jsonTokenProcessor\",\"rt\",\"lazyGenerator\",\"jsonExcerpt\",\"partialJsonGenerator\",\"accumulatedJson\",\"getResponse\",\"stringResult\",\"uncheckedPackedResult\",\"_responseAsStringPromise\",\"_getResponseAsString\",\"arrayElementGenerator\",\"typeSpecMessage\",\"toOpenAiMessage\",\"msg\",\"system\",\"assistant\",\"genericPromptWithJsonSpec\",\"convSavePromises\",\"promptFilename\",\"lineNumber\",\"promptLineNumber\",\"promptProfile\",\"id\",\"conversationUuid\",\"saveLoop\",\"conversationMessages\",\"saveConv\",\"conversationData\",\"newMsg\",\"existing\",\"find\",\"currentSave\",\"nextSave\",\"saveConversation\",\"delete\",\"genericPromptWithJsonSpecAndConversationHistory\",\"attemptNr\",\"attemptsPerCheck\",\"openaiTools\",\"jsonSchemaForAiCall\",\"streamedText\",\"responseItems\",\"event\",\"delta\",\"platformItem\",\"itemI\",\"findIndex\",\"it\",\"newItemValue\",\"common\",\"summary\",\"arguments\",\"toolCalls\",\"functionCall\",\"toolResultMessages\",\"executeToolCalls\",\"toolResult\",\"tool_call_id\",\"call\",\"textResponse\",\"checkedResult\",\"uncheckedResult\",\"typeError\",\"uncheckedResultWhichShouldBePacked\",\"String\",\"promises\",\"all\",\"v\",\"attemptCount\",\"CheckFailedTooManyTimes\",\"feedbackMessage\",\"p\",\"setTimeout\",\"warn\",\"maxAttempts\",\"problemsOnLastAttempt\",\"rawSchema\",\"toolCallsToExecute\",\"toolResults\",\"toolCall\",\"toolResultContent\",\"mustHaveWordJsonInMessageBodyForJsonResponse\",\"newO\",\"frame\",\"stack\",\"l\",\"hasFunctionNameInFrameWithFileNameInParenthesis\",\"functionName\",\"groups\",\"stacktraceFrame\",\"modelArg\",\"me\",\"Qe\",\"qt\",\"Pe\",\"Se\",\"$\",\"w\",\"P\",\"Ze\",\"Xe\",\"nt\",\"Ae\",\"Wt\",\"tt\",\"le\",\"G\",\"ue\",\"D\",\"Q\",\"ke\",\"et\",\"Er\",\"Ee\",\"Cr\",\"bt\",\"Ge\",\"kr\",\"Ar\",\"X\"],\"sources\":[\"../node_modules/monoflux/src/Flux.ts\",\"../node_modules/monoflux/src/index.ts\",\"../src/index.ts\",\"../src/ai-inference/model.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/typeSpecToJsonSchema.ts\",\"../src/ai-inference/openai/genericLLMCallToOpenAiCall.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 {\\n\\tFunctionCallInput,\\n\\tFunctionCallOutput,\\n\\tGenericPrompt,\\n\\tInputItem,\\n\\tInputMessage,\\n\\tmustHaveWordJsonInMessageBodyForJsonResponse,\\n\\tOutputItem,\\n\\tOutputMessage,\\n\\tPromptItem,\\n\\tPromptItemBase,\\n\\tPromptItemType,\\n\\tReasoning,\\n\\tRole,\\n\\tServiceTier,\\n\\tuseTypeSpecMessage\\n} from './ai-inference/model.js'\\nimport {promptOpenai} 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'\\nimport {typeSpecToJsonSchema} from './typeSpecToJsonSchema.js'\\nimport {genericLLMCallToOpenAiCall} from './ai-inference/openai/genericLLMCallToOpenAiCall.js'\\nimport {BaseOutputItem, FunctionCall, OutputItemType} from './ai-inference/openai/model/OutputItem.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: PromptItem[]\\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\\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\\tuuid: 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\\tfalse,\\n\\t\\t)\\n\\t}\\n}\\n\\ntype CheckCallback<T extends string | AnyJson> = (output: T) => Promise<(string | null | undefined)[] | string | null | undefined | void> | (string | null | undefined)[] | string | null | undefined | void\\n\\nexport type Check<T extends string | AnyJson> = {\\n\\tcallback: CheckCallback<T>\\n\\tattempts: number\\n}\\n\\nclass BasicPrompt<PSArgs> implements AsyncGenerator<string>, Promise<string> {\\n\\tprivate readonly generator: AsyncGenerator<string>\\n\\tprivate readonly stringGenerator: AsyncGenerator<string>\\n\\tprivate _genericPrompt: GenericPrompt\\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\\tprivate _strict: boolean = false,\\n\\t\\tprivate promptName?: string,\\n\\t\\tprivate _tools: ToolDefinition[] = [],\\n\\t\\tprivate _checks: Check<string>[] = [],\\n\\t) {\\n\\t\\tthis._genericPrompt = this.computeGenericPrompt()\\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\\teffectiveModel(_model),\\n\\t\\t\\t\\tself._genericPrompt,\\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\\tself._strict,\\n\\t\\t\\t\\tself._tools,\\n\\t\\t\\t\\tself._checks,\\n\\t\\t\\t\\tundefined,\\n\\t\\t\\t)\\n\\t\\t})()\\n\\t\\tthis.stringGenerator = (async function*() {\\n\\t\\t\\tfor await (const chunk of self.generator) {\\n\\t\\t\\t\\tif (chunk !== RETRY_SIGNAL) {\\n\\t\\t\\t\\t\\tyield chunk\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t})()\\n\\t}\\n\\n\\tpublic name(name: string): BasicPrompt<PSArgs> {\\n\\t\\treturn this.copy({promptName: name})\\n\\t}\\n\\n\\tpublic model(model: AiModelId): BasicPrompt<PSArgs> {\\n\\t\\treturn this.copy({model})\\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): BasicPrompt<PSArgs> {\\n\\t\\treturn this.copy({firstThink})\\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): BasicPrompt<PSArgs> {\\n\\t\\treturn this.copy({temperature});\\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): BasicPrompt<PSArgs> {\\n\\t\\treturn this.copy({topP});\\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\\treturn this.copy({serviceTier: useFlexTier ? 'flex' : undefined})\\n\\t}\\n\\n\\t/**\\n\\t * Controls whether OpenAI strict mode is enabled for JSON schema validation.\\n\\t * When enabled (default), OpenAI will strictly enforce the JSON schema.\\n\\t * When disabled, OpenAI will use a more lenient validation approach.\\n\\t */\\n\\tpublic strict(strict = true) {\\n\\t\\treturn this.copy({strict})\\n\\t}\\n\\n\\t/**\\n\\t * @param check - Callback that returns a string or an array of strings for each problem with the output\\n\\t * the AI passes to it, or nothing, null, undefined or an empty array if there are no problems. These\\n\\t * problems are passed to the AI so the AI will know how to correct a result.\\n\\t * @param attempts - The nr of attempts (minimally 1) an LLM gets to pass this check. The count is held\\n\\t * independently for each check and is independent from the {@link PromptGunConfig.attemptsPerCall} setting.\\n\\t */\\n\\tpublic check(check: CheckCallback<string>, attempts = 10) {\\n\\t\\tif (attempts < 1) {\\n\\t\\t\\tthrow new Error('The number of attempts must be at least 1')\\n\\t\\t}\\n\\t\\treturn this.copy({checks: [\\n\\t\\t\\t...this._checks,\\n\\t\\t\\t{\\n\\t\\t\\t\\tcallback: check,\\n\\t\\t\\t\\tattempts,\\n\\t\\t\\t},\\n\\t\\t]})\\n\\t}\\n\\n\\tprivate copy(\\n\\t\\t{\\n\\t\\t\\taiClient,\\n\\t\\t\\tpromptSupplier,\\n\\t\\t\\tpromptSupplierArgs,\\n\\t\\t\\tcallingCodeLine,\\n\\t\\t\\ttemperature,\\n\\t\\t\\ttopP,\\n\\t\\t\\tserviceTier,\\n\\t\\t\\tmodel,\\n\\t\\t\\tfirstThink,\\n\\t\\t\\tstrict,\\n\\t\\t\\tpromptName,\\n\\t\\t\\ttools,\\n\\t\\t\\tchecks,\\n\\t\\t}: {\\n\\t\\t\\taiClient?: AIClient,\\n\\t\\t\\tpromptSupplier?: (args: PSArgs, typeSpecMessage?: TypeSpecMessage) => Prompt,\\n\\t\\t\\tpromptSupplierArgs?: PSArgs,\\n\\t\\t\\tcallingCodeLine?: CodeLine,\\n\\t\\t\\ttemperature?: number | undefined,\\n\\t\\t\\ttopP?: number | undefined,\\n\\t\\t\\tserviceTier?: ServiceTier | undefined,\\n\\t\\t\\tmodel?: AiModelId | undefined,\\n\\t\\t\\tfirstThink?: boolean,\\n\\t\\t\\tstrict?: boolean,\\n\\t\\t\\tpromptName?: string,\\n\\t\\t\\ttools?: ToolDefinition[],\\n\\t\\t\\tchecks?: Check<string>[],\\n\\t\\t}\\n\\t): BasicPrompt<PSArgs> {\\n\\t\\treturn new BasicPrompt<PSArgs>(\\n\\t\\t\\taiClient ?? this.aiClient,\\n\\t\\t\\tpromptSupplier ?? this.promptSupplier,\\n\\t\\t\\tpromptSupplierArgs ?? this.promptSupplierArgs,\\n\\t\\t\\tcallingCodeLine ?? this.callingCodeLine,\\n\\t\\t\\ttemperature ?? this._temperature,\\n\\t\\t\\ttopP ?? this._topP,\\n\\t\\t\\tserviceTier ?? this._serviceTier,\\n\\t\\t\\tmodel ?? this._model,\\n\\t\\t\\tfirstThink ?? this._firstThink,\\n\\t\\t\\tstrict ?? this._strict,\\n\\t\\t\\tpromptName ?? this.promptName,\\n\\t\\t\\ttools ?? this._tools,\\n\\t\\t\\tchecks ?? this._checks\\n\\t\\t)\\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._genericPrompt\\n\\t\\t\\t.map(promptItemToMessage)\\n\\t}\\n\\n\\tprivate get json() {\\n\\t\\treturn false\\n\\t}\\n\\n\\tprivate computeGenericPrompt() {\\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 jsonSpecContent = jsonSpec(effectiveModel(this._model), this.json, this._firstThink)\\n\\t\\t\\n\\t\\t// If jsonSpec returns null (for OpenAI models), don't add the type spec message\\n\\t\\tif (jsonSpecContent === null) {\\n\\t\\t\\treturn genericPrompt\\n\\t\\t}\\n\\t\\t\\n\\t\\tconst jsonSpecMessage = {\\n\\t\\t\\tuuid: randomUuid(),\\n\\t\\t\\ttype: 'input_message',\\n\\t\\t\\trole: 'user' as const,\\n\\t\\t\\tcontent: jsonSpecContent\\n\\t\\t} satisfies InputMessage\\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.stringGenerator.next(value)\\n\\t}\\n\\n\\treturn(value: any): Promise<IteratorResult<string, any>> {\\n\\t\\treturn this.stringGenerator.return(value)\\n\\t}\\n\\n\\tthrow(e: any): Promise<IteratorResult<string, any>> {\\n\\t\\treturn this.stringGenerator.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\\tthis._strict,\\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\\tthis._strict,\\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.push(...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\\tif (chunk === RETRY_SIGNAL) {\\n\\t\\t\\t\\tresult = ''\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\t}\\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\\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 _genericPrompt: GenericPrompt\\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\\tprotected _tools: ToolDefinition[] = [],\\n\\t\\tprotected _strict: boolean = false,\\n\\t\\tprotected _checks: Check<Json>[] = []\\n\\t) {\\n\\t\\tsuper()\\n\\t\\tconst thiss = this\\n\\t\\t\\n\\t\\t// Create lazy generator that will only execute when accessed\\n\\t\\tthis._genericPrompt = this.computePrompt()\\n\\t\\tconst lazyGenerator = (async function*() {\\n\\t\\t\\tyield* await executeLlmCall(\\n\\t\\t\\t\\taiClient,\\n\\t\\t\\t\\teffectiveModel(_model),\\n\\t\\t\\t\\tthiss._genericPrompt,\\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\\tthiss._strict,\\n\\t\\t\\t\\tthiss._tools,\\n\\t\\t\\t\\tthiss._checks,\\n\\t\\t\\t\\tjsonTypeSupplier,\\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\\tconst jsonTokenProcessor = new JsonTokenProcessor()\\n\\t\\t\\tif (!flux) {\\n\\t\\t\\t\\tflux = Flux.fromGenerator(lazyGenerator())\\n\\t\\t\\t\\tjsonTokenFlux = 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 {\\n\\t\\t\\t\\tflux: flux!,\\n\\t\\t\\t\\tjsonTokenFlux: jsonTokenFlux!,\\n\\t\\t\\t\\tstreamingJsonRootElement: streamingJsonRootElement!,\\n\\t\\t\\t\\tjsonTokenProcessor\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t\\n\\t\\tthis.stringGenerator = (async function*() {\\n\\t\\t\\tconst { flux, streamingJsonRootElement, jsonTokenProcessor } = getFlux()\\n\\t\\t\\tfor await (const chunk of flux) {\\n\\t\\t\\t\\tif (chunk === RETRY_SIGNAL) {\\n\\t\\t\\t\\t\\tyield chunk\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tconst excerpts = jsonTokenProcessor.getExcerpts(chunk)\\n\\t\\t\\t\\tfor (const jsonExcerpt of excerpts) {\\n\\t\\t\\t\\t\\tif (jsonExcerpt.token !== undefined) {\\n\\t\\t\\t\\t\\t\\tstreamingJsonRootElement.push(jsonExcerpt)\\n\\t\\t\\t\\t\\t} else if (jsonExcerpt.source !== undefined) {\\n\\t\\t\\t\\t\\t\\tyield jsonExcerpt.source\\n\\t\\t\\t\\t\\t}\\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\\t// Filter out retry reset events from reaching external consumers\\n\\t\\t\\t\\tif (chunk === RETRY_SIGNAL) {\\n\\t\\t\\t\\t\\taccumulatedJson = ''\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t}\\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): JsonPrompt<PSArgs, Json> {\\n\\t\\treturn this.copy({promptName: name})\\n\\t}\\n\\n\\tpublic model(model: AiModelId): JsonPrompt<PSArgs, Json> {\\n\\t\\treturn this.copy({model})\\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): JsonPrompt<PSArgs, Json> {\\n\\t\\treturn this.copy({firstThink})\\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): JsonPrompt<PSArgs, Json> {\\n\\t\\treturn this.copy({temperature})\\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): JsonPrompt<PSArgs, Json> {\\n\\t\\treturn this.copy({topP})\\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): JsonPrompt<PSArgs, Json> {\\n\\t\\treturn this.copy({serviceTier: useFlexTier ? 'flex' : undefined})\\n\\t}\\n\\n\\t/**\\n\\t * Controls whether OpenAI strict mode is enabled for JSON schema validation.\\n\\t * When enabled (default), OpenAI will strictly enforce the JSON schema.\\n\\t * When disabled, OpenAI will use a more lenient validation approach.\\n\\t */\\n\\tpublic strict(strict = true): JsonPrompt<PSArgs, Json> {\\n\\t\\treturn this.copy({strict})\\n\\t}\\n\\n\\t/**\\n\\t * @param check - Callback that returns a string or an array of strings for each problem with the output\\n\\t * the AI passes to it, or nothing, null, undefined or an empty array if there are no problems. These\\n\\t * problems are passed to the AI so the AI will know how to correct a result.\\n\\t * @param attempts - The nr of attempts (minimally 1) an LLM gets to pass this check. The count is held\\n\\t * independently for each check and is independent from the {@link PromptGunConfig.attemptsPerCall} setting.\\n\\t */\\n\\tpublic check(check: CheckCallback<Json>, attempts = 10) {\\n\\t\\tif (attempts < 1) {\\n\\t\\t\\tthrow new Error('The number of attempts must be at least 1')\\n\\t\\t}\\n\\t\\treturn this.copy({checks: [\\n\\t\\t\\t\\t...this._checks,\\n\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\tcallback: check,\\n\\t\\t\\t\\t\\tattempts,\\n\\t\\t\\t\\t},\\n\\t\\t\\t]})\\n\\t}\\n\\n\\tprivate copy(\\n\\t\\t{\\n\\t\\t\\taiClient,\\n\\t\\t\\tpromptSupplier,\\n\\t\\t\\tpromptSupplierArgs,\\n\\t\\t\\tjsonTypeSupplier,\\n\\t\\t\\tcallingCodeLine,\\n\\t\\t\\ttemperature,\\n\\t\\t\\ttopP,\\n\\t\\t\\tserviceTier,\\n\\t\\t\\tmodel,\\n\\t\\t\\tfirstThink,\\n\\t\\t\\tstrict,\\n\\t\\t\\tpromptName,\\n\\t\\t\\ttools,\\n\\t\\t\\tchecks,\\n\\t\\t}: {\\n\\t\\t\\taiClient?: AIClient,\\n\\t\\t\\tpromptSupplier?: (args: PSArgs, typeSpecMessage?: TypeSpecMessage) => Prompt,\\n\\t\\t\\tpromptSupplierArgs?: PSArgs,\\n\\t\\t\\tjsonTypeSupplier?: ((value: EmptyTypeSpec<unknown>) => TypeSpec<Json>),\\n\\t\\t\\tcallingCodeLine?: CodeLine,\\n\\t\\t\\ttemperature?: number | undefined,\\n\\t\\t\\ttopP?: number | undefined,\\n\\t\\t\\tserviceTier?: ServiceTier | undefined,\\n\\t\\t\\tmodel?: AiModelId | undefined,\\n\\t\\t\\tfirstThink?: boolean,\\n\\t\\t\\tstrict?: boolean,\\n\\t\\t\\tpromptName?: string,\\n\\t\\t\\ttools?: ToolDefinition[],\\n\\t\\t\\tchecks?: Check<Json>[],\\n\\t\\t}\\n\\t): JsonPrompt<PSArgs, Json> {\\n\\t\\treturn new JsonPrompt<PSArgs, Json>(\\n\\t\\t\\taiClient ?? this.aiClient,\\n\\t\\t\\tpromptSupplier ?? this.promptSupplier,\\n\\t\\t\\tpromptSupplierArgs ?? this.promptSupplierArgs,\\n\\t\\t\\tjsonTypeSupplier ?? this.jsonTypeSupplier,\\n\\t\\t\\tcallingCodeLine ?? this.callingCodeLine,\\n\\t\\t\\tpromptName ?? this.promptName,\\n\\t\\t\\ttemperature ?? this._temperature,\\n\\t\\t\\ttopP ?? this._topP,\\n\\t\\t\\tserviceTier ?? this._serviceTier,\\n\\t\\t\\tmodel ?? this._model,\\n\\t\\t\\tfirstThink ?? this._firstThink,\\n\\t\\t\\ttools ?? this._tools,\\n\\t\\t\\tstrict ?? this._strict,\\n\\t\\t\\tchecks ?? this._checks\\n\\t\\t)\\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._genericPrompt\\n\\t\\t\\t.map(promptItemToMessage)\\n\\t}\\n\\n\\tprivate computePrompt() {\\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 jsonSpecContent = jsonSpec(effectiveModel(this._model), this.json, this._firstThink)\\n\\t\\t\\n\\t\\t// If jsonSpec returns null (for OpenAI models), don't add the type spec message\\n\\t\\tif (jsonSpecContent === null) {\\n\\t\\t\\treturn genericPrompt\\n\\t\\t}\\n\\t\\t\\n\\t\\tconst jsonSpecMessage = {\\n\\t\\t\\ttype: 'input_message',\\n\\t\\t\\tuuid: randomUuid(),\\n\\t\\t\\trole: 'user' as const,\\n\\t\\t\\tcontent: jsonSpecContent\\n\\t\\t} satisfies InputMessage\\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\\t\\n\\t\\t// Determine if we expect a wrapped response\\n\\t\\tconst expectsWrappedResponse = (() => {\\n\\t\\t\\tif (jsonTypeSupplier === undefined) {\\n\\t\\t\\t\\treturn false\\n\\t\\t\\t}\\n\\t\\t\\t// Only expect wrapped response when using OpenAI structured outputs\\n\\t\\t\\t// and the original schema wasn't already an object\\n\\t\\t\\tif (!useTypeSpecMessage(effectiveModel(this._model))) {\\n\\t\\t\\t\\tconst typeSpec = jsonTypeSupplier(specType(undefined as unknown))\\n\\t\\t\\t\\tconst rawSchema = typeSpecToJsonSchema(typeSpec)\\n\\t\\t\\t\\treturn rawSchema.type !== 'object'\\n\\t\\t\\t}\\n\\t\\t\\treturn true // Non-OpenAI models use type spec message and expect wrapped response\\n\\t\\t})()\\n\\t\\t\\n\\t\\tconst uncheckedResult = expectsWrappedResponse\\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.push(...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\\tif (chunk === RETRY_SIGNAL) {\\n\\t\\t\\t\\t// Reset accumulated content on retry\\n\\t\\t\\t\\tresult = ''\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\t}\\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\\t_strict: boolean = false,\\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\\t_strict,\\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 toGenericPrompt(prompt: string | Message | (Message | undefined)[], typeSpecMessage?: TypeSpecMessage): {messages: GenericPrompt, typeSpecIndex?: number} {\\n\\tconst toOpenAiMessage = (msg: Message | undefined): PromptItem | 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\\ttype: 'input_message',\\n\\t\\t\\tuuid: randomUuid(),\\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: [{type: 'input_message', uuid: randomUuid(), 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: PromptItem[] = []\\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,\\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\\tstrict: boolean,\\n\\ttools: ToolDefinition[],\\n\\tchecks: Check<any>[],\\n\\tjsonTypeSupplier?: ((value: EmptyTypeSpec<unknown>) => TypeSpec<any>) | undefined,\\n) {\\n\\tconst convSavePromises = new Map<string, {promise: Promise<void>}>()\\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\\tnextSave?: {\\n\\t\\t\\t\\tuuid: string\\n\\t\\t\\t\\tcallback: () => Promise<void>\\n\\t\\t\\t}\\n\\t\\t} = {}\\n\\t\\tconst conversationMessages = aiClient.conversation?.messages ?? []\\n\\t\\tconst saveConv = (conversationData: ConversationData) => {\\n\\t\\t\\tconst uuid = randomUuid()\\n\\t\\t\\tfor (const newMsg of conversationData.messages) {\\n\\t\\t\\t\\tconst existing = conversationMessages.find(m => m.uuid === newMsg.uuid)\\n\\t\\t\\t\\tif (existing !== undefined) {\\n\\t\\t\\t\\t\\tif (existing.role !== newMsg.role) {\\n\\t\\t\\t\\t\\t\\tthrow new Error('Illegal state')\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\texisting.content = newMsg.content\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tconversationMessages.push(newMsg)\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tconst callback = async () => {\\n\\t\\t\\t\\tsaveLoop.currentSave = saveLoop.nextSave\\n\\t\\t\\t\\tsaveLoop.nextSave = undefined\\n\\t\\t\\t\\tawait saveConversation(\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\tprompt: conversationData.prompt,\\n\\t\\t\\t\\t\\t\\tconversationUuid: conversationData.conversationUuid,\\n\\t\\t\\t\\t\\t\\tmessages: conversationMessages,\\n\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\taiClient['apiKeyChain']!.promptgrid\\n\\t\\t\\t\\t)\\n\\t\\t\\t\\tawait (saveLoop.nextSave as (typeof saveLoop)['nextSave'])?.callback()\\n\\t\\t\\t\\tsaveLoop.currentSave = undefined\\n\\t\\t\\t}\\n\\t\\t\\tif (saveLoop.nextSave !== undefined) {\\n\\t\\t\\t\\tconvSavePromises.delete(saveLoop.nextSave.uuid)\\n\\t\\t\\t}\\n\\t\\t\\tsaveLoop.nextSave = {uuid, callback}\\n\\t\\t\\tif (saveLoop.currentSave === undefined) {\\n\\t\\t\\t\\tconvSavePromises.set(uuid, {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 (PromptItem & Partial<PromptItem>)[]\\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})\\n\\n\\t\\tlet complete = false\\n\\t\\tlet attemptNr = 1\\n\\t\\tconst attemptsPerCheck = checks.reduce(\\n\\t\\t\\t(map, check) => map.set(check, 1),\\n\\t\\t\\tnew Map<Check<any>, number>()\\n\\t\\t)\\n\\t\\twhile (!complete) {\\n\\t\\t\\tconst responseMessageId = randomUuid()\\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\\tname: tool.name,\\n\\t\\t\\t\\t\\tdescription: tool.description,\\n\\t\\t\\t\\t\\tparameters: typeSpecToJsonSchema(tool.parameters),\\n\\t\\t\\t\\t\\tstrict: true\\n\\t\\t\\t\\t}))\\n\\n\\t\\t\\t\\tconst { flux, httpRequest } = promptOpenai(\\n\\t\\t\\t\\t\\tgenericLLMCallToOpenAiCall(\\n\\t\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\tmodel: effectiveModel(model),\\n\\t\\t\\t\\t\\t\\t\\tprompt: genericPromptWithJsonSpecAndConversationHistory,\\n\\t\\t\\t\\t\\t\\t\\tapiToken,\\n\\t\\t\\t\\t\\t\\t\\ttemperature,\\n\\t\\t\\t\\t\\t\\t\\ttopP,\\n\\t\\t\\t\\t\\t\\t\\trequireJsonResponse: json !== false,\\n\\t\\t\\t\\t\\t\\t\\tjsonSchema: jsonSchemaForAiCall(jsonTypeSupplier, json, model, strict),\\n\\t\\t\\t\\t\\t\\t\\tserviceTier,\\n\\t\\t\\t\\t\\t\\t\\ttools: openaiTools,\\n\\t\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t),\\n\\t\\t\\t\\t\\tapiToken,\\n\\t\\t\\t\\t)\\n\\n\\t\\t\\t\\tlet streamedText = '';\\n\\t\\t\\t\\tconst responseItems: OutputItem[] = []\\n\\n\\t\\t\\t\\tyield* flux\\n\\t\\t\\t\\t\\t.flatMap<PromptChunk>(event => {\\n\\t\\t\\t\\t\\t\\tswitch (event.type) {\\n\\t\\t\\t\\t\\t\\t\\tcase 'response.output_text.delta': {\\n\\t\\t\\t\\t\\t\\t\\t\\treturn [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\ttype: 'content' as const,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tcontent: event.delta\\n\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\tcase 'response.created':\\n\\t\\t\\t\\t\\t\\t\\tcase 'response.in_progress':\\n\\t\\t\\t\\t\\t\\t\\tcase 'response.completed': {\\n\\t\\t\\t\\t\\t\\t\\t\\tfor (const [i, platformItem] of event.response.output.entries()) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tconst itemI = responseItems.findIndex(it => it.llmPlatformConversationItem.id === platformItem.id)\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tconst item = itemI >= 0 ? responseItems[itemI] : undefined\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tconst newItemValue = (() => {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tconst common = {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tuuid: item?.uuid ?? randomUuid(),\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tllmPlatform: 'openai' as const,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tllmPlatformConversationItem: platformItem,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\thttpRequest: i === 0 ? JSON.stringify(httpRequest) : undefined,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\trole: 'assistant' as const,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tswitch (platformItem.type) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tcase 'message': return {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t...common,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\ttype: 'output_message',\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tcontent: platformItem.content\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t.flatMap(c => c.type === 'output_text' ? [c.text] : [])\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t.join(''),\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t} satisfies OutputMessage\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tcase 'reasoning': return {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t...common,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\ttype: 'reasoning',\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tcontent: platformItem.content?.map(c => c.text).join('')\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t?? platformItem.summary.map(c => c.text).join(''),\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t} satisfies Reasoning\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tcase 'function_call': return {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t...common,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\ttype: 'function_call_input',\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tname: platformItem.name,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\targuments: platformItem.arguments,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tcontent: `${platformItem.name}(${platformItem.arguments})`,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tfunctionCallId: platformItem.call_id,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t} satisfies FunctionCallInput\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t})()\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tsaveConv({\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tconversationUuid,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tprompt: promptProfile,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tmessages: [newItemValue],\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tif (itemI >= 0) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tresponseItems[itemI] = newItemValue\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tresponseItems.push(newItemValue)\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\treturn []\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\tdefault: {\\n\\t\\t\\t\\t\\t\\t\\t\\treturn []\\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.doOnEach(chunk => {\\n\\t\\t\\t\\t\\t\\tswitch (chunk.type) {\\n\\t\\t\\t\\t\\t\\t\\tcase 'content': {\\n\\t\\t\\t\\t\\t\\t\\t\\tstreamedText += chunk.content\\n\\t\\t\\t\\t\\t\\t\\t\\tbreak\\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.flatMap(\\n\\t\\t\\t\\t\\t\\tchunk => chunk.type === 'content'\\n\\t\\t\\t\\t\\t\\t\\t? [chunk.content]\\n\\t\\t\\t\\t\\t\\t\\t: []\\n\\t\\t\\t\\t\\t)\\n\\n\\t\\t\\t\\tconst toolCalls = responseItems\\n\\t\\t\\t\\t\\t.flatMap(\\n\\t\\t\\t\\t\\t\\titem => item.type === 'function_call_input'\\n\\t\\t\\t\\t\\t\\t\\t? (() => {\\n\\t\\t\\t\\t\\t\\t\\t\\tconst functionCall = item.llmPlatformConversationItem as FunctionCall\\n\\t\\t\\t\\t\\t\\t\\t\\treturn {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tid: functionCall.call_id,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tname: functionCall.name,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\targuments: functionCall.arguments,\\n\\t\\t\\t\\t\\t\\t\\t\\t} satisfies ToolCall\\n\\t\\t\\t\\t\\t\\t\\t})()\\n\\t\\t\\t\\t\\t\\t\\t: []\\n\\t\\t\\t\\t\\t)\\n\\t\\t\\t\\tconst llmSupplierOutputMessages = responseItems\\n\\t\\t\\t\\t\\t.map(item => item.llmPlatformConversationItem)\\n\\n\\t\\t\\t\\tif (toolCalls.length > 0) {\\n\\t\\t\\t\\t\\tconst toolResults = await executeToolCalls(toolCalls, tools)\\n\\n\\t\\t\\t\\t\\tconst toolResultMessages = toolResults.map(toolResult => ({\\n\\t\\t\\t\\t\\t\\ttype: 'function_call_output',\\n\\t\\t\\t\\t\\t\\tuuid: randomUuid(),\\n\\t\\t\\t\\t\\t\\trole: 'user' as const,\\n\\t\\t\\t\\t\\t\\tfunctionCallId: toolResult.tool_call_id,\\n\\t\\t\\t\\t\\t\\tcontent: `Tool result for ${toolResult.call.name}: ${toolResult.content}`\\n\\t\\t\\t\\t\\t} satisfies FunctionCallOutput))\\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\\t...responseItems,\\n\\t\\t\\t\\t\\t\\t...toolResultMessages\\n\\t\\t\\t\\t\\t] satisfies PromptItem[]\\n\\n\\t\\t\\t\\t\\tattemptNr = 1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\tconst textResponse = (() => {\\n\\t\\t\\t\\t\\tconst messages = responseItems.filter(item => item.type === 'output_message')\\n\\t\\t\\t\\t\\tif (messages.length !== 1) {\\n\\t\\t\\t\\t\\t\\tthrow Error('Expected 1 output message, got ' + messages.length)\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\treturn messages[0]!.content\\n\\t\\t\\t\\t})()\\n\\n\\t\\t\\t\\tconst checkedResult = (() => {\\n\\t\\t\\t\\t\\t// If this is a JSON prompt with type validation, validate after completion\\n\\t\\t\\t\\t\\tif (jsonTypeSupplier !== undefined) {\\n\\t\\t\\t\\t\\t\\t// Then validate the complete JSON response\\n\\t\\t\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\t\\t\\tconst uncheckedPackedResult = parseJsonWithUsefulError(textResponse)\\n\\n\\t\\t\\t\\t\\t\\t\\t// Use the same wrapping logic as getResponse()\\n\\t\\t\\t\\t\\t\\t\\tconst expectsWrappedResponse = (() => {\\n\\t\\t\\t\\t\\t\\t\\t\\t// Only expect wrapped response when using OpenAI structured outputs\\n\\t\\t\\t\\t\\t\\t\\t\\t// and the original schema wasn't already an object\\n\\t\\t\\t\\t\\t\\t\\t\\tif (!useTypeSpecMessage(model)) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tconst typeSpec = jsonTypeSupplier(specType(undefined as unknown))\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tconst rawSchema = typeSpecToJsonSchema(typeSpec)\\n\\t\\t\\t\\t\\t\\t\\t\\t\\treturn rawSchema.type !== 'object'\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\treturn true // Non-OpenAI models use type spec message and expect wrapped response\\n\\t\\t\\t\\t\\t\\t\\t})()\\n\\n\\t\\t\\t\\t\\t\\t\\tconst uncheckedResult = expectsWrappedResponse\\n\\t\\t\\t\\t\\t\\t\\t\\t? uncheckedPackedResult?.result\\n\\t\\t\\t\\t\\t\\t\\t\\t: uncheckedPackedResult\\n\\n\\t\\t\\t\\t\\t\\t\\t// Attempt type checking\\n\\t\\t\\t\\t\\t\\t\\treturn assertType(\\n\\t\\t\\t\\t\\t\\t\\t\\tuncheckedResult,\\n\\t\\t\\t\\t\\t\\t\\t\\tjsonTypeSupplier(specType(uncheckedResult)),\\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} catch (typeError) {\\n\\t\\t\\t\\t\\t\\t\\t// Try fallback validation (AI might have forgotten the wrapper)\\n\\t\\t\\t\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\t\\t\\t\\tconst uncheckedResultWhichShouldBePacked = parseJsonWithUsefulError(textResponse)\\n\\t\\t\\t\\t\\t\\t\\t\\treturn assertType(\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tuncheckedResultWhichShouldBePacked,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tjsonTypeSupplier(specType(uncheckedResultWhichShouldBePacked)),\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t{juggleBetweenNullAndUndefined: true},\\n\\t\\t\\t\\t\\t\\t\\t\\t)\\n\\t\\t\\t\\t\\t\\t\\t} catch (fallbackError) {\\n\\t\\t\\t\\t\\t\\t\\t\\t// Type validation failed, treat as a retriable error\\n\\t\\t\\t\\t\\t\\t\\t\\tconst errorMessage = typeError instanceof Error ? typeError.message : String(typeError)\\n\\t\\t\\t\\t\\t\\t\\t\\tthrow new Error(`JSON response failed type validation: ${errorMessage}`)\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\treturn textResponse\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t})()\\n\\n\\t\\t\\t\\tif (checks.length > 0) {\\n\\t\\t\\t\\t\\tconst promises = checks.map(async check => {\\n\\t\\t\\t\\t\\t\\tconst result = await (async () => {\\n\\t\\t\\t\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\t\\t\\t\\treturn await check.callback(checkedResult) ?? undefined\\n\\t\\t\\t\\t\\t\\t\\t} catch (e) {\\n\\t\\t\\t\\t\\t\\t\\t\\tif (e instanceof Error) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\treturn e.message\\n\\t\\t\\t\\t\\t\\t\\t\\t} else if (typeof e === 'string') {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\treturn e\\n\\t\\t\\t\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tthrow 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\\t\\treturn {result, check}\\n\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\tconst problems = (await Promise.all(promises))\\n\\t\\t\\t\\t\\t\\t.flatMap(({result, check}) => {\\n\\t\\t\\t\\t\\t\\t\\tconst problems = (() => {\\n\\t\\t\\t\\t\\t\\t\\t\\tif (typeof result === 'string') {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\treturn [result]\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\tif (Array.isArray(result)) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\treturn result.flatMap(v => typeof v === 'string' ? [v] : [])\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\treturn []\\n\\t\\t\\t\\t\\t\\t\\t})()\\n\\t\\t\\t\\t\\t\\t\\tif (problems.length > 0) {\\n\\t\\t\\t\\t\\t\\t\\t\\tconst attemptCount = requireDefined(attemptsPerCheck.get(check))\\n\\t\\t\\t\\t\\t\\t\\t\\tif (attemptCount >= check.attempts) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tthrow new CheckFailedTooManyTimes(\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tcheck,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tcheck.attempts,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tattemptCount,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tproblems\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t)\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\tattemptsPerCheck.set(check, attemptCount + 1)\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\treturn problems\\n\\t\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\tif (problems.length > 0) {\\n\\t\\t\\t\\t\\t\\tconst feedbackMessage = {\\n\\t\\t\\t\\t\\t\\t\\ttype: 'input_message',\\n\\t\\t\\t\\t\\t\\t\\tuuid: randomUuid(),\\n\\t\\t\\t\\t\\t\\t\\trole: 'user' as const,\\n\\t\\t\\t\\t\\t\\t\\tcontent: `Your result was rejected because:\\\\n${problems.map(p => `- ${p}`).join('\\\\n')}`\\n\\t\\t\\t\\t\\t\\t} satisfies InputMessage\\n\\t\\t\\t\\t\\t\\tsaveConv({\\n\\t\\t\\t\\t\\t\\t\\tconversationUuid,\\n\\t\\t\\t\\t\\t\\t\\tprompt: promptProfile,\\n\\t\\t\\t\\t\\t\\t\\tmessages: [feedbackMessage]\\n\\t\\t\\t\\t\\t\\t})\\n\\n\\t\\t\\t\\t\\t\\tgenericPromptWithJsonSpecAndConversationHistory = [\\n\\t\\t\\t\\t\\t\\t\\t...genericPromptWithJsonSpecAndConversationHistory,\\n\\t\\t\\t\\t\\t\\t\\t...responseItems,\\n\\t\\t\\t\\t\\t\\t\\tfeedbackMessage\\n\\t\\t\\t\\t\\t\\t] satisfies PromptItem[]\\n\\n\\t\\t\\t\\t\\t\\tyield RETRY_SIGNAL\\n\\t\\t\\t\\t\\t\\tattemptNr = 1\\n\\t\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\tgenericPromptWithJsonSpecAndConversationHistory = [\\n\\t\\t\\t\\t\\t...genericPromptWithJsonSpecAndConversationHistory,\\n\\t\\t\\t\\t\\t...responseItems,\\n\\t\\t\\t\\t] satisfies PromptItem[]\\n\\n\\t\\t\\t\\tcomplete = true\\n\\t\\t\\t} catch (e) {\\n\\t\\t\\t\\tif (e instanceof Error && e.name === CheckFailedTooManyTimes.name) {\\n\\t\\t\\t\\t\\tthrow e\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tif (attemptNr >= (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 (try ${attemptNr + 1}/${aiClient['config'].attemptsPerCall})`, e)\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t// Emit a special reset event so downstream parsers know to reset their accumulated content\\n\\t\\t\\t\\tyield RETRY_SIGNAL\\n\\t\\t\\t\\tattemptNr++\\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\\nclass CheckFailedTooManyTimes extends Error {\\n\\tconstructor(\\n\\t\\tpublic readonly check: Check<any>,\\n\\t\\tpublic readonly maxAttempts: number,\\n\\t\\tpublic readonly attempts: number,\\n\\t\\tpublic readonly problemsOnLastAttempt: string[],\\n\\t\\tmessage?: string\\n\\t) {\\n\\t\\tsuper(message)\\n\\t}\\n}\\n\\nfunction jsonSchemaForAiCall(\\n\\tjsonTypeSupplier: ((value: EmptyTypeSpec<unknown>) => TypeSpec<any>) | undefined,\\n\\tjson: TypeSpec<any> | boolean,\\n\\tmodel: AiModelId,\\n\\tstrict: boolean\\n) {\\n\\tif (jsonTypeSupplier === undefined) {\\n\\t\\treturn undefined\\n\\t}\\n\\tif (json === false) {\\n\\t\\treturn undefined\\n\\t}\\n\\tif (useTypeSpecMessage(model)) {\\n\\t\\treturn undefined\\n\\t}\\n\\tconst typeSpec = jsonTypeSupplier(specType(undefined as unknown))\\n\\tconst rawSchema = typeSpecToJsonSchema(typeSpec)\\n\\n\\t// OpenAI structured outputs requires root schema to be an object\\n\\t// If we have an array or other non-object type, wrap it in an object\\n\\tconst wrappedSchema = rawSchema.type === 'object'\\n\\t\\t? rawSchema\\n\\t\\t: {\\n\\t\\t\\ttype: 'object',\\n\\t\\t\\tproperties: {\\n\\t\\t\\t\\tresult: rawSchema\\n\\t\\t\\t},\\n\\t\\t\\trequired: ['result'],\\n\\t\\t\\tadditionalProperties: false\\n\\t\\t}\\n\\n\\n\\treturn {\\n\\t\\tname: 'response',\\n\\t\\tschema: wrappedSchema,\\n\\t\\tstrict\\n\\t}\\n}\\n\\nexport type ToolCall = {\\n\\tid: string\\n\\tname: string\\n\\targuments: string\\n}\\n\\nexport type ContentChunk = {\\n\\ttype: 'content'\\n\\tcontent: string\\n}\\n\\nexport type PromptChunk = ContentChunk\\n\\nasync function executeToolCalls(\\n\\ttoolCallsToExecute: ToolCall[],\\n\\ttools: ToolDefinition[] | undefined\\n) {\\n\\tif (tools === undefined) {\\n\\t\\tthrow Error('Illegal state: no tools defined')\\n\\t}\\n\\tconst toolResults = []\\n\\tfor (const toolCall of toolCallsToExecute) {\\n\\t\\tconst tool = tools.find(t => t.name === toolCall.name)\\n\\t\\tconst toolResultContent = await (async () => {\\n\\t\\t\\tif (tool === undefined) {\\n\\t\\t\\t\\treturn `Error: Tool ${toolCall.name} not found`\\n\\t\\t\\t}\\n\\t\\t\\ttry {\\n\\t\\t\\t\\tconst args = toolCall.arguments.trim() === '' ? {} : JSON.parse(toolCall.arguments)\\n\\t\\t\\t\\treturn await tool.function(args)\\n\\t\\t\\t} catch (error) {\\n\\t\\t\\t\\treturn `Error: ${error instanceof Error ? error.message : String(error)}`\\n\\t\\t\\t}\\n\\t\\t})()\\n\\t\\ttoolResults.push({\\n\\t\\t\\tcall: toolCall,\\n\\t\\t\\ttool,\\n\\t\\t\\ttool_call_id: toolCall.id,\\n\\t\\t\\trole: 'tool' as const,\\n\\t\\t\\tcontent: toolResultContent\\n\\t\\t})\\n\\t}\\n\\treturn toolResults\\n}\\n\\nfunction jsonSpec(\\n\\tmodel: AiModelId,\\n\\tjson: true | TypeSpec<any>,\\n\\tfirstThink: boolean,\\n): string | null {\\n\\tif (!useTypeSpecMessage(model)) {\\n\\t\\t// For OpenAI models, we don't need the type spec message\\n\\t\\t// since they handle JSON schema natively via response_format\\n\\t\\tif (mustHaveWordJsonInMessageBodyForJsonResponse(model)) {\\n\\t\\t\\treturn 'Respond with JSON'\\n\\t\\t}\\n\\t\\treturn null\\n\\t}\\n\\t\\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 {\\n\\tApiKeys as AccessTokens,\\n\\tAnyJson,\\n\\tAssistantMessage,\\n\\tDeveloperMessage,\\n\\tHandshakeData,\\n\\tJsonArray,\\n\\tJsonObject,\\n\\tMessage,\\n\\tOpts,\\n\\tPrompt,\\n\\tSystemMessage,\\n\\tUserMessage,\\n\\tTypeSpecMessage,\\n\\tToolDefinition,\\n\\tToolFunction,\\n\\tInputItem,\\n\\tOutputItem,\\n\\tReasoning,\\n}\\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, PromptItem, ServiceTier, Role, InputMessage, OutputMessage, FunctionCallInput, FunctionCallOutput, CheckCallback, PromptItemBase, PromptItemType, FunctionCall, BaseOutputItem, OutputItemType }\\nexport { typeSpecToJsonSchema } from './typeSpecToJsonSchema.js'\\nexport type { PlatformId } from './ai-inference/model.js'\\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\\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: PromptItem[]\\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\\nfunction promptItemToMessage(m: PromptItem) {\\n\\tswitch (m.type) {\\n\\t\\tcase 'input_message':\\n\\t\\tcase 'output_message':\\n\\t\\t\\treturn {[m.role]: m.content} as unknown as Message\\n\\t\\tcase 'reasoning':\\n\\t\\tcase 'function_call_input':\\n\\t\\t\\treturn {assistant: m.content}\\n\\t\\tcase 'function_call_output':\\n\\t\\t\\treturn {user: m.content}\\n\\t}\\n}\\n\\nfunction effectiveModel(modelArg: AiModelId | undefined): AiModelId {\\n\\treturn modelArg ?? 'gpt-4o'\\n}\\n\\nconst RETRY_SIGNAL = `retry-signal-${randomUuid()}`\",\"import {AiModelId} from './AiModelId.js'\\nimport {FunctionCall} from './openai/model/OutputItem.js'\\n\\n\\nexport type PlatformId =\\n | 'openai'\\n// | 'huggingface-inference-api'\\n// | 'llama-cpp'\\n// | 'replicate'\\n// | 'anthropic'\\n\\nexport type PlatformSpecificPromptRequest<Stream extends boolean = false> = Omit<PromptRequest<Stream>, 'platform'>\\n\\nexport type Role = 'user' | 'system' | 'developer' | 'assistant'\\n\\nexport type PromptItemType =\\n | 'input_message'\\n | 'output_message'\\n | 'reasoning'\\n | 'function_call_input'\\n | 'function_call_output'\\n\\nexport type PromptItemBase<T extends PromptItemType> = {\\n type: T\\n uuid: string\\n}\\n\\nexport type InputMessage = PromptItemBase<'input_message'> & {\\n role: Role\\n content: string\\n name?: undefined\\n arguments?: undefined\\n httpRequest?: undefined\\n llmPlatform?: undefined\\n llmPlatformConversationItem?: undefined\\n}\\n\\nexport type OutputMessage = PromptItemBase<'output_message'> & {\\n role: Role\\n content: string\\n httpRequest?: string\\n llmPlatform: PlatformId\\n llmPlatformConversationItem: any\\n}\\n\\nexport type Reasoning = PromptItemBase<'reasoning'> & {\\n role: Role\\n content: string\\n name?: undefined\\n arguments?: undefined\\n httpRequest?: string\\n llmPlatform?: PlatformId\\n llmPlatformConversationItem: any\\n}\\n\\nexport type FunctionCallInput = PromptItemBase<'function_call_input'> & {\\n name: string\\n /** @deprecated **/\\n role: 'assistant'\\n functionCallId: string\\n content: string\\n arguments: string\\n httpRequest?: string\\n llmPlatform?: PlatformId\\n llmPlatformConversationItem: any\\n}\\n\\nexport type FunctionCallOutput = PromptItemBase<'function_call_output'> & {\\n /** @deprecated **/\\n role: 'user'\\n content: string\\n functionCallId: string\\n httpRequest?: undefined\\n llmPlatform?: undefined\\n llmPlatformConversationItem?: undefined\\n}\\n\\nexport type OutputItem = OutputMessage | Reasoning | FunctionCallInput\\n\\nexport type InputItem = InputMessage | FunctionCallOutput\\n\\nexport type PromptItem = InputItem | OutputItem\\n\\nexport type ServiceTier = 'normal' | 'flex'\\n\\nexport type GenericPrompt = PromptItem[]\\n\\n/**\\n * Determines whether to include a type spec message based on the model.\\n * Currently returns false for OpenAI models (they handle JSON schema natively),\\n * true for others that might need explicit instructions.\\n */\\nexport function useTypeSpecMessage(model: AiModelId): boolean {\\n // OpenAI models handle JSON schema natively via response_format\\n // so we don't need the type spec message\\n if (model.startsWith('gpt-') || model.startsWith('o1-') || model === 'o1' || model === 'o3-mini' || model === 'o3') {\\n return false\\n }\\n \\n // For other models, we might need the type spec message\\n // (keeping this ready for future model support)\\n return true\\n}\\n\\n/**\\n * Determines whether to include a type spec message based on the model.\\n * Currently returns false for OpenAI models (they handle JSON schema natively),\\n * true for others that might need explicit instructions.\\n */\\nexport function mustHaveWordJsonInMessageBodyForJsonResponse(model: AiModelId): boolean {\\n // OpenAI models handle JSON schema natively via response_format\\n // so we don't need the type spec message\\n if (model.startsWith('gpt-') || model.startsWith('o1-') || model === 'o1' || model === 'o3-mini' || model === 'o3') {\\n return true\\n }\\n\\n // For other models, we might need the type spec message\\n // (keeping this ready for future model support)\\n return false\\n}\\n\\nexport type PromptRequest<Stream extends boolean = false> = {\\n prompt: GenericPrompt\\n requireJsonResponse?: boolean\\n model: AiModelId\\n llamaCppHomeDir?: string\\n /**\\n * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both.\\n */\\n temperature?: number\\n topP?: number\\n stream?: Stream\\n llmArgs?: LargeLanguageModelArgs\\n platform: PlatformId\\n apiToken: string\\n serviceTier: ServiceTier\\n}\\n\\ntype LargeLanguageModelArgs = {\\n top_k?: any\\n top_p?: any\\n temp?: any\\n batch_size?: any\\n repeat_last_n?: any\\n repeat_penalty?: any\\n interactive?: any\\n seed?: number\\n threads?: number\\n n_predict?: number\\n ctx_size?: number\\n url?: string\\n}\\n\",\"import {AiModelId} from '../AiModelId.ts'\\nimport {Flux} from 'monoflux'\\nimport {ResponseStreamEvent} from './model/ResponseStreamEvent.js'\\nimport {InputItem} from './model/InputItem.js'\\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 openAiRequest: ResponsesApiRequestBody,\\n apiToken: string,\\n): { flux: Flux<ResponseStreamEvent>; httpRequest: any } {\\n const httpRequest = {\\n url: 'https://api.openai.com/v1/responses',\\n method: 'POST',\\n headers: {\\n 'Content-Type': 'application/json',\\n 'Accept': 'application/json',\\n 'Authorization': `Bearer ${apiToken.slice(0, 7)}...${apiToken.slice(-4)}` // Redact most of the token\\n },\\n body: openAiRequest,\\n }\\n \\n const flux = Flux.fromGeneratorFunction(async function* () {\\n const abortController = new AbortController()\\n const response = await fetch(\\n 'https://api.openai.com/v1/responses',\\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(openAiRequest)\\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 buffer = ''\\n \\n yield* Flux\\n .fromReadableStream(response.body, () => abortController.abort())\\n .map(value => textDecoder.decode(value, {stream: true}))\\n .flatMap(value => {\\n buffer += value\\n const events: string[] = []\\n \\n // Split on double newlines to separate SSE events\\n const parts = buffer.split('\\\\n\\\\n')\\n \\n // Keep the last part in buffer if it might be incomplete\\n buffer = parts.pop() || ''\\n \\n // Process complete events\\n for (const part of parts) {\\n if (part.trim()) {\\n events.push(part.trim())\\n }\\n }\\n \\n return events\\n })\\n .flatMap(eventText => {\\n // Parse SSE event\\n const lines = eventText.split('\\\\n')\\n let data = ''\\n \\n for (const line of lines) {\\n if (line.startsWith('data: ')) {\\n data += line.substring(6)\\n }\\n }\\n \\n if (!data) return []\\n \\n try {\\n const json = JSON.parse(data) as ResponseStreamEvent\\n return [json]\\n } catch (e) {\\n return []\\n }\\n })\\n })\\n \\n return {flux, httpRequest}\\n}\\n\\nconst textDecoder = new TextDecoder()\\n\\nexport type ResponsesApiRequestBody = {\\n model: AiModelId\\n input: string | InputItem[]\\n stream: boolean\\n temperature?: number\\n top_p?: number\\n text?: {\\n format: {\\n type: 'json_object' | 'text' | 'json_schema'\\n name: string\\n schema?: any\\n strict?: boolean\\n }\\n }\\n service_tier?: 'default' | 'flex'\\n tools?: {\\n type: 'function'\\n name: string\\n description?: string\\n strict: boolean\\n parameters?: any\\n }[]\\n}\\n\\nexport type OpenAIRequestyBody = ResponsesApiRequestBody\\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.has(\\n propertyName,\\n type => type.canBeString()\\n )\\n }\\n\\n hasNumber<Key extends string>(propertyName: Key): TypeSpec<Combine<T, Record<Key, number>>> {\\n return this.has(\\n propertyName,\\n type => type.canBeNumber()\\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.has(propertyName, assertTypeOfProperty, true)\\n }\\n\\n has<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 has<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 has<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} of content: ${this.content}`)\\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 /**\\n * Has non-optional property\\n */\\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'\",\"import {TypeSpec} from './type-spec/type-spec.js'\\n\\nexport function typeSpecToJsonSchema(typeSpec: TypeSpec<any>): any {\\n const convertType = (type: any): any => {\\n if (Array.isArray(type)) {\\n // Handle union types\\n if (type.length === 1) {\\n return convertType(type[0])\\n }\\n\\n // Check if all types are constants (enum case)\\n if (type.every(t => t.type === 'constant')) {\\n return {\\n type: 'string',\\n enum: type.map(t => t.value)\\n }\\n }\\n\\n // For other union types, use oneOf\\n return {\\n anyOf: type.map(t => convertType(t))\\n }\\n }\\n\\n switch (type.type) {\\n case 'object': {\\n const properties: any = {}\\n const required: string[] = []\\n\\n for (const [key, propSpec] of Object.entries(type.props)) {\\n const convertedType = convertType((propSpec as any).type)\\n \\n // Add description if comment exists\\n if ((propSpec as any).comment) {\\n properties[key] = {\\n ...convertedType,\\n description: (propSpec as any).comment\\n }\\n } else {\\n properties[key] = convertedType\\n }\\n \\n if (!(propSpec as any).optional) {\\n required.push(key)\\n }\\n }\\n\\n return {\\n type: 'object',\\n properties,\\n required: required.length > 0 ? required : undefined,\\n additionalProperties: false\\n }\\n }\\n case 'array': {\\n return {\\n type: 'array',\\n items: convertType(type.elementType)\\n }\\n }\\n case 'string': {\\n return {type: 'string'}\\n }\\n case 'number': {\\n return {type: 'number'}\\n }\\n case 'boolean': {\\n return {type: 'boolean'}\\n }\\n case 'null': {\\n return {type: 'null'}\\n }\\n case 'undefined': {\\n return {type: 'null'}\\n }\\n case 'constant': {\\n // If the constant is an array, it likely represents enum values\\n if (Array.isArray(type.value)) {\\n return {\\n type: 'string',\\n enum: type.value\\n }\\n }\\n return {\\n type: 'string',\\n const: type.value\\n }\\n }\\n default: {\\n return {type: 'string'} // fallback\\n }\\n }\\n }\\n\\n return convertType(typeSpec['type'])\\n}\",\"import {InputMessage, PlatformSpecificPromptRequest} from '../model.js'\\nimport {OpenAIRequestyBody} from './promptOpenai.js'\\nimport {InputItem} from './model/InputItem.js'\\nimport {OutputItem} from './model/OutputItem.js'\\n\\nexport function genericLLMCallToOpenAiCall(\\n {\\n model,\\n prompt,\\n temperature,\\n topP,\\n requireJsonResponse,\\n jsonSchema,\\n serviceTier,\\n tools\\n }: PlatformSpecificPromptRequest<boolean> & {\\n jsonSchema?: { name: string; schema: any; strict?: boolean }\\n tools?: {\\n type: 'function'\\n name: string\\n description?: string\\n parameters: any\\n strict: boolean\\n }[]\\n }\\n): OpenAIRequestyBody {\\n return {\\n model,\\n input: prompt.map(item => {\\n if (item.llmPlatformConversationItem && item.llmPlatform === 'openai') {\\n return item.llmPlatformConversationItem\\n }\\n if (item.type === 'function_call_output') {\\n return {\\n type: 'function_call_output',\\n call_id: item.functionCallId,\\n output: item.content\\n } satisfies InputItem\\n }\\n if (item.role === 'assistant') {\\n return {\\n type: 'message',\\n role: item.role,\\n content: [\\n {\\n type: 'output_text',\\n text: item.content\\n }\\n ]\\n }\\n }\\n return {\\n role: item.role,\\n content: [\\n {\\n type: 'input_text',\\n text: item.content\\n }\\n ]\\n }\\n }),\\n stream: true,\\n temperature,\\n top_p: topP,\\n text: jsonSchema ? {\\n format: {\\n type: 'json_schema' as const,\\n name: jsonSchema.name,\\n schema: jsonSchema.schema,\\n strict: jsonSchema.strict\\n }\\n } : requireJsonResponse ? {\\n format: {\\n type: 'json_object' as const,\\n name: 'response'\\n }\\n } : undefined,\\n service_tier: serviceTier === 'flex' ? 'flex' : 'default',\\n tools\\n }\\n}\",\"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-audio)\\n */\\n gpt_audio: 'gpt-audio',\\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-audio-2025-08-28)\\n */\\n gpt_audio_2025_08_28: 'gpt-audio-2025-08-28',\\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 | ? | ? |\\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-realtime)\\n */\\n gpt_realtime: 'gpt-realtime',\\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-realtime-2025-08-28)\\n */\\n gpt_realtime_2025_08_28: 'gpt-realtime-2025-08-28',\\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 * \\\"OpenAI model ID: o3-deep-research\\\"\\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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AAAC,iBAAAC,mBAAAC,8BAAAC,6BAAAC,qBAAAC,eAAAC,qBAAAC,SAAAC,iBAAAC,qCAAAC,kBAAAC,yBAAAC,sBAAAC,eAAAC,cAAAC\",\"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\",\"ne\",\"at\",\"fe\",\"Object\",\"defineProperty\",\"Flux_1\",\"ut\",\"enumerable\",\"get\",\"import_monoflux\",\"de\",\"useTypeSpecMessage\",\"model\",\"startsWith\",\"promptOpenai\",\"openAiRequest\",\"apiToken\",\"httpRequest\",\"url\",\"method\",\"headers\",\"Accept\",\"Authorization\",\"slice\",\"body\",\"Ne\",\"abortController\",\"AbortController\",\"response\",\"fetch\",\"signal\",\"JSON\",\"stringify\",\"status\",\"message\",\"bodyText\",\"parse\",\"errorMessage\",\"text\",\"buffer\",\"abort\",\"textDecoder\",\"decode\",\"parts\",\"split\",\"pop\",\"part\",\"trim\",\"eventText\",\"lines\",\"data\",\"line\",\"substring\",\"TextDecoder\",\"ComplexTypeError\",\"httpStatus\",\"problems\",\"problem\",\"expectedProp\",\"path\",\"replace\",\"expectedType\",\"typeToString\",\"join\",\"insteadGot\",\"unknownProp\",\"super\",\"requireThat\",\"TypeSpec\",\"checkIsOneOf\",\"types\",\"opts\",\"problemsPerType\",\"type\",\"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\",\"has\",\"canBeString\",\"hasNumber\",\"canBeNumber\",\"canHaveProperty\",\"assertTypeOfProperty\",\"old\",\"propertyType\",\"canBeBoolean\",\"canBeConstant\",\"canBeNull\",\"canBeUndefined\",\"andNothingElse\",\"orDefaultTo\",\"describe\",\"indentLevel\",\"keys\",\"indent\",\"depth\",\"config\",\"getPromptGridApiUrl\",\"rawValue\",\"url2\",\"backendUrlNotTriviallyIdentifiableInMinifiedCode\",\"Token\",\"source\",\"fieldName\",\"maybeIncomplete\",\"JsonTokenProcessor\",\"_JsonTokenProcessor\",\"jsonBuffer\",\"highestOffsetParsed\",\"toJsonTokenFlux\",\"dataBufferFlux\",\"processDataBuffer\",\"deltaContentFlux\",\"content\",\"getExcerpts\",\"token\",\"excerpts\",\"jsonParser\",\"JsonParser\",\"nextToken\",\"currentTokenLocation\",\"getCharOffset\",\"position\",\"currentTokenType\",\"parentFieldName\",\"currentValue\",\"context\",\"startPosition\",\"test\",\"char\",\"pushContext\",\"popContext\",\"currentContextType\",\"startPos\",\"endPos\",\"indexOf\",\"nextFourChars\",\"nextFiveChars\",\"numStr\",\"hasDecimal\",\"parseFloat\",\"parseInt\",\"mayBeIncomplete\",\"JsonParseException\",\"contextType\",\"currentContext\",\"name\",\"nonNullish\",\"StreamedJsonElement\",\"receivedJson\",\"propertyCallbacks\",\"Map\",\"onElementCallbacks\",\"Set\",\"onCompleteCallbacks\",\"onEachExcerptCallbacks\",\"currentToken\",\"state\",\"Begin\",\"receivedExcerpts\",\"onElement\",\"add\",\"onProperty\",\"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\",\"dt\",\"whenCompleteAs\",\"isState\",\"InNested\",\"child\",\"tokenType\",\"size\",\"InObject\",\"InArray\",\"end\",\"UnexpectedTokenException\",\"resultingJson\",\"InPropertyValue\",\"InArrayElement\",\"subscription\",\"completeValue\",\"from\",\"stateClass\",\"count\",\"State\",\"StreamedJsonRootElement\",\"jsonTokenFlux\",\"yt\",\"lastTokenExcerpt\",\"StreamedJsonParser\",\"parseJsonWithUsefulError\",\"completedJson\",\"parsePartialJson\",\"partialJson\",\"opened\",\"escaped\",\"pushScope\",\"scope\",\"popScope\",\"expect\",\"lastOpened\",\"includes\",\"illegalState\",\"nextEscapedValue\",\"match\",\"closeEverything\",\"reverse\",\"opener\",\"requireDefined\",\"byteToHex\",\"toString\",\"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\",\"hasBoolean\",\"hasConstant\",\"arg2\",\"otherArgs\",\"constants\",\"PropTypeSpec\",\"withComment\",\"_FullPropTypeSpec\",\"assertType\",\"typeSpec\",\"describeType\",\"propSpec\",\"comma\",\"promptOpenaiImageGen\",\"apiKey\",\"prompt\",\"ok\",\"errorData\",\"json\",\"b64_json\",\"atob\",\"charCodeAt\",\"writeFile\",\"typeSpecToJsonSchema\",\"convertType\",\"every\",\"enum\",\"anyOf\",\"required\",\"entries\",\"convertedType\",\"description\",\"additionalProperties\",\"items\",\"const\",\"genericLLMCallToOpenAiCall\",\"temperature\",\"topP\",\"requireJsonResponse\",\"jsonSchema\",\"serviceTier\",\"tools\",\"input\",\"item\",\"llmPlatformConversationItem\",\"llmPlatform\",\"call_id\",\"functionCallId\",\"output\",\"role\",\"top_p\",\"format\",\"schema\",\"strict\",\"service_tier\",\"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_audio\",\"gpt_audio_2025_08_28\",\"gpt_image_1\",\"gpt_realtime\",\"gpt_realtime_2025_08_28\",\"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\",\"messages\",\"apiKeyChain\",\"obtainAiClientData\",\"conversation\",\"chat\",\"arg1\",\"toPrompt\",\"effectiveMessages\",\"user\",\"m\",\"BasicPrompt\",\"getCallerFileNameAndLineNumber\",\"image\",\"ImagePrompt\",\"_AIConversation\",\"copyConversation\",\"_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\",\"_BasicPrompt\",\"promptSupplier\",\"promptSupplierArgs\",\"_temperature\",\"_topP\",\"_serviceTier\",\"_firstThink\",\"_strict\",\"promptName\",\"_tools\",\"_checks\",\"_genericPrompt\",\"computeGenericPrompt\",\"self\",\"executeLlmCall\",\"effectiveModel\",\"stringGenerator\",\"chunk\",\"RETRY_SIGNAL\",\"copy\",\"firstThink\",\"flex\",\"useFlexTier\",\"check\",\"attempts\",\"checks\",\"promptItemToMessage\",\"TypeSpecMarker\",\"genericPrompt\",\"typeSpecIndex\",\"toGenericPrompt\",\"jsonSpecContent\",\"jsonSpec\",\"jsonSpecMessage\",\"JsonPrompt\",\"getBoolean\",\"o\",\"getString\",\"getNumber\",\"getObject\",\"getArray\",\"JsonArrayPrompt\",\"getAny\",\"normalizedTools\",\"tool\",\"defineTool\",\"parameters\",\"function\",\"_JsonPrompt\",\"jsonTypeSupplier\",\"computePrompt\",\"streamingJsonRootElement\",\"getFlux\",\"jsonTokenProcessor\",\"rt\",\"lazyGenerator\",\"jsonExcerpt\",\"partialJsonGenerator\",\"accumulatedJson\",\"getResponse\",\"stringResult\",\"uncheckedPackedResult\",\"_responseAsStringPromise\",\"_getResponseAsString\",\"arrayElementGenerator\",\"typeSpecMessage\",\"toOpenAiMessage\",\"msg\",\"system\",\"assistant\",\"genericPromptWithJsonSpec\",\"convSavePromises\",\"promptFilename\",\"lineNumber\",\"promptLineNumber\",\"promptProfile\",\"id\",\"conversationUuid\",\"saveLoop\",\"conversationMessages\",\"saveConv\",\"conversationData\",\"newMsg\",\"existing\",\"find\",\"currentSave\",\"nextSave\",\"saveConversation\",\"delete\",\"genericPromptWithJsonSpecAndConversationHistory\",\"attemptNr\",\"attemptsPerCheck\",\"openaiTools\",\"jsonSchemaForAiCall\",\"streamedText\",\"responseItems\",\"event\",\"delta\",\"platformItem\",\"itemI\",\"findIndex\",\"it\",\"newItemValue\",\"common\",\"summary\",\"arguments\",\"toolCalls\",\"functionCall\",\"toolResultMessages\",\"executeToolCalls\",\"toolResult\",\"tool_call_id\",\"call\",\"textResponse\",\"checkedResult\",\"uncheckedResult\",\"typeError\",\"uncheckedResultWhichShouldBePacked\",\"String\",\"promises\",\"all\",\"v\",\"attemptCount\",\"CheckFailedTooManyTimes\",\"feedbackMessage\",\"p\",\"setTimeout\",\"warn\",\"maxAttempts\",\"problemsOnLastAttempt\",\"rawSchema\",\"toolCallsToExecute\",\"toolResults\",\"toolCall\",\"toolResultContent\",\"mustHaveWordJsonInMessageBodyForJsonResponse\",\"newO\",\"frame\",\"stack\",\"l\",\"hasFunctionNameInFrameWithFileNameInParenthesis\",\"functionName\",\"groups\",\"stacktraceFrame\",\"modelArg\",\"me\",\"Qe\",\"qt\",\"Pe\",\"Se\",\"$\",\"w\",\"P\",\"Ze\",\"Xe\",\"nt\",\"Ae\",\"Wt\",\"tt\",\"le\",\"G\",\"ue\",\"D\",\"Q\",\"ke\",\"et\",\"Er\",\"Ee\",\"Cr\",\"bt\",\"Ge\",\"kr\",\"Ar\",\"X\"],\"sources\":[\"../node_modules/monoflux/src/Flux.ts\",\"../node_modules/monoflux/src/index.ts\",\"../src/index.ts\",\"../src/ai-inference/model.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/typeSpecToJsonSchema.ts\",\"../src/ai-inference/openai/genericLLMCallToOpenAiCall.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 {\\n\\tFunctionCallInput,\\n\\tFunctionCallOutput,\\n\\tGenericPrompt,\\n\\tInputItem,\\n\\tInputMessage,\\n\\tmustHaveWordJsonInMessageBodyForJsonResponse,\\n\\tOutputItem,\\n\\tOutputMessage,\\n\\tPromptItem,\\n\\tPromptItemBase,\\n\\tPromptItemType,\\n\\tReasoning,\\n\\tRole,\\n\\tServiceTier,\\n\\tuseTypeSpecMessage\\n} from './ai-inference/model.js'\\nimport {promptOpenai} 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'\\nimport {typeSpecToJsonSchema} from './typeSpecToJsonSchema.js'\\nimport {genericLLMCallToOpenAiCall} from './ai-inference/openai/genericLLMCallToOpenAiCall.js'\\nimport {BaseOutputItem, FunctionCall, OutputItemType} from './ai-inference/openai/model/OutputItem.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: PromptItem[]\\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\\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\\tuuid: 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\\tfalse,\\n\\t\\t)\\n\\t}\\n}\\n\\ntype CheckCallback<T extends string | AnyJson> = (output: T) => Promise<(string | null | undefined)[] | string | null | undefined | void> | (string | null | undefined)[] | string | null | undefined | void\\n\\nexport type Check<T extends string | AnyJson> = {\\n\\tcallback: CheckCallback<T>\\n\\tattempts: number\\n}\\n\\nclass BasicPrompt<PSArgs> implements AsyncGenerator<string>, Promise<string> {\\n\\tprivate readonly generator: AsyncGenerator<string>\\n\\tprivate readonly stringGenerator: AsyncGenerator<string>\\n\\tprivate _genericPrompt: GenericPrompt\\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\\tprivate _strict: boolean = false,\\n\\t\\tprivate promptName?: string,\\n\\t\\tprivate _tools: ToolDefinition[] = [],\\n\\t\\tprivate _checks: Check<string>[] = [],\\n\\t) {\\n\\t\\tthis._genericPrompt = this.computeGenericPrompt()\\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\\teffectiveModel(_model),\\n\\t\\t\\t\\tself._genericPrompt,\\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\\tself._strict,\\n\\t\\t\\t\\tself._tools,\\n\\t\\t\\t\\tself._checks,\\n\\t\\t\\t\\tundefined,\\n\\t\\t\\t)\\n\\t\\t})()\\n\\t\\tthis.stringGenerator = (async function*() {\\n\\t\\t\\tfor await (const chunk of self.generator) {\\n\\t\\t\\t\\tif (chunk !== RETRY_SIGNAL) {\\n\\t\\t\\t\\t\\tyield chunk\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t})()\\n\\t}\\n\\n\\tpublic name(name: string): BasicPrompt<PSArgs> {\\n\\t\\treturn this.copy({promptName: name})\\n\\t}\\n\\n\\tpublic model(model: AiModelId): BasicPrompt<PSArgs> {\\n\\t\\treturn this.copy({model})\\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): BasicPrompt<PSArgs> {\\n\\t\\treturn this.copy({firstThink})\\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): BasicPrompt<PSArgs> {\\n\\t\\treturn this.copy({temperature});\\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): BasicPrompt<PSArgs> {\\n\\t\\treturn this.copy({topP});\\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\\treturn this.copy({serviceTier: useFlexTier ? 'flex' : undefined})\\n\\t}\\n\\n\\t/**\\n\\t * Controls whether OpenAI strict mode is enabled for JSON schema validation.\\n\\t * When enabled (default), OpenAI will strictly enforce the JSON schema.\\n\\t * When disabled, OpenAI will use a more lenient validation approach.\\n\\t */\\n\\tpublic strict(strict = true) {\\n\\t\\treturn this.copy({strict})\\n\\t}\\n\\n\\t/**\\n\\t * @param check - Callback that returns a string or an array of strings for each problem with the output\\n\\t * the AI passes to it, or nothing, null, undefined or an empty array if there are no problems. These\\n\\t * problems are passed to the AI so the AI will know how to correct a result.\\n\\t * @param attempts - The nr of attempts (minimally 1) an LLM gets to pass this check. The count is held\\n\\t * independently for each check and is independent from the {@link PromptGunConfig.attemptsPerCall} setting.\\n\\t */\\n\\tpublic check(check: CheckCallback<string>, attempts = 10) {\\n\\t\\tif (attempts < 1) {\\n\\t\\t\\tthrow new Error('The number of attempts must be at least 1')\\n\\t\\t}\\n\\t\\treturn this.copy({checks: [\\n\\t\\t\\t...this._checks,\\n\\t\\t\\t{\\n\\t\\t\\t\\tcallback: check,\\n\\t\\t\\t\\tattempts,\\n\\t\\t\\t},\\n\\t\\t]})\\n\\t}\\n\\n\\tprivate copy(\\n\\t\\t{\\n\\t\\t\\taiClient,\\n\\t\\t\\tpromptSupplier,\\n\\t\\t\\tpromptSupplierArgs,\\n\\t\\t\\tcallingCodeLine,\\n\\t\\t\\ttemperature,\\n\\t\\t\\ttopP,\\n\\t\\t\\tserviceTier,\\n\\t\\t\\tmodel,\\n\\t\\t\\tfirstThink,\\n\\t\\t\\tstrict,\\n\\t\\t\\tpromptName,\\n\\t\\t\\ttools,\\n\\t\\t\\tchecks,\\n\\t\\t}: {\\n\\t\\t\\taiClient?: AIClient,\\n\\t\\t\\tpromptSupplier?: (args: PSArgs, typeSpecMessage?: TypeSpecMessage) => Prompt,\\n\\t\\t\\tpromptSupplierArgs?: PSArgs,\\n\\t\\t\\tcallingCodeLine?: CodeLine,\\n\\t\\t\\ttemperature?: number | undefined,\\n\\t\\t\\ttopP?: number | undefined,\\n\\t\\t\\tserviceTier?: ServiceTier | undefined,\\n\\t\\t\\tmodel?: AiModelId | undefined,\\n\\t\\t\\tfirstThink?: boolean,\\n\\t\\t\\tstrict?: boolean,\\n\\t\\t\\tpromptName?: string,\\n\\t\\t\\ttools?: ToolDefinition[],\\n\\t\\t\\tchecks?: Check<string>[],\\n\\t\\t}\\n\\t): BasicPrompt<PSArgs> {\\n\\t\\treturn new BasicPrompt<PSArgs>(\\n\\t\\t\\taiClient ?? this.aiClient,\\n\\t\\t\\tpromptSupplier ?? this.promptSupplier,\\n\\t\\t\\tpromptSupplierArgs ?? this.promptSupplierArgs,\\n\\t\\t\\tcallingCodeLine ?? this.callingCodeLine,\\n\\t\\t\\ttemperature ?? this._temperature,\\n\\t\\t\\ttopP ?? this._topP,\\n\\t\\t\\tserviceTier ?? this._serviceTier,\\n\\t\\t\\tmodel ?? this._model,\\n\\t\\t\\tfirstThink ?? this._firstThink,\\n\\t\\t\\tstrict ?? this._strict,\\n\\t\\t\\tpromptName ?? this.promptName,\\n\\t\\t\\ttools ?? this._tools,\\n\\t\\t\\tchecks ?? this._checks\\n\\t\\t)\\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._genericPrompt\\n\\t\\t\\t.map(promptItemToMessage)\\n\\t}\\n\\n\\tprivate get json() {\\n\\t\\treturn false\\n\\t}\\n\\n\\tprivate computeGenericPrompt() {\\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 jsonSpecContent = jsonSpec(effectiveModel(this._model), this.json, this._firstThink)\\n\\t\\t\\n\\t\\t// If jsonSpec returns null (for OpenAI models), don't add the type spec message\\n\\t\\tif (jsonSpecContent === null) {\\n\\t\\t\\treturn genericPrompt\\n\\t\\t}\\n\\t\\t\\n\\t\\tconst jsonSpecMessage = {\\n\\t\\t\\tuuid: randomUuid(),\\n\\t\\t\\ttype: 'input_message',\\n\\t\\t\\trole: 'user' as const,\\n\\t\\t\\tcontent: jsonSpecContent\\n\\t\\t} satisfies InputMessage\\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.stringGenerator.next(value)\\n\\t}\\n\\n\\treturn(value: any): Promise<IteratorResult<string, any>> {\\n\\t\\treturn this.stringGenerator.return(value)\\n\\t}\\n\\n\\tthrow(e: any): Promise<IteratorResult<string, any>> {\\n\\t\\treturn this.stringGenerator.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\\tthis._strict,\\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\\tthis._strict,\\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.push(...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\\tif (chunk === RETRY_SIGNAL) {\\n\\t\\t\\t\\tresult = ''\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\t}\\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\\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 _genericPrompt: GenericPrompt\\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\\tprotected _tools: ToolDefinition[] = [],\\n\\t\\tprotected _strict: boolean = false,\\n\\t\\tprotected _checks: Check<Json>[] = []\\n\\t) {\\n\\t\\tsuper()\\n\\t\\tconst thiss = this\\n\\t\\t\\n\\t\\t// Create lazy generator that will only execute when accessed\\n\\t\\tthis._genericPrompt = this.computePrompt()\\n\\t\\tconst lazyGenerator = (async function*() {\\n\\t\\t\\tyield* await executeLlmCall(\\n\\t\\t\\t\\taiClient,\\n\\t\\t\\t\\teffectiveModel(_model),\\n\\t\\t\\t\\tthiss._genericPrompt,\\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\\tthiss._strict,\\n\\t\\t\\t\\tthiss._tools,\\n\\t\\t\\t\\tthiss._checks,\\n\\t\\t\\t\\tjsonTypeSupplier,\\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\\tconst jsonTokenProcessor = new JsonTokenProcessor()\\n\\t\\t\\tif (!flux) {\\n\\t\\t\\t\\tflux = Flux.fromGenerator(lazyGenerator())\\n\\t\\t\\t\\tjsonTokenFlux = 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 {\\n\\t\\t\\t\\tflux: flux!,\\n\\t\\t\\t\\tjsonTokenFlux: jsonTokenFlux!,\\n\\t\\t\\t\\tstreamingJsonRootElement: streamingJsonRootElement!,\\n\\t\\t\\t\\tjsonTokenProcessor\\n\\t\\t\\t}\\n\\t\\t}\\n\\t\\t\\n\\t\\tthis.stringGenerator = (async function*() {\\n\\t\\t\\tconst { flux, streamingJsonRootElement, jsonTokenProcessor } = getFlux()\\n\\t\\t\\tfor await (const chunk of flux) {\\n\\t\\t\\t\\tif (chunk === RETRY_SIGNAL) {\\n\\t\\t\\t\\t\\tyield chunk\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tconst excerpts = jsonTokenProcessor.getExcerpts(chunk)\\n\\t\\t\\t\\tfor (const jsonExcerpt of excerpts) {\\n\\t\\t\\t\\t\\tif (jsonExcerpt.token !== undefined) {\\n\\t\\t\\t\\t\\t\\tstreamingJsonRootElement.push(jsonExcerpt)\\n\\t\\t\\t\\t\\t} else if (jsonExcerpt.source !== undefined) {\\n\\t\\t\\t\\t\\t\\tyield jsonExcerpt.source\\n\\t\\t\\t\\t\\t}\\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\\t// Filter out retry reset events from reaching external consumers\\n\\t\\t\\t\\tif (chunk === RETRY_SIGNAL) {\\n\\t\\t\\t\\t\\taccumulatedJson = ''\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t}\\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): JsonPrompt<PSArgs, Json> {\\n\\t\\treturn this.copy({promptName: name})\\n\\t}\\n\\n\\tpublic model(model: AiModelId): JsonPrompt<PSArgs, Json> {\\n\\t\\treturn this.copy({model})\\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): JsonPrompt<PSArgs, Json> {\\n\\t\\treturn this.copy({firstThink})\\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): JsonPrompt<PSArgs, Json> {\\n\\t\\treturn this.copy({temperature})\\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): JsonPrompt<PSArgs, Json> {\\n\\t\\treturn this.copy({topP})\\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): JsonPrompt<PSArgs, Json> {\\n\\t\\treturn this.copy({serviceTier: useFlexTier ? 'flex' : undefined})\\n\\t}\\n\\n\\t/**\\n\\t * Controls whether OpenAI strict mode is enabled for JSON schema validation.\\n\\t * When enabled (default), OpenAI will strictly enforce the JSON schema.\\n\\t * When disabled, OpenAI will use a more lenient validation approach.\\n\\t */\\n\\tpublic strict(strict = true): JsonPrompt<PSArgs, Json> {\\n\\t\\treturn this.copy({strict})\\n\\t}\\n\\n\\t/**\\n\\t * @param check - Callback that returns a string or an array of strings for each problem with the output\\n\\t * the AI passes to it, or nothing, null, undefined or an empty array if there are no problems. These\\n\\t * problems are passed to the AI so the AI will know how to correct a result.\\n\\t * @param attempts - The nr of attempts (minimally 1) an LLM gets to pass this check. The count is held\\n\\t * independently for each check and is independent from the {@link PromptGunConfig.attemptsPerCall} setting.\\n\\t */\\n\\tpublic check(check: CheckCallback<Json>, attempts = 10) {\\n\\t\\tif (attempts < 1) {\\n\\t\\t\\tthrow new Error('The number of attempts must be at least 1')\\n\\t\\t}\\n\\t\\treturn this.copy({checks: [\\n\\t\\t\\t\\t...this._checks,\\n\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\tcallback: check,\\n\\t\\t\\t\\t\\tattempts,\\n\\t\\t\\t\\t},\\n\\t\\t\\t]})\\n\\t}\\n\\n\\tprivate copy(\\n\\t\\t{\\n\\t\\t\\taiClient,\\n\\t\\t\\tpromptSupplier,\\n\\t\\t\\tpromptSupplierArgs,\\n\\t\\t\\tjsonTypeSupplier,\\n\\t\\t\\tcallingCodeLine,\\n\\t\\t\\ttemperature,\\n\\t\\t\\ttopP,\\n\\t\\t\\tserviceTier,\\n\\t\\t\\tmodel,\\n\\t\\t\\tfirstThink,\\n\\t\\t\\tstrict,\\n\\t\\t\\tpromptName,\\n\\t\\t\\ttools,\\n\\t\\t\\tchecks,\\n\\t\\t}: {\\n\\t\\t\\taiClient?: AIClient,\\n\\t\\t\\tpromptSupplier?: (args: PSArgs, typeSpecMessage?: TypeSpecMessage) => Prompt,\\n\\t\\t\\tpromptSupplierArgs?: PSArgs,\\n\\t\\t\\tjsonTypeSupplier?: ((value: EmptyTypeSpec<unknown>) => TypeSpec<Json>),\\n\\t\\t\\tcallingCodeLine?: CodeLine,\\n\\t\\t\\ttemperature?: number | undefined,\\n\\t\\t\\ttopP?: number | undefined,\\n\\t\\t\\tserviceTier?: ServiceTier | undefined,\\n\\t\\t\\tmodel?: AiModelId | undefined,\\n\\t\\t\\tfirstThink?: boolean,\\n\\t\\t\\tstrict?: boolean,\\n\\t\\t\\tpromptName?: string,\\n\\t\\t\\ttools?: ToolDefinition[],\\n\\t\\t\\tchecks?: Check<Json>[],\\n\\t\\t}\\n\\t): JsonPrompt<PSArgs, Json> {\\n\\t\\treturn new JsonPrompt<PSArgs, Json>(\\n\\t\\t\\taiClient ?? this.aiClient,\\n\\t\\t\\tpromptSupplier ?? this.promptSupplier,\\n\\t\\t\\tpromptSupplierArgs ?? this.promptSupplierArgs,\\n\\t\\t\\tjsonTypeSupplier ?? this.jsonTypeSupplier,\\n\\t\\t\\tcallingCodeLine ?? this.callingCodeLine,\\n\\t\\t\\tpromptName ?? this.promptName,\\n\\t\\t\\ttemperature ?? this._temperature,\\n\\t\\t\\ttopP ?? this._topP,\\n\\t\\t\\tserviceTier ?? this._serviceTier,\\n\\t\\t\\tmodel ?? this._model,\\n\\t\\t\\tfirstThink ?? this._firstThink,\\n\\t\\t\\ttools ?? this._tools,\\n\\t\\t\\tstrict ?? this._strict,\\n\\t\\t\\tchecks ?? this._checks\\n\\t\\t)\\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._genericPrompt\\n\\t\\t\\t.map(promptItemToMessage)\\n\\t}\\n\\n\\tprivate computePrompt() {\\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 jsonSpecContent = jsonSpec(effectiveModel(this._model), this.json, this._firstThink)\\n\\t\\t\\n\\t\\t// If jsonSpec returns null (for OpenAI models), don't add the type spec message\\n\\t\\tif (jsonSpecContent === null) {\\n\\t\\t\\treturn genericPrompt\\n\\t\\t}\\n\\t\\t\\n\\t\\tconst jsonSpecMessage = {\\n\\t\\t\\ttype: 'input_message',\\n\\t\\t\\tuuid: randomUuid(),\\n\\t\\t\\trole: 'user' as const,\\n\\t\\t\\tcontent: jsonSpecContent\\n\\t\\t} satisfies InputMessage\\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\\t\\n\\t\\t// Determine if we expect a wrapped response\\n\\t\\tconst expectsWrappedResponse = (() => {\\n\\t\\t\\tif (jsonTypeSupplier === undefined) {\\n\\t\\t\\t\\treturn false\\n\\t\\t\\t}\\n\\t\\t\\t// Only expect wrapped response when using OpenAI structured outputs\\n\\t\\t\\t// and the original schema wasn't already an object\\n\\t\\t\\tif (!useTypeSpecMessage(effectiveModel(this._model))) {\\n\\t\\t\\t\\tconst typeSpec = jsonTypeSupplier(specType(undefined as unknown))\\n\\t\\t\\t\\tconst rawSchema = typeSpecToJsonSchema(typeSpec)\\n\\t\\t\\t\\treturn rawSchema.type !== 'object'\\n\\t\\t\\t}\\n\\t\\t\\treturn true // Non-OpenAI models use type spec message and expect wrapped response\\n\\t\\t})()\\n\\t\\t\\n\\t\\tconst uncheckedResult = expectsWrappedResponse\\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.push(...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\\tif (chunk === RETRY_SIGNAL) {\\n\\t\\t\\t\\t// Reset accumulated content on retry\\n\\t\\t\\t\\tresult = ''\\n\\t\\t\\t\\tcontinue\\n\\t\\t\\t}\\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\\t_strict: boolean = false,\\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\\t_strict,\\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 toGenericPrompt(prompt: string | Message | (Message | undefined)[], typeSpecMessage?: TypeSpecMessage): {messages: GenericPrompt, typeSpecIndex?: number} {\\n\\tconst toOpenAiMessage = (msg: Message | undefined): PromptItem | 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\\ttype: 'input_message',\\n\\t\\t\\tuuid: randomUuid(),\\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: [{type: 'input_message', uuid: randomUuid(), 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: PromptItem[] = []\\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,\\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\\tstrict: boolean,\\n\\ttools: ToolDefinition[],\\n\\tchecks: Check<any>[],\\n\\tjsonTypeSupplier?: ((value: EmptyTypeSpec<unknown>) => TypeSpec<any>) | undefined,\\n) {\\n\\tconst convSavePromises = new Map<string, {promise: Promise<void>}>()\\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\\tnextSave?: {\\n\\t\\t\\t\\tuuid: string\\n\\t\\t\\t\\tcallback: () => Promise<void>\\n\\t\\t\\t}\\n\\t\\t} = {}\\n\\t\\tconst conversationMessages = aiClient.conversation?.messages ?? []\\n\\t\\tconst saveConv = (conversationData: ConversationData) => {\\n\\t\\t\\tconst uuid = randomUuid()\\n\\t\\t\\tfor (const newMsg of conversationData.messages) {\\n\\t\\t\\t\\tconst existing = conversationMessages.find(m => m.uuid === newMsg.uuid)\\n\\t\\t\\t\\tif (existing !== undefined) {\\n\\t\\t\\t\\t\\tif (existing.role !== newMsg.role) {\\n\\t\\t\\t\\t\\t\\tthrow new Error('Illegal state')\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\texisting.content = newMsg.content\\n\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\tconversationMessages.push(newMsg)\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t\\tconst callback = async () => {\\n\\t\\t\\t\\tsaveLoop.currentSave = saveLoop.nextSave\\n\\t\\t\\t\\tsaveLoop.nextSave = undefined\\n\\t\\t\\t\\tawait saveConversation(\\n\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\tprompt: conversationData.prompt,\\n\\t\\t\\t\\t\\t\\tconversationUuid: conversationData.conversationUuid,\\n\\t\\t\\t\\t\\t\\tmessages: conversationMessages,\\n\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\taiClient['apiKeyChain']!.promptgrid\\n\\t\\t\\t\\t)\\n\\t\\t\\t\\tawait (saveLoop.nextSave as (typeof saveLoop)['nextSave'])?.callback()\\n\\t\\t\\t\\tsaveLoop.currentSave = undefined\\n\\t\\t\\t}\\n\\t\\t\\tif (saveLoop.nextSave !== undefined) {\\n\\t\\t\\t\\tconvSavePromises.delete(saveLoop.nextSave.uuid)\\n\\t\\t\\t}\\n\\t\\t\\tsaveLoop.nextSave = {uuid, callback}\\n\\t\\t\\tif (saveLoop.currentSave === undefined) {\\n\\t\\t\\t\\tconvSavePromises.set(uuid, {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 (PromptItem & Partial<PromptItem>)[]\\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})\\n\\n\\t\\tlet complete = false\\n\\t\\tlet attemptNr = 1\\n\\t\\tconst attemptsPerCheck = checks.reduce(\\n\\t\\t\\t(map, check) => map.set(check, 1),\\n\\t\\t\\tnew Map<Check<any>, number>()\\n\\t\\t)\\n\\t\\twhile (!complete) {\\n\\t\\t\\tconst responseMessageId = randomUuid()\\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\\tname: tool.name,\\n\\t\\t\\t\\t\\tdescription: tool.description,\\n\\t\\t\\t\\t\\tparameters: typeSpecToJsonSchema(tool.parameters),\\n\\t\\t\\t\\t\\tstrict: true\\n\\t\\t\\t\\t}))\\n\\n\\t\\t\\t\\tconst { flux, httpRequest } = promptOpenai(\\n\\t\\t\\t\\t\\tgenericLLMCallToOpenAiCall(\\n\\t\\t\\t\\t\\t\\t{\\n\\t\\t\\t\\t\\t\\t\\tmodel: effectiveModel(model),\\n\\t\\t\\t\\t\\t\\t\\tprompt: genericPromptWithJsonSpecAndConversationHistory,\\n\\t\\t\\t\\t\\t\\t\\tapiToken,\\n\\t\\t\\t\\t\\t\\t\\ttemperature,\\n\\t\\t\\t\\t\\t\\t\\ttopP,\\n\\t\\t\\t\\t\\t\\t\\trequireJsonResponse: json !== false,\\n\\t\\t\\t\\t\\t\\t\\tjsonSchema: jsonSchemaForAiCall(jsonTypeSupplier, json, model, strict),\\n\\t\\t\\t\\t\\t\\t\\tserviceTier,\\n\\t\\t\\t\\t\\t\\t\\ttools: openaiTools,\\n\\t\\t\\t\\t\\t\\t},\\n\\t\\t\\t\\t\\t),\\n\\t\\t\\t\\t\\tapiToken,\\n\\t\\t\\t\\t)\\n\\n\\t\\t\\t\\tlet streamedText = '';\\n\\t\\t\\t\\tconst responseItems: OutputItem[] = []\\n\\n\\t\\t\\t\\tyield* flux\\n\\t\\t\\t\\t\\t.flatMap<PromptChunk>(event => {\\n\\t\\t\\t\\t\\t\\tswitch (event.type) {\\n\\t\\t\\t\\t\\t\\t\\tcase 'response.output_text.delta': {\\n\\t\\t\\t\\t\\t\\t\\t\\treturn [{\\n\\t\\t\\t\\t\\t\\t\\t\\t\\ttype: 'content' as const,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tcontent: event.delta\\n\\t\\t\\t\\t\\t\\t\\t\\t}]\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\tcase 'response.created':\\n\\t\\t\\t\\t\\t\\t\\tcase 'response.in_progress':\\n\\t\\t\\t\\t\\t\\t\\tcase 'response.completed': {\\n\\t\\t\\t\\t\\t\\t\\t\\tfor (const [i, platformItem] of event.response.output.entries()) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tconst itemI = responseItems.findIndex(it => it.llmPlatformConversationItem.id === platformItem.id)\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tconst item = itemI >= 0 ? responseItems[itemI] : undefined\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tconst newItemValue = (() => {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tconst common = {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tuuid: item?.uuid ?? randomUuid(),\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tllmPlatform: 'openai' as const,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tllmPlatformConversationItem: platformItem,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\thttpRequest: i === 0 ? JSON.stringify(httpRequest) : undefined,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\trole: 'assistant' as const,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tswitch (platformItem.type) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tcase 'message': return {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t...common,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\ttype: 'output_message',\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tcontent: platformItem.content\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t.flatMap(c => c.type === 'output_text' ? [c.text] : [])\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t.join(''),\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t} satisfies OutputMessage\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tcase 'reasoning': return {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t...common,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\ttype: 'reasoning',\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tcontent: platformItem.content?.map(c => c.text).join('')\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t?? platformItem.summary.map(c => c.text).join(''),\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t} satisfies Reasoning\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tcase 'function_call': return {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t...common,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\ttype: 'function_call_input',\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tname: platformItem.name,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\targuments: platformItem.arguments,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tcontent: `${platformItem.name}(${platformItem.arguments})`,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tfunctionCallId: platformItem.call_id,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t} satisfies FunctionCallInput\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t})()\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tsaveConv({\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tconversationUuid,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tprompt: promptProfile,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tmessages: [newItemValue],\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tif (itemI >= 0) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tresponseItems[itemI] = newItemValue\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tresponseItems.push(newItemValue)\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\treturn []\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\tdefault: {\\n\\t\\t\\t\\t\\t\\t\\t\\treturn []\\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.doOnEach(chunk => {\\n\\t\\t\\t\\t\\t\\tswitch (chunk.type) {\\n\\t\\t\\t\\t\\t\\t\\tcase 'content': {\\n\\t\\t\\t\\t\\t\\t\\t\\tstreamedText += chunk.content\\n\\t\\t\\t\\t\\t\\t\\t\\tbreak\\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.flatMap(\\n\\t\\t\\t\\t\\t\\tchunk => chunk.type === 'content'\\n\\t\\t\\t\\t\\t\\t\\t? [chunk.content]\\n\\t\\t\\t\\t\\t\\t\\t: []\\n\\t\\t\\t\\t\\t)\\n\\n\\t\\t\\t\\tconst toolCalls = responseItems\\n\\t\\t\\t\\t\\t.flatMap(\\n\\t\\t\\t\\t\\t\\titem => item.type === 'function_call_input'\\n\\t\\t\\t\\t\\t\\t\\t? (() => {\\n\\t\\t\\t\\t\\t\\t\\t\\tconst functionCall = item.llmPlatformConversationItem as FunctionCall\\n\\t\\t\\t\\t\\t\\t\\t\\treturn {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tid: functionCall.call_id,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tname: functionCall.name,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\targuments: functionCall.arguments,\\n\\t\\t\\t\\t\\t\\t\\t\\t} satisfies ToolCall\\n\\t\\t\\t\\t\\t\\t\\t})()\\n\\t\\t\\t\\t\\t\\t\\t: []\\n\\t\\t\\t\\t\\t)\\n\\t\\t\\t\\tconst llmSupplierOutputMessages = responseItems\\n\\t\\t\\t\\t\\t.map(item => item.llmPlatformConversationItem)\\n\\n\\t\\t\\t\\tif (toolCalls.length > 0) {\\n\\t\\t\\t\\t\\tconst toolResults = await executeToolCalls(toolCalls, tools)\\n\\n\\t\\t\\t\\t\\tconst toolResultMessages = toolResults.map(toolResult => ({\\n\\t\\t\\t\\t\\t\\ttype: 'function_call_output',\\n\\t\\t\\t\\t\\t\\tuuid: randomUuid(),\\n\\t\\t\\t\\t\\t\\trole: 'user' as const,\\n\\t\\t\\t\\t\\t\\tfunctionCallId: toolResult.tool_call_id,\\n\\t\\t\\t\\t\\t\\tcontent: `Tool result for ${toolResult.call.name}: ${toolResult.content}`\\n\\t\\t\\t\\t\\t} satisfies FunctionCallOutput))\\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\\t...responseItems,\\n\\t\\t\\t\\t\\t\\t...toolResultMessages\\n\\t\\t\\t\\t\\t] satisfies PromptItem[]\\n\\n\\t\\t\\t\\t\\tattemptNr = 1\\n\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\tconst textResponse = (() => {\\n\\t\\t\\t\\t\\tconst messages = responseItems.filter(item => item.type === 'output_message')\\n\\t\\t\\t\\t\\tif (messages.length !== 1) {\\n\\t\\t\\t\\t\\t\\tthrow Error('Expected 1 output message, got ' + messages.length)\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\treturn messages[0]!.content\\n\\t\\t\\t\\t})()\\n\\n\\t\\t\\t\\tconst checkedResult = (() => {\\n\\t\\t\\t\\t\\t// If this is a JSON prompt with type validation, validate after completion\\n\\t\\t\\t\\t\\tif (jsonTypeSupplier !== undefined) {\\n\\t\\t\\t\\t\\t\\t// Then validate the complete JSON response\\n\\t\\t\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\t\\t\\tconst uncheckedPackedResult = parseJsonWithUsefulError(textResponse)\\n\\n\\t\\t\\t\\t\\t\\t\\t// Use the same wrapping logic as getResponse()\\n\\t\\t\\t\\t\\t\\t\\tconst expectsWrappedResponse = (() => {\\n\\t\\t\\t\\t\\t\\t\\t\\t// Only expect wrapped response when using OpenAI structured outputs\\n\\t\\t\\t\\t\\t\\t\\t\\t// and the original schema wasn't already an object\\n\\t\\t\\t\\t\\t\\t\\t\\tif (!useTypeSpecMessage(model)) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tconst typeSpec = jsonTypeSupplier(specType(undefined as unknown))\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tconst rawSchema = typeSpecToJsonSchema(typeSpec)\\n\\t\\t\\t\\t\\t\\t\\t\\t\\treturn rawSchema.type !== 'object'\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\treturn true // Non-OpenAI models use type spec message and expect wrapped response\\n\\t\\t\\t\\t\\t\\t\\t})()\\n\\n\\t\\t\\t\\t\\t\\t\\tconst uncheckedResult = expectsWrappedResponse\\n\\t\\t\\t\\t\\t\\t\\t\\t? uncheckedPackedResult?.result\\n\\t\\t\\t\\t\\t\\t\\t\\t: uncheckedPackedResult\\n\\n\\t\\t\\t\\t\\t\\t\\t// Attempt type checking\\n\\t\\t\\t\\t\\t\\t\\treturn assertType(\\n\\t\\t\\t\\t\\t\\t\\t\\tuncheckedResult,\\n\\t\\t\\t\\t\\t\\t\\t\\tjsonTypeSupplier(specType(uncheckedResult)),\\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} catch (typeError) {\\n\\t\\t\\t\\t\\t\\t\\t// Try fallback validation (AI might have forgotten the wrapper)\\n\\t\\t\\t\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\t\\t\\t\\tconst uncheckedResultWhichShouldBePacked = parseJsonWithUsefulError(textResponse)\\n\\t\\t\\t\\t\\t\\t\\t\\treturn assertType(\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tuncheckedResultWhichShouldBePacked,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tjsonTypeSupplier(specType(uncheckedResultWhichShouldBePacked)),\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t{juggleBetweenNullAndUndefined: true},\\n\\t\\t\\t\\t\\t\\t\\t\\t)\\n\\t\\t\\t\\t\\t\\t\\t} catch (fallbackError) {\\n\\t\\t\\t\\t\\t\\t\\t\\t// Type validation failed, treat as a retriable error\\n\\t\\t\\t\\t\\t\\t\\t\\tconst errorMessage = typeError instanceof Error ? typeError.message : String(typeError)\\n\\t\\t\\t\\t\\t\\t\\t\\tthrow new Error(`JSON response failed type validation: ${errorMessage}`)\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\treturn textResponse\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t})()\\n\\n\\t\\t\\t\\tif (checks.length > 0) {\\n\\t\\t\\t\\t\\tconst promises = checks.map(async check => {\\n\\t\\t\\t\\t\\t\\tconst result = await (async () => {\\n\\t\\t\\t\\t\\t\\t\\ttry {\\n\\t\\t\\t\\t\\t\\t\\t\\treturn await check.callback(checkedResult) ?? undefined\\n\\t\\t\\t\\t\\t\\t\\t} catch (e) {\\n\\t\\t\\t\\t\\t\\t\\t\\tif (e instanceof Error) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\treturn e.message\\n\\t\\t\\t\\t\\t\\t\\t\\t} else if (typeof e === 'string') {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\treturn e\\n\\t\\t\\t\\t\\t\\t\\t\\t} else {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tthrow 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\\t\\treturn {result, check}\\n\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\tconst problems = (await Promise.all(promises))\\n\\t\\t\\t\\t\\t\\t.flatMap(({result, check}) => {\\n\\t\\t\\t\\t\\t\\t\\tconst problems = (() => {\\n\\t\\t\\t\\t\\t\\t\\t\\tif (typeof result === 'string') {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\treturn [result]\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\tif (Array.isArray(result)) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\treturn result.flatMap(v => typeof v === 'string' ? [v] : [])\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\treturn []\\n\\t\\t\\t\\t\\t\\t\\t})()\\n\\t\\t\\t\\t\\t\\t\\tif (problems.length > 0) {\\n\\t\\t\\t\\t\\t\\t\\t\\tconst attemptCount = requireDefined(attemptsPerCheck.get(check))\\n\\t\\t\\t\\t\\t\\t\\t\\tif (attemptCount >= check.attempts) {\\n\\t\\t\\t\\t\\t\\t\\t\\t\\tthrow new CheckFailedTooManyTimes(\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tcheck,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tcheck.attempts,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tattemptCount,\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tproblems\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t)\\n\\t\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\t\\tattemptsPerCheck.set(check, attemptCount + 1)\\n\\t\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t\\t\\treturn problems\\n\\t\\t\\t\\t\\t\\t})\\n\\t\\t\\t\\t\\tif (problems.length > 0) {\\n\\t\\t\\t\\t\\t\\tconst feedbackMessage = {\\n\\t\\t\\t\\t\\t\\t\\ttype: 'input_message',\\n\\t\\t\\t\\t\\t\\t\\tuuid: randomUuid(),\\n\\t\\t\\t\\t\\t\\t\\trole: 'user' as const,\\n\\t\\t\\t\\t\\t\\t\\tcontent: `Your result was rejected because:\\\\n${problems.map(p => `- ${p}`).join('\\\\n')}`\\n\\t\\t\\t\\t\\t\\t} satisfies InputMessage\\n\\t\\t\\t\\t\\t\\tsaveConv({\\n\\t\\t\\t\\t\\t\\t\\tconversationUuid,\\n\\t\\t\\t\\t\\t\\t\\tprompt: promptProfile,\\n\\t\\t\\t\\t\\t\\t\\tmessages: [feedbackMessage]\\n\\t\\t\\t\\t\\t\\t})\\n\\n\\t\\t\\t\\t\\t\\tgenericPromptWithJsonSpecAndConversationHistory = [\\n\\t\\t\\t\\t\\t\\t\\t...genericPromptWithJsonSpecAndConversationHistory,\\n\\t\\t\\t\\t\\t\\t\\t...responseItems,\\n\\t\\t\\t\\t\\t\\t\\tfeedbackMessage\\n\\t\\t\\t\\t\\t\\t] satisfies PromptItem[]\\n\\n\\t\\t\\t\\t\\t\\tyield RETRY_SIGNAL\\n\\t\\t\\t\\t\\t\\tattemptNr = 1\\n\\t\\t\\t\\t\\t\\tcontinue\\n\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\tgenericPromptWithJsonSpecAndConversationHistory = [\\n\\t\\t\\t\\t\\t...genericPromptWithJsonSpecAndConversationHistory,\\n\\t\\t\\t\\t\\t...responseItems,\\n\\t\\t\\t\\t] satisfies PromptItem[]\\n\\n\\t\\t\\t\\tcomplete = true\\n\\t\\t\\t} catch (e) {\\n\\t\\t\\t\\tif (e instanceof Error && e.name === CheckFailedTooManyTimes.name) {\\n\\t\\t\\t\\t\\tthrow e\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\tif (attemptNr >= (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 (try ${attemptNr + 1}/${aiClient['config'].attemptsPerCall})`, e)\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t// Emit a special reset event so downstream parsers know to reset their accumulated content\\n\\t\\t\\t\\tyield RETRY_SIGNAL\\n\\t\\t\\t\\tattemptNr++\\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\\nclass CheckFailedTooManyTimes extends Error {\\n\\tconstructor(\\n\\t\\tpublic readonly check: Check<any>,\\n\\t\\tpublic readonly maxAttempts: number,\\n\\t\\tpublic readonly attempts: number,\\n\\t\\tpublic readonly problemsOnLastAttempt: string[],\\n\\t\\tmessage?: string\\n\\t) {\\n\\t\\tsuper(message)\\n\\t}\\n}\\n\\nfunction jsonSchemaForAiCall(\\n\\tjsonTypeSupplier: ((value: EmptyTypeSpec<unknown>) => TypeSpec<any>) | undefined,\\n\\tjson: TypeSpec<any> | boolean,\\n\\tmodel: AiModelId,\\n\\tstrict: boolean\\n) {\\n\\tif (jsonTypeSupplier === undefined) {\\n\\t\\treturn undefined\\n\\t}\\n\\tif (json === false) {\\n\\t\\treturn undefined\\n\\t}\\n\\tif (useTypeSpecMessage(model)) {\\n\\t\\treturn undefined\\n\\t}\\n\\tconst typeSpec = jsonTypeSupplier(specType(undefined as unknown))\\n\\tconst rawSchema = typeSpecToJsonSchema(typeSpec)\\n\\n\\t// OpenAI structured outputs requires root schema to be an object\\n\\t// If we have an array or other non-object type, wrap it in an object\\n\\tconst wrappedSchema = rawSchema.type === 'object'\\n\\t\\t? rawSchema\\n\\t\\t: {\\n\\t\\t\\ttype: 'object',\\n\\t\\t\\tproperties: {\\n\\t\\t\\t\\tresult: rawSchema\\n\\t\\t\\t},\\n\\t\\t\\trequired: ['result'],\\n\\t\\t\\tadditionalProperties: false\\n\\t\\t}\\n\\n\\n\\treturn {\\n\\t\\tname: 'response',\\n\\t\\tschema: wrappedSchema,\\n\\t\\tstrict\\n\\t}\\n}\\n\\nexport type ToolCall = {\\n\\tid: string\\n\\tname: string\\n\\targuments: string\\n}\\n\\nexport type ContentChunk = {\\n\\ttype: 'content'\\n\\tcontent: string\\n}\\n\\nexport type PromptChunk = ContentChunk\\n\\nasync function executeToolCalls(\\n\\ttoolCallsToExecute: ToolCall[],\\n\\ttools: ToolDefinition[] | undefined\\n) {\\n\\tif (tools === undefined) {\\n\\t\\tthrow Error('Illegal state: no tools defined')\\n\\t}\\n\\tconst toolResults = []\\n\\tfor (const toolCall of toolCallsToExecute) {\\n\\t\\tconst tool = tools.find(t => t.name === toolCall.name)\\n\\t\\tconst toolResultContent = await (async () => {\\n\\t\\t\\tif (tool === undefined) {\\n\\t\\t\\t\\treturn `Error: Tool ${toolCall.name} not found`\\n\\t\\t\\t}\\n\\t\\t\\ttry {\\n\\t\\t\\t\\tconst args = toolCall.arguments.trim() === '' ? {} : JSON.parse(toolCall.arguments)\\n\\t\\t\\t\\treturn await tool.function(args)\\n\\t\\t\\t} catch (error) {\\n\\t\\t\\t\\treturn `Error: ${error instanceof Error ? error.message : String(error)}`\\n\\t\\t\\t}\\n\\t\\t})()\\n\\t\\ttoolResults.push({\\n\\t\\t\\tcall: toolCall,\\n\\t\\t\\ttool,\\n\\t\\t\\ttool_call_id: toolCall.id,\\n\\t\\t\\trole: 'tool' as const,\\n\\t\\t\\tcontent: toolResultContent\\n\\t\\t})\\n\\t}\\n\\treturn toolResults\\n}\\n\\nfunction jsonSpec(\\n\\tmodel: AiModelId,\\n\\tjson: true | TypeSpec<any>,\\n\\tfirstThink: boolean,\\n): string | null {\\n\\tif (!useTypeSpecMessage(model)) {\\n\\t\\t// For OpenAI models, we don't need the type spec message\\n\\t\\t// since they handle JSON schema natively via response_format\\n\\t\\tif (mustHaveWordJsonInMessageBodyForJsonResponse(model)) {\\n\\t\\t\\treturn 'Respond with JSON'\\n\\t\\t}\\n\\t\\treturn null\\n\\t}\\n\\t\\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 {\\n\\tApiKeys as AccessTokens,\\n\\tAnyJson,\\n\\tAssistantMessage,\\n\\tDeveloperMessage,\\n\\tHandshakeData,\\n\\tJsonArray,\\n\\tJsonObject,\\n\\tMessage,\\n\\tOpts,\\n\\tPrompt,\\n\\tSystemMessage,\\n\\tUserMessage,\\n\\tTypeSpecMessage,\\n\\tToolDefinition,\\n\\tToolFunction,\\n\\tInputItem,\\n\\tOutputItem,\\n\\tReasoning,\\n}\\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, PromptItem, ServiceTier, Role, InputMessage, OutputMessage, FunctionCallInput, FunctionCallOutput, CheckCallback, PromptItemBase, PromptItemType, FunctionCall, BaseOutputItem, OutputItemType }\\nexport { typeSpecToJsonSchema } from './typeSpecToJsonSchema.js'\\nexport type { PlatformId } from './ai-inference/model.js'\\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\\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: PromptItem[]\\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\\nfunction promptItemToMessage(m: PromptItem) {\\n\\tswitch (m.type) {\\n\\t\\tcase 'input_message':\\n\\t\\tcase 'output_message':\\n\\t\\t\\treturn {[m.role]: m.content} as unknown as Message\\n\\t\\tcase 'reasoning':\\n\\t\\tcase 'function_call_input':\\n\\t\\t\\treturn {assistant: m.content}\\n\\t\\tcase 'function_call_output':\\n\\t\\t\\treturn {user: m.content}\\n\\t}\\n}\\n\\nfunction effectiveModel(modelArg: AiModelId | undefined): AiModelId {\\n\\treturn modelArg ?? 'gpt-4o'\\n}\\n\\nconst RETRY_SIGNAL = `retry-signal-${randomUuid()}`\",\"import {AiModelId} from './AiModelId.js'\\nimport {FunctionCall} from './openai/model/OutputItem.js'\\n\\n\\nexport type PlatformId =\\n | 'openai'\\n// | 'huggingface-inference-api'\\n// | 'llama-cpp'\\n// | 'replicate'\\n// | 'anthropic'\\n\\nexport type PlatformSpecificPromptRequest<Stream extends boolean = false> = Omit<PromptRequest<Stream>, 'platform'>\\n\\nexport type Role = 'user' | 'system' | 'developer' | 'assistant'\\n\\nexport type PromptItemType =\\n | 'input_message'\\n | 'output_message'\\n | 'reasoning'\\n | 'function_call_input'\\n | 'function_call_output'\\n\\nexport type PromptItemBase<T extends PromptItemType> = {\\n type: T\\n uuid: string\\n}\\n\\nexport type InputMessage = PromptItemBase<'input_message'> & {\\n role: Role\\n content: string\\n name?: undefined\\n arguments?: undefined\\n httpRequest?: undefined\\n llmPlatform?: undefined\\n llmPlatformConversationItem?: undefined\\n}\\n\\nexport type OutputMessage = PromptItemBase<'output_message'> & {\\n role: Role\\n content: string\\n httpRequest?: string\\n llmPlatform: PlatformId\\n llmPlatformConversationItem: any\\n}\\n\\nexport type Reasoning = PromptItemBase<'reasoning'> & {\\n role: Role\\n content: string\\n name?: undefined\\n arguments?: undefined\\n httpRequest?: string\\n llmPlatform?: PlatformId\\n llmPlatformConversationItem: any\\n}\\n\\nexport type FunctionCallInput = PromptItemBase<'function_call_input'> & {\\n name: string\\n /** @deprecated **/\\n role: 'assistant'\\n functionCallId: string\\n content: string\\n arguments: string\\n httpRequest?: string\\n llmPlatform?: PlatformId\\n llmPlatformConversationItem: any\\n}\\n\\nexport type FunctionCallOutput = PromptItemBase<'function_call_output'> & {\\n /** @deprecated **/\\n role: 'user'\\n content: string\\n functionCallId: string\\n httpRequest?: undefined\\n llmPlatform?: undefined\\n llmPlatformConversationItem?: undefined\\n}\\n\\nexport type OutputItem = OutputMessage | Reasoning | FunctionCallInput\\n\\nexport type InputItem = InputMessage | FunctionCallOutput\\n\\nexport type PromptItem = InputItem | OutputItem\\n\\nexport type ServiceTier = 'normal' | 'flex'\\n\\nexport type GenericPrompt = PromptItem[]\\n\\n/**\\n * Determines whether to include a type spec message based on the model.\\n * Currently returns false for OpenAI models (they handle JSON schema natively),\\n * true for others that might need explicit instructions.\\n */\\nexport function useTypeSpecMessage(model: AiModelId): boolean {\\n // OpenAI models handle JSON schema natively via response_format\\n // so we don't need the type spec message\\n if (model.startsWith('gpt-') || model.startsWith('o1-') || model === 'o1' || model === 'o3-mini' || model === 'o3') {\\n return false\\n }\\n \\n // For other models, we might need the type spec message\\n // (keeping this ready for future model support)\\n return true\\n}\\n\\n/**\\n * Determines whether to include a type spec message based on the model.\\n * Currently returns false for OpenAI models (they handle JSON schema natively),\\n * true for others that might need explicit instructions.\\n */\\nexport function mustHaveWordJsonInMessageBodyForJsonResponse(model: AiModelId): boolean {\\n // OpenAI models handle JSON schema natively via response_format\\n // so we don't need the type spec message\\n if (model.startsWith('gpt-') || model.startsWith('o1-') || model === 'o1' || model === 'o3-mini' || model === 'o3') {\\n return true\\n }\\n\\n // For other models, we might need the type spec message\\n // (keeping this ready for future model support)\\n return false\\n}\\n\\nexport type PromptRequest<Stream extends boolean = false> = {\\n prompt: GenericPrompt\\n requireJsonResponse?: boolean\\n model: AiModelId\\n llamaCppHomeDir?: string\\n /**\\n * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both.\\n */\\n temperature?: number\\n topP?: number\\n stream?: Stream\\n llmArgs?: LargeLanguageModelArgs\\n platform: PlatformId\\n apiToken: string\\n serviceTier: ServiceTier\\n}\\n\\ntype LargeLanguageModelArgs = {\\n top_k?: any\\n top_p?: any\\n temp?: any\\n batch_size?: any\\n repeat_last_n?: any\\n repeat_penalty?: any\\n interactive?: any\\n seed?: number\\n threads?: number\\n n_predict?: number\\n ctx_size?: number\\n url?: string\\n}\\n\",\"import {AiModelId} from '../AiModelId.ts'\\nimport {Flux} from 'monoflux'\\nimport {ResponseStreamEvent} from './model/ResponseStreamEvent.js'\\nimport {InputItem} from './model/InputItem.js'\\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 openAiRequest: ResponsesApiRequestBody,\\n apiToken: string,\\n): { flux: Flux<ResponseStreamEvent>; httpRequest: any } {\\n const httpRequest = {\\n url: 'https://api.openai.com/v1/responses',\\n method: 'POST',\\n headers: {\\n 'Content-Type': 'application/json',\\n 'Accept': 'application/json',\\n 'Authorization': `Bearer ${apiToken.slice(0, 7)}...${apiToken.slice(-4)}` // Redact most of the token\\n },\\n body: openAiRequest,\\n }\\n \\n const flux = Flux.fromGeneratorFunction(async function* () {\\n const abortController = new AbortController()\\n const response = await fetch(\\n 'https://api.openai.com/v1/responses',\\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(openAiRequest)\\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 buffer = ''\\n \\n yield* Flux\\n .fromReadableStream(response.body, () => abortController.abort())\\n .map(value => textDecoder.decode(value, {stream: true}))\\n .flatMap(value => {\\n buffer += value\\n const events: string[] = []\\n \\n // Split on double newlines to separate SSE events\\n const parts = buffer.split('\\\\n\\\\n')\\n \\n // Keep the last part in buffer if it might be incomplete\\n buffer = parts.pop() || ''\\n \\n // Process complete events\\n for (const part of parts) {\\n if (part.trim()) {\\n events.push(part.trim())\\n }\\n }\\n \\n return events\\n })\\n .flatMap(eventText => {\\n // Parse SSE event\\n const lines = eventText.split('\\\\n')\\n let data = ''\\n \\n for (const line of lines) {\\n if (line.startsWith('data: ')) {\\n data += line.substring(6)\\n }\\n }\\n \\n if (!data) return []\\n \\n try {\\n const json = JSON.parse(data) as ResponseStreamEvent\\n return [json]\\n } catch (e) {\\n return []\\n }\\n })\\n })\\n \\n return {flux, httpRequest}\\n}\\n\\nconst textDecoder = new TextDecoder()\\n\\nexport type ResponsesApiRequestBody = {\\n model: AiModelId\\n input: string | InputItem[]\\n stream: boolean\\n temperature?: number\\n top_p?: number\\n text?: {\\n format: {\\n type: 'json_object' | 'text' | 'json_schema'\\n name: string\\n schema?: any\\n strict?: boolean\\n }\\n }\\n service_tier?: 'default' | 'flex'\\n tools?: {\\n type: 'function'\\n name: string\\n description?: string\\n strict: boolean\\n parameters?: any\\n }[]\\n}\\n\\nexport type OpenAIRequestyBody = ResponsesApiRequestBody\\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.has(\\n propertyName,\\n type => type.canBeString()\\n )\\n }\\n\\n hasNumber<Key extends string>(propertyName: Key): TypeSpec<Combine<T, Record<Key, number>>> {\\n return this.has(\\n propertyName,\\n type => type.canBeNumber()\\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.has(propertyName, assertTypeOfProperty, true)\\n }\\n\\n has<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 has<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 has<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} of content: ${this.content}`)\\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 /**\\n * Has non-optional property\\n */\\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'\",\"import {TypeSpec} from './type-spec/type-spec.js'\\n\\nexport function typeSpecToJsonSchema(typeSpec: TypeSpec<any>): any {\\n const convertType = (type: any): any => {\\n if (Array.isArray(type)) {\\n // Handle union types\\n if (type.length === 1) {\\n return convertType(type[0])\\n }\\n\\n // Check if all types are constants (enum case)\\n if (type.every(t => t.type === 'constant')) {\\n return {\\n type: 'string',\\n enum: type.map(t => t.value)\\n }\\n }\\n\\n // For other union types, use oneOf\\n return {\\n anyOf: type.map(t => convertType(t))\\n }\\n }\\n\\n switch (type.type) {\\n case 'object': {\\n const properties: any = {}\\n const required: string[] = []\\n\\n for (const [key, propSpec] of Object.entries(type.props)) {\\n const convertedType = convertType((propSpec as any).type)\\n \\n // Add description if comment exists\\n if ((propSpec as any).comment) {\\n properties[key] = {\\n ...convertedType,\\n description: (propSpec as any).comment\\n }\\n } else {\\n properties[key] = convertedType\\n }\\n \\n if (!(propSpec as any).optional) {\\n required.push(key)\\n }\\n }\\n\\n return {\\n type: 'object',\\n properties,\\n required: required.length > 0 ? required : undefined,\\n additionalProperties: false\\n }\\n }\\n case 'array': {\\n return {\\n type: 'array',\\n items: convertType(type.elementType)\\n }\\n }\\n case 'string': {\\n return {type: 'string'}\\n }\\n case 'number': {\\n return {type: 'number'}\\n }\\n case 'boolean': {\\n return {type: 'boolean'}\\n }\\n case 'null': {\\n return {type: 'null'}\\n }\\n case 'undefined': {\\n return {type: 'null'}\\n }\\n case 'constant': {\\n // If the constant is an array, it likely represents enum values\\n if (Array.isArray(type.value)) {\\n return {\\n type: 'string',\\n enum: type.value\\n }\\n }\\n return {\\n type: 'string',\\n const: type.value\\n }\\n }\\n default: {\\n return {type: 'string'} // fallback\\n }\\n }\\n }\\n\\n return convertType(typeSpec['type'])\\n}\",\"import {InputMessage, PlatformSpecificPromptRequest} from '../model.js'\\nimport {OpenAIRequestyBody} from './promptOpenai.js'\\nimport {InputItem} from './model/InputItem.js'\\nimport {OutputItem} from './model/OutputItem.js'\\n\\nexport function genericLLMCallToOpenAiCall(\\n {\\n model,\\n prompt,\\n temperature,\\n topP,\\n requireJsonResponse,\\n jsonSchema,\\n serviceTier,\\n tools\\n }: PlatformSpecificPromptRequest<boolean> & {\\n jsonSchema?: { name: string; schema: any; strict?: boolean }\\n tools?: {\\n type: 'function'\\n name: string\\n description?: string\\n parameters: any\\n strict: boolean\\n }[]\\n }\\n): OpenAIRequestyBody {\\n return {\\n model,\\n input: prompt.map(item => {\\n if (item.llmPlatformConversationItem && item.llmPlatform === 'openai') {\\n return item.llmPlatformConversationItem\\n }\\n if (item.type === 'function_call_output') {\\n return {\\n type: 'function_call_output',\\n call_id: item.functionCallId,\\n output: item.content\\n } satisfies InputItem\\n }\\n if (item.role === 'assistant') {\\n return {\\n type: 'message',\\n role: item.role,\\n content: [\\n {\\n type: 'output_text',\\n text: item.content\\n }\\n ]\\n }\\n }\\n return {\\n role: item.role,\\n content: [\\n {\\n type: 'input_text',\\n text: item.content\\n }\\n ]\\n }\\n }),\\n stream: true,\\n temperature,\\n top_p: topP,\\n text: jsonSchema ? {\\n format: {\\n type: 'json_schema' as const,\\n name: jsonSchema.name,\\n schema: jsonSchema.schema,\\n strict: jsonSchema.strict\\n }\\n } : requireJsonResponse ? {\\n format: {\\n type: 'json_object' as const,\\n name: 'response'\\n }\\n } : undefined,\\n service_tier: serviceTier === 'flex' ? 'flex' : 'default',\\n tools\\n }\\n}\",\"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-audio)\\n */\\n gpt_audio: 'gpt-audio',\\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-audio-2025-08-28)\\n */\\n gpt_audio_2025_08_28: 'gpt-audio-2025-08-28',\\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 | ? | ? |\\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-realtime)\\n */\\n gpt_realtime: 'gpt-realtime',\\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-realtime-2025-08-28)\\n */\\n gpt_realtime_2025_08_28: 'gpt-realtime-2025-08-28',\\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,MAA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