@promptbook/google 0.112.0-72 → 0.112.0-79

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.
Files changed (214) hide show
  1. package/README.md +9 -9
  2. package/esm/index.es.js +310 -204
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +1 -1
  5. package/esm/src/avatars/visuals/octopus3d2AvatarVisual.d.ts +7 -0
  6. package/esm/src/avatars/visuals/octopus3dAvatarVisualShared.d.ts +37 -0
  7. package/esm/src/book-components/Chat/save/_common/chatExportRendering.d.ts +75 -0
  8. package/esm/src/book-components/Chat/save/_common/getPromptbookExportBranding.d.ts +18 -0
  9. package/esm/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +13 -1
  10. package/esm/src/book-components/Chat/save/html/htmlSaveFormatDefinition.test.d.ts +1 -0
  11. package/esm/src/book-components/Chat/save/index.d.ts +5 -5
  12. package/esm/src/book-components/Chat/save/markdown/mdSaveFormatDefinition.d.ts +5 -3
  13. package/esm/src/book-components/Chat/save/markdown/mdSaveFormatDefinition.test.d.ts +1 -0
  14. package/esm/src/book-components/Chat/save/pdf/buildChatPdf.d.ts +4 -3
  15. package/esm/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +3 -3
  16. package/esm/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.test.d.ts +1 -0
  17. package/esm/src/book-components/Chat/save/react/reactSaveFormatDefinition.test.d.ts +1 -0
  18. package/esm/src/book-components/Chat/utils/renderMarkdown.d.ts +26 -0
  19. package/esm/src/cli/cli-commands/agent/agentProjectPaths.d.ts +8 -8
  20. package/esm/src/cli/cli-commands/agent/agentRunCliOptions.d.ts +2 -0
  21. package/esm/src/cli/cli-commands/agent/initializeAgentRunnerCommand.d.ts +1 -0
  22. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +56 -0
  23. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer.test.d.ts +1 -0
  24. package/esm/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.d.ts +7 -0
  25. package/esm/src/cli/cli-commands/agents-server/ensureAgentsServerGitignoreFile.d.ts +7 -0
  26. package/esm/src/cli/cli-commands/agents-server/init.d.ts +9 -0
  27. package/esm/src/cli/cli-commands/agents-server/init.test.d.ts +1 -0
  28. package/esm/src/cli/cli-commands/agents-server/initializeAgentsServerProjectConfiguration.d.ts +17 -0
  29. package/esm/src/cli/cli-commands/agents-server/printAgentsServerInitializationSummary.d.ts +7 -0
  30. package/esm/src/cli/cli-commands/agents-server/run.d.ts +14 -0
  31. package/esm/src/cli/cli-commands/agents-server/run.test.d.ts +1 -0
  32. package/esm/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +23 -0
  33. package/esm/src/cli/cli-commands/agents-server.d.ts +8 -0
  34. package/esm/src/cli/cli-commands/common/handleActionErrors.d.ts +9 -4
  35. package/esm/src/cli/cli-commands/common/projectInitialization.d.ts +65 -0
  36. package/esm/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +44 -0
  37. package/esm/src/cli/common/$deprecateCliCommand.d.ts +8 -0
  38. package/esm/src/cli/common/$deprecateCliCommand.test.d.ts +1 -0
  39. package/esm/src/conversion/pipelineJsonToString/appendMarkdownBlock.d.ts +7 -0
  40. package/esm/src/conversion/pipelineJsonToString/createPipelineCommands.d.ts +7 -0
  41. package/esm/src/conversion/pipelineJsonToString/createPipelineIntroduction.d.ts +8 -0
  42. package/esm/src/conversion/pipelineJsonToString/createTaskSerialization.d.ts +23 -0
  43. package/esm/src/conversion/pipelineJsonToString/stringifyCommands.d.ts +7 -0
  44. package/esm/src/conversion/pipelineJsonToString/stringifyTask.d.ts +8 -0
  45. package/esm/src/conversion/pipelineJsonToString.test.d.ts +1 -0
  46. package/esm/src/execution/createPipelineExecutor/executeSingleAttempt.d.ts +31 -0
  47. package/esm/src/execution/createPipelineExecutor/handleAttemptFailure.d.ts +40 -0
  48. package/esm/src/execution/createPipelineExecutor/reportPromptExecution.d.ts +34 -0
  49. package/esm/src/execution/resolveTaskTldr.d.ts +32 -0
  50. package/esm/src/execution/resolveTaskTldr.test.d.ts +1 -0
  51. package/esm/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +22 -63
  52. package/esm/src/llm-providers/agent/AgentLlmExecutionToolsAgentKitRunner.d.ts +51 -0
  53. package/esm/src/llm-providers/agent/AgentLlmExecutionToolsOpenAiAssistantRunner.d.ts +43 -0
  54. package/esm/src/llm-providers/agent/AgentLlmExecutionToolsPromptPreparer.d.ts +41 -0
  55. package/esm/src/llm-providers/agent/emitAgentLlmExecutionToolsAssistantPreparationProgress.d.ts +26 -0
  56. package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +16 -93
  57. package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionToolsInputBuilder.d.ts +41 -0
  58. package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionToolsOutputTypeMapper.d.ts +56 -0
  59. package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionToolsToolBuilder.d.ts +99 -0
  60. package/esm/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +24 -120
  61. package/esm/src/llm-providers/openai/OpenAiAssistantExecutionToolsProgressReporter.d.ts +62 -0
  62. package/esm/src/llm-providers/openai/OpenAiAssistantExecutionToolsPromptBuilder.d.ts +29 -0
  63. package/esm/src/llm-providers/openai/OpenAiAssistantExecutionToolsStreamRunner.d.ts +63 -0
  64. package/esm/src/llm-providers/openai/OpenAiAssistantExecutionToolsToolRunner.d.ts +89 -0
  65. package/esm/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +9 -28
  66. package/esm/src/llm-providers/openai/OpenAiCompatibleModelCatalog.d.ts +31 -0
  67. package/esm/src/llm-providers/openai/OpenAiCompatibleNonChatPromptCaller.d.ts +57 -0
  68. package/esm/src/llm-providers/openai/OpenAiCompatibleRequestManager.d.ts +29 -0
  69. package/esm/src/llm-providers/openai/OpenAiVectorStoreFileBatchHandler.d.ts +51 -0
  70. package/esm/src/llm-providers/openai/OpenAiVectorStoreFileBatchPoller.d.ts +75 -0
  71. package/esm/src/llm-providers/openai/OpenAiVectorStoreHandler.d.ts +1 -98
  72. package/esm/src/llm-providers/openai/OpenAiVectorStoreKnowledgeSourcePreparer.d.ts +44 -0
  73. package/esm/src/llm-providers/openai/utils/OpenAiCompatibleChatProgressReporter.d.ts +86 -0
  74. package/esm/src/llm-providers/openai/utils/OpenAiCompatibleChatPromptBuilder.d.ts +57 -0
  75. package/esm/src/llm-providers/openai/utils/OpenAiCompatibleChatToolCaller.d.ts +57 -0
  76. package/esm/src/remote-server/startRemoteServer/RemoteServerRuntime.d.ts +14 -0
  77. package/esm/src/remote-server/startRemoteServer/SocketResponse.d.ts +9 -0
  78. package/esm/src/remote-server/startRemoteServer/StartRemoteServerConfiguration.d.ts +18 -0
  79. package/esm/src/remote-server/startRemoteServer/createRemoteServerExpressApp.d.ts +7 -0
  80. package/esm/src/remote-server/startRemoteServer/createRemoteServerHandle.d.ts +11 -0
  81. package/esm/src/remote-server/startRemoteServer/createSocketServer.d.ts +9 -0
  82. package/esm/src/remote-server/startRemoteServer/getExecutionToolsFromIdentification.d.ts +12 -0
  83. package/esm/src/remote-server/startRemoteServer/registerBookRoutes.d.ts +7 -0
  84. package/esm/src/remote-server/startRemoteServer/registerExecutionRoutes.d.ts +7 -0
  85. package/esm/src/remote-server/startRemoteServer/registerListModelsSocketHandler.d.ts +8 -0
  86. package/esm/src/remote-server/startRemoteServer/registerLoginRoute.d.ts +7 -0
  87. package/esm/src/remote-server/startRemoteServer/registerNotFoundRoute.d.ts +7 -0
  88. package/esm/src/remote-server/startRemoteServer/registerOpenAiCompatibleChatCompletionsRoute.d.ts +7 -0
  89. package/esm/src/remote-server/startRemoteServer/registerOpenApiRoutes.d.ts +7 -0
  90. package/esm/src/remote-server/startRemoteServer/registerPreparePipelineSocketHandler.d.ts +8 -0
  91. package/esm/src/remote-server/startRemoteServer/registerPromptSocketHandler.d.ts +8 -0
  92. package/esm/src/remote-server/startRemoteServer/registerRemoteServerHttpRoutes.d.ts +7 -0
  93. package/esm/src/remote-server/startRemoteServer/registerRemoteServerSocketHandlers.d.ts +8 -0
  94. package/esm/src/remote-server/startRemoteServer/registerServerIndexRoute.d.ts +7 -0
  95. package/esm/src/remote-server/startRemoteServer/resolveStartRemoteServerConfiguration.d.ts +8 -0
  96. package/esm/src/remote-server/startRemoteServer/respondToSocketRequest.d.ts +8 -0
  97. package/esm/src/remote-server/startRemoteServer/startListening.d.ts +9 -0
  98. package/esm/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +14 -1
  99. package/esm/src/utils/color/Color.d.ts +4 -44
  100. package/esm/src/utils/color/ColorValue.d.ts +55 -0
  101. package/esm/src/utils/color/isHexColorString.d.ts +10 -0
  102. package/esm/src/utils/color/parseColorString.d.ts +11 -0
  103. package/esm/src/utils/serialization/serializeToPromptbookJavascript.d.ts +2 -0
  104. package/esm/src/utils/serialization/serializeToPromptbookJavascript.test.d.ts +1 -0
  105. package/esm/src/version.d.ts +1 -1
  106. package/package.json +2 -2
  107. package/umd/index.umd.js +310 -204
  108. package/umd/index.umd.js.map +1 -1
  109. package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +1 -1
  110. package/umd/src/avatars/visuals/octopus3d2AvatarVisual.d.ts +7 -0
  111. package/umd/src/avatars/visuals/octopus3dAvatarVisualShared.d.ts +37 -0
  112. package/umd/src/book-components/Chat/save/_common/chatExportRendering.d.ts +75 -0
  113. package/umd/src/book-components/Chat/save/_common/getPromptbookExportBranding.d.ts +18 -0
  114. package/umd/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +13 -1
  115. package/umd/src/book-components/Chat/save/html/htmlSaveFormatDefinition.test.d.ts +1 -0
  116. package/umd/src/book-components/Chat/save/index.d.ts +5 -5
  117. package/umd/src/book-components/Chat/save/markdown/mdSaveFormatDefinition.d.ts +5 -3
  118. package/umd/src/book-components/Chat/save/markdown/mdSaveFormatDefinition.test.d.ts +1 -0
  119. package/umd/src/book-components/Chat/save/pdf/buildChatPdf.d.ts +4 -3
  120. package/umd/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +3 -3
  121. package/umd/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.test.d.ts +1 -0
  122. package/umd/src/book-components/Chat/save/react/reactSaveFormatDefinition.test.d.ts +1 -0
  123. package/umd/src/book-components/Chat/utils/renderMarkdown.d.ts +26 -0
  124. package/umd/src/cli/cli-commands/agent/agentProjectPaths.d.ts +8 -8
  125. package/umd/src/cli/cli-commands/agent/agentRunCliOptions.d.ts +2 -0
  126. package/umd/src/cli/cli-commands/agent/initializeAgentRunnerCommand.d.ts +1 -0
  127. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +56 -0
  128. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer.test.d.ts +1 -0
  129. package/umd/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.d.ts +7 -0
  130. package/umd/src/cli/cli-commands/agents-server/ensureAgentsServerGitignoreFile.d.ts +7 -0
  131. package/umd/src/cli/cli-commands/agents-server/init.d.ts +9 -0
  132. package/umd/src/cli/cli-commands/agents-server/init.test.d.ts +1 -0
  133. package/umd/src/cli/cli-commands/agents-server/initializeAgentsServerProjectConfiguration.d.ts +17 -0
  134. package/umd/src/cli/cli-commands/agents-server/printAgentsServerInitializationSummary.d.ts +7 -0
  135. package/umd/src/cli/cli-commands/agents-server/run.d.ts +14 -0
  136. package/umd/src/cli/cli-commands/agents-server/run.test.d.ts +1 -0
  137. package/umd/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +23 -0
  138. package/umd/src/cli/cli-commands/agents-server.d.ts +8 -0
  139. package/umd/src/cli/cli-commands/common/handleActionErrors.d.ts +9 -4
  140. package/umd/src/cli/cli-commands/common/projectInitialization.d.ts +65 -0
  141. package/umd/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +44 -0
  142. package/umd/src/cli/common/$deprecateCliCommand.d.ts +8 -0
  143. package/umd/src/cli/common/$deprecateCliCommand.test.d.ts +1 -0
  144. package/umd/src/conversion/pipelineJsonToString/appendMarkdownBlock.d.ts +7 -0
  145. package/umd/src/conversion/pipelineJsonToString/createPipelineCommands.d.ts +7 -0
  146. package/umd/src/conversion/pipelineJsonToString/createPipelineIntroduction.d.ts +8 -0
  147. package/umd/src/conversion/pipelineJsonToString/createTaskSerialization.d.ts +23 -0
  148. package/umd/src/conversion/pipelineJsonToString/stringifyCommands.d.ts +7 -0
  149. package/umd/src/conversion/pipelineJsonToString/stringifyTask.d.ts +8 -0
  150. package/umd/src/conversion/pipelineJsonToString.test.d.ts +1 -0
  151. package/umd/src/execution/createPipelineExecutor/executeSingleAttempt.d.ts +31 -0
  152. package/umd/src/execution/createPipelineExecutor/handleAttemptFailure.d.ts +40 -0
  153. package/umd/src/execution/createPipelineExecutor/reportPromptExecution.d.ts +34 -0
  154. package/umd/src/execution/resolveTaskTldr.d.ts +32 -0
  155. package/umd/src/execution/resolveTaskTldr.test.d.ts +1 -0
  156. package/umd/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +22 -63
  157. package/umd/src/llm-providers/agent/AgentLlmExecutionToolsAgentKitRunner.d.ts +51 -0
  158. package/umd/src/llm-providers/agent/AgentLlmExecutionToolsOpenAiAssistantRunner.d.ts +43 -0
  159. package/umd/src/llm-providers/agent/AgentLlmExecutionToolsPromptPreparer.d.ts +41 -0
  160. package/umd/src/llm-providers/agent/emitAgentLlmExecutionToolsAssistantPreparationProgress.d.ts +26 -0
  161. package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +16 -93
  162. package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionToolsInputBuilder.d.ts +41 -0
  163. package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionToolsOutputTypeMapper.d.ts +56 -0
  164. package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionToolsToolBuilder.d.ts +99 -0
  165. package/umd/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +24 -120
  166. package/umd/src/llm-providers/openai/OpenAiAssistantExecutionToolsProgressReporter.d.ts +62 -0
  167. package/umd/src/llm-providers/openai/OpenAiAssistantExecutionToolsPromptBuilder.d.ts +29 -0
  168. package/umd/src/llm-providers/openai/OpenAiAssistantExecutionToolsStreamRunner.d.ts +63 -0
  169. package/umd/src/llm-providers/openai/OpenAiAssistantExecutionToolsToolRunner.d.ts +89 -0
  170. package/umd/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +9 -28
  171. package/umd/src/llm-providers/openai/OpenAiCompatibleModelCatalog.d.ts +31 -0
  172. package/umd/src/llm-providers/openai/OpenAiCompatibleNonChatPromptCaller.d.ts +57 -0
  173. package/umd/src/llm-providers/openai/OpenAiCompatibleRequestManager.d.ts +29 -0
  174. package/umd/src/llm-providers/openai/OpenAiVectorStoreFileBatchHandler.d.ts +51 -0
  175. package/umd/src/llm-providers/openai/OpenAiVectorStoreFileBatchPoller.d.ts +75 -0
  176. package/umd/src/llm-providers/openai/OpenAiVectorStoreHandler.d.ts +1 -98
  177. package/umd/src/llm-providers/openai/OpenAiVectorStoreKnowledgeSourcePreparer.d.ts +44 -0
  178. package/umd/src/llm-providers/openai/utils/OpenAiCompatibleChatProgressReporter.d.ts +86 -0
  179. package/umd/src/llm-providers/openai/utils/OpenAiCompatibleChatPromptBuilder.d.ts +57 -0
  180. package/umd/src/llm-providers/openai/utils/OpenAiCompatibleChatToolCaller.d.ts +57 -0
  181. package/umd/src/remote-server/startRemoteServer/RemoteServerRuntime.d.ts +14 -0
  182. package/umd/src/remote-server/startRemoteServer/SocketResponse.d.ts +9 -0
  183. package/umd/src/remote-server/startRemoteServer/StartRemoteServerConfiguration.d.ts +18 -0
  184. package/umd/src/remote-server/startRemoteServer/createRemoteServerExpressApp.d.ts +7 -0
  185. package/umd/src/remote-server/startRemoteServer/createRemoteServerHandle.d.ts +11 -0
  186. package/umd/src/remote-server/startRemoteServer/createSocketServer.d.ts +9 -0
  187. package/umd/src/remote-server/startRemoteServer/getExecutionToolsFromIdentification.d.ts +12 -0
  188. package/umd/src/remote-server/startRemoteServer/registerBookRoutes.d.ts +7 -0
  189. package/umd/src/remote-server/startRemoteServer/registerExecutionRoutes.d.ts +7 -0
  190. package/umd/src/remote-server/startRemoteServer/registerListModelsSocketHandler.d.ts +8 -0
  191. package/umd/src/remote-server/startRemoteServer/registerLoginRoute.d.ts +7 -0
  192. package/umd/src/remote-server/startRemoteServer/registerNotFoundRoute.d.ts +7 -0
  193. package/umd/src/remote-server/startRemoteServer/registerOpenAiCompatibleChatCompletionsRoute.d.ts +7 -0
  194. package/umd/src/remote-server/startRemoteServer/registerOpenApiRoutes.d.ts +7 -0
  195. package/umd/src/remote-server/startRemoteServer/registerPreparePipelineSocketHandler.d.ts +8 -0
  196. package/umd/src/remote-server/startRemoteServer/registerPromptSocketHandler.d.ts +8 -0
  197. package/umd/src/remote-server/startRemoteServer/registerRemoteServerHttpRoutes.d.ts +7 -0
  198. package/umd/src/remote-server/startRemoteServer/registerRemoteServerSocketHandlers.d.ts +8 -0
  199. package/umd/src/remote-server/startRemoteServer/registerServerIndexRoute.d.ts +7 -0
  200. package/umd/src/remote-server/startRemoteServer/resolveStartRemoteServerConfiguration.d.ts +8 -0
  201. package/umd/src/remote-server/startRemoteServer/respondToSocketRequest.d.ts +8 -0
  202. package/umd/src/remote-server/startRemoteServer/startListening.d.ts +9 -0
  203. package/umd/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +14 -1
  204. package/umd/src/utils/color/Color.d.ts +4 -44
  205. package/umd/src/utils/color/ColorValue.d.ts +55 -0
  206. package/umd/src/utils/color/isHexColorString.d.ts +10 -0
  207. package/umd/src/utils/color/parseColorString.d.ts +11 -0
  208. package/umd/src/utils/serialization/serializeToPromptbookJavascript.d.ts +2 -0
  209. package/umd/src/utils/serialization/serializeToPromptbookJavascript.test.d.ts +1 -0
  210. package/umd/src/version.d.ts +1 -1
  211. package/esm/src/cli/cli-commands/coder/appendBlock.d.ts +0 -6
  212. package/esm/src/cli/cli-commands/coder/readTextFileIfExists.d.ts +0 -6
  213. package/umd/src/cli/cli-commands/coder/appendBlock.d.ts +0 -6
  214. package/umd/src/cli/cli-commands/coder/readTextFileIfExists.d.ts +0 -6
package/README.md CHANGED
@@ -648,28 +648,28 @@ npx ts-node ./src/cli/test/ptbk.ts coder verify
648
648
 
649
649
  #### Using `ptbk coder` in an external project
650
650
 
651
- If you want to use the workflow in another repository, install the package and invoke the `ptbk` binary. After local installation, `npx ptbk ...` is the most portable form; plain `ptbk ...` also works when your environment exposes the local binary on `PATH`.
651
+ If you want to use the workflow in another repository, install the package and invoke the `ptbk` binary directly.
652
652
 
653
653
  ```bash
654
654
  npm install ptbk
655
655
 
656
656
  ptbk coder init
657
657
 
658
- npx ptbk coder generate-boilerplates
658
+ ptbk coder generate-boilerplates
659
659
 
660
- npx ptbk coder generate-boilerplates --template prompts/templates/common.md
660
+ ptbk coder generate-boilerplates --template prompts/templates/common.md
661
661
 
662
- npx ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --test npm run test
662
+ ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --test npm run test
663
663
 
664
- npx ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --auto-push
664
+ ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --auto-push
665
665
 
666
- npx ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --test npm run test --ignore-git-changes --no-wait
666
+ ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --test npm run test --ignore-git-changes --no-wait
667
667
 
668
- npx ptbk coder find-refactor-candidates
668
+ ptbk coder find-refactor-candidates
669
669
 
670
- npx ptbk coder find-refactor-candidates --level xhigh
670
+ ptbk coder find-refactor-candidates --level xhigh
671
671
 
672
- npx ptbk coder verify
672
+ ptbk coder verify
673
673
  ```
674
674
 
675
675
  `ptbk coder init` also bootstraps a starter `AGENTS.md`, adds `package.json` scripts for the four main coder commands, adds the shared `/.promptbook` temp ignore to `.gitignore`, and configures `.vscode/settings.json` so pasted images from `prompts/*.md` land in `prompts/screenshots/`.
package/esm/index.es.js CHANGED
@@ -16,7 +16,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
16
16
  * @generated
17
17
  * @see https://github.com/webgptorg/promptbook
18
18
  */
19
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-72';
19
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-79';
20
20
  /**
21
21
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
22
22
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -836,6 +836,111 @@ function checkChannelValue(channelName, value) {
836
836
  }
837
837
  }
838
838
 
839
+ /**
840
+ * Shared immutable channel storage and serialization helpers for `Color`.
841
+ *
842
+ * @private base class of Color
843
+ */
844
+ class ColorValue {
845
+ constructor(red, green, blue, alpha = 255) {
846
+ this.red = red;
847
+ this.green = green;
848
+ this.blue = blue;
849
+ this.alpha = alpha;
850
+ checkChannelValue('Red', red);
851
+ checkChannelValue('Green', green);
852
+ checkChannelValue('Blue', blue);
853
+ checkChannelValue('Alpha', alpha);
854
+ }
855
+ /**
856
+ * Shortcut for `red` property
857
+ * Number from 0 to 255
858
+ * @alias red
859
+ */
860
+ get r() {
861
+ return this.red;
862
+ }
863
+ /**
864
+ * Shortcut for `green` property
865
+ * Number from 0 to 255
866
+ * @alias green
867
+ */
868
+ get g() {
869
+ return this.green;
870
+ }
871
+ /**
872
+ * Shortcut for `blue` property
873
+ * Number from 0 to 255
874
+ * @alias blue
875
+ */
876
+ get b() {
877
+ return this.blue;
878
+ }
879
+ /**
880
+ * Shortcut for `alpha` property
881
+ * Number from 0 (transparent) to 255 (opaque)
882
+ * @alias alpha
883
+ */
884
+ get a() {
885
+ return this.alpha;
886
+ }
887
+ /**
888
+ * Shortcut for `alpha` property
889
+ * Number from 0 (transparent) to 255 (opaque)
890
+ * @alias alpha
891
+ */
892
+ get opacity() {
893
+ return this.alpha;
894
+ }
895
+ /**
896
+ * Shortcut for 1-`alpha` property
897
+ */
898
+ get transparency() {
899
+ return 255 - this.alpha;
900
+ }
901
+ clone() {
902
+ return take(this.createColor(this.red, this.green, this.blue, this.alpha));
903
+ }
904
+ toString() {
905
+ return this.toHex();
906
+ }
907
+ toHex() {
908
+ if (this.alpha === 255) {
909
+ return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
910
+ .toString(16)
911
+ .padStart(2, '0')}`;
912
+ }
913
+ else {
914
+ return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
915
+ .toString(16)
916
+ .padStart(2, '0')}${this.alpha.toString(16).padStart(2, '0')}`;
917
+ }
918
+ }
919
+ toRgb() {
920
+ if (this.alpha === 255) {
921
+ return `rgb(${this.red}, ${this.green}, ${this.blue})`;
922
+ }
923
+ else {
924
+ return `rgba(${this.red}, ${this.green}, ${this.blue}, ${Math.round((this.alpha / 255) * 100)}%)`;
925
+ }
926
+ }
927
+ toHsl() {
928
+ throw new Error(`Getting HSL is not implemented`);
929
+ }
930
+ }
931
+
932
+ /**
933
+ * Checks if the given value is a valid hex color string
934
+ *
935
+ * @param value - value to check
936
+ * @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
937
+ *
938
+ * @private function of Color
939
+ */
940
+ function isHexColorString(value) {
941
+ return (typeof value === 'string' && /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
942
+ }
943
+
839
944
  /**
840
945
  * Constant for short hex lengths.
841
946
  */
@@ -1047,16 +1152,53 @@ function parseAlphaValue(value) {
1047
1152
 
1048
1153
  /**
1049
1154
  * Pattern matching hsl regex.
1155
+ *
1156
+ * @private function of Color
1050
1157
  */
1051
1158
  const HSL_REGEX_PATTERN = /^hsl\(\s*([0-9.]+)\s*,\s*([0-9.]+)%\s*,\s*([0-9.]+)%\s*\)$/;
1052
1159
  /**
1053
1160
  * Pattern matching RGB regex.
1161
+ *
1162
+ * @private function of Color
1054
1163
  */
1055
1164
  const RGB_REGEX_PATTERN = /^rgb\(\s*([0-9.%-]+)\s*,\s*([0-9.%-]+)\s*,\s*([0-9.%-]+)\s*\)$/;
1056
1165
  /**
1057
1166
  * Pattern matching rgba regex.
1167
+ *
1168
+ * @private function of Color
1058
1169
  */
1059
1170
  const RGBA_REGEX_PATTERN = /^rgba\(\s*([0-9.%-]+)\s*,\s*([0-9.%-]+)\s*,\s*([0-9.%-]+)\s*,\s*([0-9.%-]+)\s*\)$/;
1171
+ /**
1172
+ * Parses a supported color string into RGBA channels.
1173
+ *
1174
+ * @param color as a string for example `#009edd`, `rgb(0,158,221)`, `rgb(0%,62%,86.7%)`, `hsl(197.1,100%,43.3%)`, `red`, `darkgrey`,...
1175
+ * @returns RGBA channel values.
1176
+ *
1177
+ * @private function of Color
1178
+ */
1179
+ function parseColorString(color) {
1180
+ const trimmed = color.trim();
1181
+ const cssColor = CSS_COLORS[trimmed];
1182
+ if (cssColor) {
1183
+ return parseColorString(cssColor);
1184
+ }
1185
+ else if (isHexColorString(trimmed)) {
1186
+ return parseHexColor(trimmed);
1187
+ }
1188
+ if (HSL_REGEX_PATTERN.test(trimmed)) {
1189
+ return parseHslColor(trimmed);
1190
+ }
1191
+ else if (RGB_REGEX_PATTERN.test(trimmed)) {
1192
+ return parseRgbColor(trimmed);
1193
+ }
1194
+ else if (RGBA_REGEX_PATTERN.test(trimmed)) {
1195
+ return parseRgbaColor(trimmed);
1196
+ }
1197
+ else {
1198
+ throw new Error(`Can not create a new Color instance from string "${trimmed}".`);
1199
+ }
1200
+ }
1201
+
1060
1202
  /**
1061
1203
  * Color object represents an RGB color with alpha channel
1062
1204
  *
@@ -1064,7 +1206,7 @@ const RGBA_REGEX_PATTERN = /^rgba\(\s*([0-9.%-]+)\s*,\s*([0-9.%-]+)\s*,\s*([0-9.
1064
1206
  *
1065
1207
  * @public exported from `@promptbook/color`
1066
1208
  */
1067
- class Color {
1209
+ class Color extends ColorValue {
1068
1210
  /**
1069
1211
  * Creates a new Color instance from miscellaneous formats
1070
1212
  * - It can receive Color instance and just return the same instance
@@ -1137,25 +1279,7 @@ class Color {
1137
1279
  * @returns Color object
1138
1280
  */
1139
1281
  static fromString(color) {
1140
- const trimmed = color.trim();
1141
- if (CSS_COLORS[trimmed]) {
1142
- return Color.fromString(CSS_COLORS[trimmed]);
1143
- }
1144
- else if (Color.isHexColorString(trimmed)) {
1145
- return Color.fromHex(trimmed);
1146
- }
1147
- if (HSL_REGEX_PATTERN.test(trimmed)) {
1148
- return Color.fromHsl(trimmed);
1149
- }
1150
- else if (RGB_REGEX_PATTERN.test(trimmed)) {
1151
- return Color.fromRgbString(trimmed);
1152
- }
1153
- else if (RGBA_REGEX_PATTERN.test(trimmed)) {
1154
- return Color.fromRgbaString(trimmed);
1155
- }
1156
- else {
1157
- throw new Error(`Can not create a new Color instance from string "${trimmed}".`);
1158
- }
1282
+ return Color.fromColorChannels(parseColorString(color));
1159
1283
  }
1160
1284
  /**
1161
1285
  * Gets common color
@@ -1185,8 +1309,7 @@ class Color {
1185
1309
  * @returns Color object
1186
1310
  */
1187
1311
  static fromHex(hex) {
1188
- const { red, green, blue, alpha } = parseHexColor(hex);
1189
- return take(new Color(red, green, blue, alpha));
1312
+ return Color.fromColorChannels(parseHexColor(hex));
1190
1313
  }
1191
1314
  /**
1192
1315
  * Creates a new Color instance from color in hsl format
@@ -1195,8 +1318,7 @@ class Color {
1195
1318
  * @returns Color object
1196
1319
  */
1197
1320
  static fromHsl(hsl) {
1198
- const { red, green, blue, alpha } = parseHslColor(hsl);
1199
- return take(new Color(red, green, blue, alpha));
1321
+ return Color.fromColorChannels(parseHslColor(hsl));
1200
1322
  }
1201
1323
  /**
1202
1324
  * Creates a new Color instance from color in rgb format
@@ -1205,8 +1327,7 @@ class Color {
1205
1327
  * @returns Color object
1206
1328
  */
1207
1329
  static fromRgbString(rgb) {
1208
- const { red, green, blue, alpha } = parseRgbColor(rgb);
1209
- return take(new Color(red, green, blue, alpha));
1330
+ return Color.fromColorChannels(parseRgbColor(rgb));
1210
1331
  }
1211
1332
  /**
1212
1333
  * Creates a new Color instance from color in rbga format
@@ -1215,8 +1336,7 @@ class Color {
1215
1336
  * @returns Color object
1216
1337
  */
1217
1338
  static fromRgbaString(rgba) {
1218
- const { red, green, blue, alpha } = parseRgbaColor(rgba);
1219
- return take(new Color(red, green, blue, alpha));
1339
+ return Color.fromColorChannels(parseRgbaColor(rgba));
1220
1340
  }
1221
1341
  /**
1222
1342
  * Creates a new Color for color channels values
@@ -1228,7 +1348,7 @@ class Color {
1228
1348
  * @returns Color object
1229
1349
  */
1230
1350
  static fromValues(red, green, blue, alpha = 255) {
1231
- return take(new Color(red, green, blue, alpha));
1351
+ return Color.fromColorChannels({ red, green, blue, alpha });
1232
1352
  }
1233
1353
  /**
1234
1354
  * Checks if the given value is a valid Color object.
@@ -1261,8 +1381,7 @@ class Color {
1261
1381
  * @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
1262
1382
  */
1263
1383
  static isHexColorString(value) {
1264
- return (typeof value === 'string' &&
1265
- /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
1384
+ return isHexColorString(value);
1266
1385
  }
1267
1386
  /**
1268
1387
  * Creates new Color object
@@ -1275,89 +1394,13 @@ class Color {
1275
1394
  * @param alpha number from 0 (transparent) to 255 (opaque)
1276
1395
  */
1277
1396
  constructor(red, green, blue, alpha = 255) {
1278
- this.red = red;
1279
- this.green = green;
1280
- this.blue = blue;
1281
- this.alpha = alpha;
1282
- checkChannelValue('Red', red);
1283
- checkChannelValue('Green', green);
1284
- checkChannelValue('Blue', blue);
1285
- checkChannelValue('Alpha', alpha);
1397
+ super(red, green, blue, alpha);
1286
1398
  }
1287
- /**
1288
- * Shortcut for `red` property
1289
- * Number from 0 to 255
1290
- * @alias red
1291
- */
1292
- get r() {
1293
- return this.red;
1399
+ createColor(red, green, blue, alpha) {
1400
+ return new Color(red, green, blue, alpha);
1294
1401
  }
1295
- /**
1296
- * Shortcut for `green` property
1297
- * Number from 0 to 255
1298
- * @alias green
1299
- */
1300
- get g() {
1301
- return this.green;
1302
- }
1303
- /**
1304
- * Shortcut for `blue` property
1305
- * Number from 0 to 255
1306
- * @alias blue
1307
- */
1308
- get b() {
1309
- return this.blue;
1310
- }
1311
- /**
1312
- * Shortcut for `alpha` property
1313
- * Number from 0 (transparent) to 255 (opaque)
1314
- * @alias alpha
1315
- */
1316
- get a() {
1317
- return this.alpha;
1318
- }
1319
- /**
1320
- * Shortcut for `alpha` property
1321
- * Number from 0 (transparent) to 255 (opaque)
1322
- * @alias alpha
1323
- */
1324
- get opacity() {
1325
- return this.alpha;
1326
- }
1327
- /**
1328
- * Shortcut for 1-`alpha` property
1329
- */
1330
- get transparency() {
1331
- return 255 - this.alpha;
1332
- }
1333
- clone() {
1334
- return take(new Color(this.red, this.green, this.blue, this.alpha));
1335
- }
1336
- toString() {
1337
- return this.toHex();
1338
- }
1339
- toHex() {
1340
- if (this.alpha === 255) {
1341
- return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
1342
- .toString(16)
1343
- .padStart(2, '0')}`;
1344
- }
1345
- else {
1346
- return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
1347
- .toString(16)
1348
- .padStart(2, '0')}${this.alpha.toString(16).padStart(2, '0')}`;
1349
- }
1350
- }
1351
- toRgb() {
1352
- if (this.alpha === 255) {
1353
- return `rgb(${this.red}, ${this.green}, ${this.blue})`;
1354
- }
1355
- else {
1356
- return `rgba(${this.red}, ${this.green}, ${this.blue}, ${Math.round((this.alpha / 255) * 100)}%)`;
1357
- }
1358
- }
1359
- toHsl() {
1360
- throw new Error(`Getting HSL is not implemented`);
1402
+ static fromColorChannels({ red, green, blue, alpha }) {
1403
+ return take(new Color(red, green, blue, alpha));
1361
1404
  }
1362
1405
  }
1363
1406
 
@@ -1831,120 +1874,183 @@ function assertsError(whatWasThrown) {
1831
1874
  * @public exported from `@promptbook/utils`
1832
1875
  */
1833
1876
  function checkSerializableAsJson(options) {
1834
- const { value, name, message } = options;
1877
+ checkSerializableValue(options);
1878
+ }
1879
+ // TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
1880
+ // TODO: [🧠][main] !!3 In-memory cache of same values to prevent multiple checks
1881
+ // Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
1882
+ /**
1883
+ * Checks one value and dispatches to the appropriate specialized validator.
1884
+ *
1885
+ * @private function of `checkSerializableAsJson`
1886
+ */
1887
+ function checkSerializableValue(options) {
1888
+ const { value } = options;
1889
+ if (isSerializablePrimitive(value)) {
1890
+ return;
1891
+ }
1835
1892
  if (value === undefined) {
1836
- throw new UnexpectedError(`${name} is undefined`);
1893
+ throw new UnexpectedError(`${options.name} is undefined`);
1837
1894
  }
1838
- else if (value === null) {
1839
- return;
1895
+ if (typeof value === 'symbol') {
1896
+ throw new UnexpectedError(`${options.name} is symbol`);
1840
1897
  }
1841
- else if (typeof value === 'boolean') {
1842
- return;
1898
+ if (typeof value === 'function') {
1899
+ throw new UnexpectedError(`${options.name} is function`);
1843
1900
  }
1844
- else if (typeof value === 'number' && !isNaN(value)) {
1901
+ if (Array.isArray(value)) {
1902
+ checkSerializableArray(options, value);
1845
1903
  return;
1846
1904
  }
1847
- else if (typeof value === 'string') {
1905
+ if (value !== null && typeof value === 'object') {
1906
+ checkSerializableObject(options, value);
1848
1907
  return;
1849
1908
  }
1850
- else if (typeof value === 'symbol') {
1851
- throw new UnexpectedError(`${name} is symbol`);
1852
- }
1853
- else if (typeof value === 'function') {
1854
- throw new UnexpectedError(`${name} is function`);
1855
- }
1856
- else if (typeof value === 'object' && Array.isArray(value)) {
1857
- for (let i = 0; i < value.length; i++) {
1858
- checkSerializableAsJson({ name: `${name}[${i}]`, value: value[i], message });
1859
- }
1909
+ throwUnknownTypeError(options);
1910
+ }
1911
+ /**
1912
+ * Checks the primitive values that are directly JSON serializable.
1913
+ *
1914
+ * @private function of `checkSerializableAsJson`
1915
+ */
1916
+ function isSerializablePrimitive(value) {
1917
+ return (value === null ||
1918
+ typeof value === 'boolean' ||
1919
+ (typeof value === 'number' && !isNaN(value)) ||
1920
+ typeof value === 'string');
1921
+ }
1922
+ /**
1923
+ * Recursively checks JSON array items.
1924
+ *
1925
+ * @private function of `checkSerializableAsJson`
1926
+ */
1927
+ function checkSerializableArray(context, arrayValue) {
1928
+ for (let index = 0; index < arrayValue.length; index++) {
1929
+ checkSerializableAsJson({
1930
+ ...context,
1931
+ name: `${context.name}[${index}]`,
1932
+ value: arrayValue[index],
1933
+ });
1860
1934
  }
1861
- else if (typeof value === 'object') {
1862
- if (value instanceof Date) {
1863
- throw new UnexpectedError(spaceTrim$1((block) => `
1864
- \`${name}\` is Date
1935
+ }
1936
+ /**
1937
+ * Checks object-like values and dispatches special unsupported built-ins.
1938
+ *
1939
+ * @private function of `checkSerializableAsJson`
1940
+ */
1941
+ function checkSerializableObject(context, objectValue) {
1942
+ checkUnsupportedObjectType(context, objectValue);
1943
+ checkSerializableObjectEntries(context, objectValue);
1944
+ assertJsonStringificationSucceeds(context, objectValue);
1945
+ }
1946
+ /**
1947
+ * Rejects built-in objects that must be converted before JSON serialization.
1948
+ *
1949
+ * @private function of `checkSerializableAsJson`
1950
+ */
1951
+ function checkUnsupportedObjectType(context, objectValue) {
1952
+ if (objectValue instanceof Date) {
1953
+ throw new UnexpectedError(spaceTrim$1((block) => `
1954
+ \`${context.name}\` is Date
1865
1955
 
1866
- Use \`string_date_iso8601\` instead
1956
+ Use \`string_date_iso8601\` instead
1867
1957
 
1868
- Additional message for \`${name}\`:
1869
- ${block(message || '(nothing)')}
1870
- `));
1871
- }
1872
- else if (value instanceof Map) {
1873
- throw new UnexpectedError(`${name} is Map`);
1874
- }
1875
- else if (value instanceof Set) {
1876
- throw new UnexpectedError(`${name} is Set`);
1877
- }
1878
- else if (value instanceof RegExp) {
1879
- throw new UnexpectedError(`${name} is RegExp`);
1880
- }
1881
- else if (value instanceof Error) {
1882
- throw new UnexpectedError(spaceTrim$1((block) => `
1883
- \`${name}\` is unserialized Error
1958
+ Additional message for \`${context.name}\`:
1959
+ ${block(context.message || '(nothing)')}
1960
+ `));
1961
+ }
1962
+ if (objectValue instanceof Map) {
1963
+ throw new UnexpectedError(`${context.name} is Map`);
1964
+ }
1965
+ if (objectValue instanceof Set) {
1966
+ throw new UnexpectedError(`${context.name} is Set`);
1967
+ }
1968
+ if (objectValue instanceof RegExp) {
1969
+ throw new UnexpectedError(`${context.name} is RegExp`);
1970
+ }
1971
+ if (objectValue instanceof Error) {
1972
+ throw new UnexpectedError(spaceTrim$1((block) => `
1973
+ \`${context.name}\` is unserialized Error
1884
1974
 
1885
- Use function \`serializeError\`
1975
+ Use function \`serializeError\`
1886
1976
 
1887
- Additional message for \`${name}\`:
1888
- ${block(message || '(nothing)')}
1977
+ Additional message for \`${context.name}\`:
1978
+ ${block(context.message || '(nothing)')}
1889
1979
 
1890
- `));
1980
+ `));
1981
+ }
1982
+ }
1983
+ /**
1984
+ * Recursively checks object properties while preserving omitted `undefined` keys.
1985
+ *
1986
+ * @private function of `checkSerializableAsJson`
1987
+ */
1988
+ function checkSerializableObjectEntries(context, objectValue) {
1989
+ for (const [subName, subValue] of Object.entries(objectValue)) {
1990
+ if (subValue === undefined) {
1991
+ // Note: undefined in object is serializable - it is just omitted
1992
+ continue;
1891
1993
  }
1892
- else {
1893
- for (const [subName, subValue] of Object.entries(value)) {
1894
- if (subValue === undefined) {
1895
- // Note: undefined in object is serializable - it is just omitted
1896
- continue;
1897
- }
1898
- checkSerializableAsJson({ name: `${name}.${subName}`, value: subValue, message });
1899
- }
1900
- try {
1901
- JSON.stringify(value); // <- TODO: [0]
1902
- }
1903
- catch (error) {
1904
- assertsError(error);
1905
- throw new UnexpectedError(spaceTrim$1((block) => `
1906
- \`${name}\` is not serializable
1994
+ checkSerializableAsJson({
1995
+ ...context,
1996
+ name: `${context.name}.${subName}`,
1997
+ value: subValue,
1998
+ });
1999
+ }
2000
+ }
2001
+ /**
2002
+ * Uses `JSON.stringify` as the final guard for cases like circular references.
2003
+ *
2004
+ * @private function of `checkSerializableAsJson`
2005
+ */
2006
+ function assertJsonStringificationSucceeds(context, objectValue) {
2007
+ try {
2008
+ JSON.stringify(objectValue); // <- TODO: [0]
2009
+ }
2010
+ catch (error) {
2011
+ assertsError(error);
2012
+ throw new UnexpectedError(spaceTrim$1((block) => `
2013
+ \`${context.name}\` is not serializable
1907
2014
 
1908
- ${block(error.stack || error.message)}
2015
+ ${block(error.stack || error.message)}
1909
2016
 
1910
- Additional message for \`${name}\`:
1911
- ${block(message || '(nothing)')}
1912
- `));
2017
+ Additional message for \`${context.name}\`:
2018
+ ${block(context.message || '(nothing)')}
2019
+ `));
2020
+ }
2021
+ /*
2022
+ TODO: [0] Is there some more elegant way to check circular references?
2023
+ const seen = new Set();
2024
+ const stack = [{ value }];
2025
+ while (stack.length > 0) {
2026
+ const { value } = stack.pop()!;
2027
+ if (typeof value === 'object' && value !== null) {
2028
+ if (seen.has(value)) {
2029
+ throw new UnexpectedError(`${name} has circular reference`);
1913
2030
  }
1914
- /*
1915
- TODO: [0] Is there some more elegant way to check circular references?
1916
- const seen = new Set();
1917
- const stack = [{ value }];
1918
- while (stack.length > 0) {
1919
- const { value } = stack.pop()!;
1920
- if (typeof value === 'object' && value !== null) {
1921
- if (seen.has(value)) {
1922
- throw new UnexpectedError(`${name} has circular reference`);
1923
- }
1924
- seen.add(value);
1925
- if (Array.isArray(value)) {
1926
- stack.push(...value.map((value) => ({ value })));
1927
- } else {
1928
- stack.push(...Object.values(value).map((value) => ({ value })));
1929
- }
1930
- }
2031
+ seen.add(value);
2032
+ if (Array.isArray(value)) {
2033
+ stack.push(...value.map((value) => ({ value })));
2034
+ } else {
2035
+ stack.push(...Object.values(value).map((value) => ({ value })));
1931
2036
  }
1932
- */
1933
- return;
1934
2037
  }
1935
2038
  }
1936
- else {
1937
- throw new UnexpectedError(spaceTrim$1((block) => `
1938
- \`${name}\` is unknown type
2039
+ */
2040
+ }
2041
+ /**
2042
+ * Throws the fallback error for unsupported value types like `bigint` and `NaN`.
2043
+ *
2044
+ * @private function of `checkSerializableAsJson`
2045
+ */
2046
+ function throwUnknownTypeError(context) {
2047
+ throw new UnexpectedError(spaceTrim$1((block) => `
2048
+ \`${context.name}\` is unknown type
1939
2049
 
1940
- Additional message for \`${name}\`:
1941
- ${block(message || '(nothing)')}
1942
- `));
1943
- }
2050
+ Additional message for \`${context.name}\`:
2051
+ ${block(context.message || '(nothing)')}
2052
+ `));
1944
2053
  }
1945
- // TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
1946
- // TODO: [🧠][main] !!3 In-memory cache of same values to prevent multiple checks
1947
- // Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
1948
2054
 
1949
2055
  /**
1950
2056
  * Creates a deep clone of the given object