@promptbook/node 0.112.0-64 → 0.112.0-66
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/esm/index.es.js +786 -258
- package/esm/index.es.js.map +1 -1
- package/esm/src/_packages/components.index.d.ts +0 -2
- package/esm/src/_packages/core.index.d.ts +2 -2
- package/esm/src/_packages/types.index.d.ts +0 -2
- package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +1 -1
- package/esm/src/avatars/visuals/minecraft2AvatarVisual.d.ts +7 -0
- package/esm/src/avatars/visuals/minecraftAvatarVisualShared.d.ts +48 -0
- package/esm/src/book-2.0/book-language-documentation/BookLanguageDocumentationExample.d.ts +27 -0
- package/esm/src/book-2.0/book-language-documentation/bookLanguageCommonPitfalls.d.ts +25 -0
- package/esm/src/book-2.0/book-language-documentation/bookLanguageDocumentationExamples.d.ts +10 -0
- package/esm/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.d.ts +14 -0
- package/esm/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.d.ts +43 -0
- package/esm/src/book-components/Chat/types/ChatMessage.d.ts +0 -34
- package/esm/src/cli/cli-commands/coder/ensureCoderGitignoreFile.d.ts +1 -1
- package/esm/src/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +0 -11
- package/esm/src/commitments/_common/toolRuntimeContext.d.ts +0 -6
- package/esm/src/config.d.ts +3 -3
- package/esm/src/formfactors/index.d.ts +2 -2
- package/esm/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +1 -1
- package/esm/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +0 -4
- package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionToolsOptions.d.ts +0 -9
- package/esm/src/utils/files/getPromptbookTempPath.d.ts +24 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +785 -257
- package/umd/index.umd.js.map +1 -1
- package/umd/src/_packages/components.index.d.ts +0 -2
- package/umd/src/_packages/core.index.d.ts +2 -2
- package/umd/src/_packages/types.index.d.ts +0 -2
- package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +1 -1
- package/umd/src/avatars/visuals/minecraft2AvatarVisual.d.ts +7 -0
- package/umd/src/avatars/visuals/minecraftAvatarVisualShared.d.ts +48 -0
- package/umd/src/book-2.0/book-language-documentation/BookLanguageDocumentationExample.d.ts +27 -0
- package/umd/src/book-2.0/book-language-documentation/bookLanguageCommonPitfalls.d.ts +25 -0
- package/umd/src/book-2.0/book-language-documentation/bookLanguageDocumentationExamples.d.ts +10 -0
- package/umd/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.d.ts +14 -0
- package/umd/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.d.ts +43 -0
- package/umd/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.test.d.ts +1 -0
- package/umd/src/book-components/Chat/types/ChatMessage.d.ts +0 -34
- package/umd/src/cli/cli-commands/coder/ensureCoderGitignoreFile.d.ts +1 -1
- package/umd/src/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +0 -11
- package/umd/src/commitments/_common/toolRuntimeContext.d.ts +0 -6
- package/umd/src/config.d.ts +3 -3
- package/umd/src/formfactors/index.d.ts +2 -2
- package/umd/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +1 -1
- package/umd/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +0 -4
- package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionToolsOptions.d.ts +0 -9
- package/umd/src/utils/files/getPromptbookTempPath.d.ts +24 -0
- package/umd/src/utils/files/getPromptbookTempPath.test.d.ts +1 -0
- package/umd/src/version.d.ts +1 -1
- /package/esm/src/{commitments/KNOWLEDGE/KNOWLEDGE.test.d.ts → book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.test.d.ts} +0 -0
- /package/{umd/src/commitments/KNOWLEDGE/KNOWLEDGE.test.d.ts → esm/src/utils/files/getPromptbookTempPath.test.d.ts} +0 -0
package/esm/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import colors from 'colors';
|
|
2
2
|
import { stat, access, constants, readFile, writeFile, readdir, mkdir, watch, rm, unlink } from 'fs/promises';
|
|
3
|
-
import { basename, join, dirname, isAbsolute, relative } from 'path';
|
|
3
|
+
import { posix, basename, join, dirname, isAbsolute, relative } from 'path';
|
|
4
4
|
import _spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
5
5
|
import JSZip from 'jszip';
|
|
6
6
|
import { randomBytes } from 'crypto';
|
|
@@ -35,7 +35,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
35
35
|
* @generated
|
|
36
36
|
* @see https://github.com/webgptorg/promptbook
|
|
37
37
|
*/
|
|
38
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
38
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-66';
|
|
39
39
|
/**
|
|
40
40
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
41
41
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -954,6 +954,29 @@ function saturate(amount) {
|
|
|
954
954
|
}
|
|
955
955
|
// TODO: Maybe implement by mix+hsl
|
|
956
956
|
|
|
957
|
+
/**
|
|
958
|
+
* Relative directory name without the `./` prefix for Git ignore rules and glob patterns.
|
|
959
|
+
*
|
|
960
|
+
* @private internal utility for Promptbook-owned temp files
|
|
961
|
+
*/
|
|
962
|
+
const PROMPTBOOK_TEMP_DIRECTORY_NAME = '.promptbook';
|
|
963
|
+
/**
|
|
964
|
+
* Builds one project-relative path inside the shared Promptbook working directory.
|
|
965
|
+
*
|
|
966
|
+
* @private internal utility for Promptbook-owned temp files
|
|
967
|
+
*/
|
|
968
|
+
function getPromptbookTempPath(...pathSegments) {
|
|
969
|
+
return `./${getPromptbookTempPosixPath(...pathSegments)}`;
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* Builds one POSIX path fragment inside the shared Promptbook working directory for globs and generated text files.
|
|
973
|
+
*
|
|
974
|
+
* @private internal utility for Promptbook-owned temp files
|
|
975
|
+
*/
|
|
976
|
+
function getPromptbookTempPosixPath(...pathSegments) {
|
|
977
|
+
return posix.join(PROMPTBOOK_TEMP_DIRECTORY_NAME, ...pathSegments);
|
|
978
|
+
}
|
|
979
|
+
|
|
957
980
|
/**
|
|
958
981
|
* Returns the same value that is passed as argument.
|
|
959
982
|
* No side effects.
|
|
@@ -1148,7 +1171,6 @@ const DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹♂️]
|
|
|
1148
1171
|
*/
|
|
1149
1172
|
const DEFAULT_MAX_EXECUTION_ATTEMPTS = 7; // <- TODO: [🤹♂️]
|
|
1150
1173
|
// <- TODO: [🕝] Make also `AGENTS_DIRNAME_ALTERNATIVES`
|
|
1151
|
-
// TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
|
|
1152
1174
|
/**
|
|
1153
1175
|
* Where to store the temporary downloads
|
|
1154
1176
|
*
|
|
@@ -1156,7 +1178,15 @@ const DEFAULT_MAX_EXECUTION_ATTEMPTS = 7; // <- TODO: [🤹♂️]
|
|
|
1156
1178
|
*
|
|
1157
1179
|
* @public exported from `@promptbook/core`
|
|
1158
1180
|
*/
|
|
1159
|
-
const DEFAULT_DOWNLOAD_CACHE_DIRNAME = '
|
|
1181
|
+
const DEFAULT_DOWNLOAD_CACHE_DIRNAME = getPromptbookTempPath('download-cache');
|
|
1182
|
+
/**
|
|
1183
|
+
* Where to store the cache of executions for promptbook CLI
|
|
1184
|
+
*
|
|
1185
|
+
* Note: When the folder does not exist, it is created recursively
|
|
1186
|
+
*
|
|
1187
|
+
* @public exported from `@promptbook/core`
|
|
1188
|
+
*/
|
|
1189
|
+
getPromptbookTempPath('execution-cache');
|
|
1160
1190
|
/**
|
|
1161
1191
|
* Where to store the scrape cache
|
|
1162
1192
|
*
|
|
@@ -1164,7 +1194,7 @@ const DEFAULT_DOWNLOAD_CACHE_DIRNAME = './.promptbook/download-cache';
|
|
|
1164
1194
|
*
|
|
1165
1195
|
* @public exported from `@promptbook/core`
|
|
1166
1196
|
*/
|
|
1167
|
-
const DEFAULT_SCRAPE_CACHE_DIRNAME = '
|
|
1197
|
+
const DEFAULT_SCRAPE_CACHE_DIRNAME = getPromptbookTempPath('scrape-cache');
|
|
1168
1198
|
/*
|
|
1169
1199
|
TODO: [🌃]
|
|
1170
1200
|
/**
|
|
@@ -8843,8 +8873,10 @@ const ImageGeneratorFormfactorDefinition = {
|
|
|
8843
8873
|
*/
|
|
8844
8874
|
const MatcherFormfactorDefinition = {
|
|
8845
8875
|
name: 'EXPERIMENTAL_MATCHER',
|
|
8846
|
-
description: `
|
|
8847
|
-
|
|
8876
|
+
description: spaceTrim$1(`
|
|
8877
|
+
An evaluation system that determines whether content meets specific criteria or patterns.
|
|
8878
|
+
Used for content validation, quality assessment, and intelligent filtering tasks. Currently in experimental phase.
|
|
8879
|
+
`),
|
|
8848
8880
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/177`,
|
|
8849
8881
|
pipelineInterface: {
|
|
8850
8882
|
inputParameters: [
|
|
@@ -8901,9 +8933,11 @@ const SheetsFormfactorDefinition = {
|
|
|
8901
8933
|
*/
|
|
8902
8934
|
const TranslatorFormfactorDefinition = {
|
|
8903
8935
|
name: 'TRANSLATOR',
|
|
8904
|
-
description: `
|
|
8905
|
-
|
|
8906
|
-
|
|
8936
|
+
description: spaceTrim$1(`
|
|
8937
|
+
A text transformation system that converts input content into different forms,
|
|
8938
|
+
including language translations, paraphrasing, style conversions, and tone adjustments.
|
|
8939
|
+
This form factor takes one input and produces one transformed output.
|
|
8940
|
+
`),
|
|
8907
8941
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/175`,
|
|
8908
8942
|
pipelineInterface: {
|
|
8909
8943
|
inputParameters: [
|
|
@@ -10278,12 +10312,21 @@ const QuickChatbotHla = {
|
|
|
10278
10312
|
// <- TODO: [🧠] Make this dynamic, async, prepare-phase HLAs
|
|
10279
10313
|
],
|
|
10280
10314
|
});
|
|
10281
|
-
// TODO: Use spaceTrim in multiline strings
|
|
10282
10315
|
$pipelineJson.tasks.push({
|
|
10283
10316
|
taskType: 'PROMPT_TASK',
|
|
10284
10317
|
name: 'create-an-answer',
|
|
10285
10318
|
title: 'Create an answer',
|
|
10286
|
-
content:
|
|
10319
|
+
content: spaceTrim$1(`
|
|
10320
|
+
Write a response to the user message:
|
|
10321
|
+
|
|
10322
|
+
**Question from user**
|
|
10323
|
+
|
|
10324
|
+
> {userMessage}
|
|
10325
|
+
|
|
10326
|
+
**Previous conversation**
|
|
10327
|
+
|
|
10328
|
+
> {previousConversationSummary}
|
|
10329
|
+
`),
|
|
10287
10330
|
resultingParameterName: 'chatbotResponse',
|
|
10288
10331
|
personaName,
|
|
10289
10332
|
dependentParameterNames: [
|
|
@@ -10295,7 +10338,26 @@ const QuickChatbotHla = {
|
|
|
10295
10338
|
taskType: 'PROMPT_TASK',
|
|
10296
10339
|
name: 'summarize-the-conversation',
|
|
10297
10340
|
title: 'Summarize the conversation',
|
|
10298
|
-
content:
|
|
10341
|
+
content: spaceTrim$1(`
|
|
10342
|
+
Summarize the conversation in a few words:
|
|
10343
|
+
|
|
10344
|
+
## Rules
|
|
10345
|
+
|
|
10346
|
+
- Summarise the text of the conversation in a few words
|
|
10347
|
+
- Convert the text to its basic idea
|
|
10348
|
+
- Imagine you are writing the headline or subject line of an email
|
|
10349
|
+
- Respond with a few words of summary only
|
|
10350
|
+
|
|
10351
|
+
## Conversation
|
|
10352
|
+
|
|
10353
|
+
**User:**
|
|
10354
|
+
|
|
10355
|
+
> {userMessage}
|
|
10356
|
+
|
|
10357
|
+
**You:**
|
|
10358
|
+
|
|
10359
|
+
> {chatbotResponse}
|
|
10360
|
+
`),
|
|
10299
10361
|
resultingParameterName: 'conversationSummary',
|
|
10300
10362
|
personaName,
|
|
10301
10363
|
expectations: {
|
|
@@ -15838,18 +15900,6 @@ function parseDataUrlKnowledgeSource(source) {
|
|
|
15838
15900
|
}
|
|
15839
15901
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
15840
15902
|
|
|
15841
|
-
/**
|
|
15842
|
-
* Name of the tool used by agents to search configured `KNOWLEDGE` sources.
|
|
15843
|
-
*
|
|
15844
|
-
* @public exported from `@promptbook/core`
|
|
15845
|
-
*/
|
|
15846
|
-
const KNOWLEDGE_SEARCH_TOOL_NAME = 'knowledge_search';
|
|
15847
|
-
/**
|
|
15848
|
-
* Title of the system-message section generated for `KNOWLEDGE` commitments.
|
|
15849
|
-
*
|
|
15850
|
-
* @private constant of `KnowledgeCommitmentDefinition`
|
|
15851
|
-
*/
|
|
15852
|
-
const KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE = 'Knowledge Search';
|
|
15853
15903
|
/**
|
|
15854
15904
|
* KNOWLEDGE commitment definition
|
|
15855
15905
|
*
|
|
@@ -15971,17 +16021,9 @@ class KnowledgeCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
15971
16021
|
knowledgeInfoEntries.push(`Knowledge Source Inline: ${inlineSource.filename} (derived from inline content and processed for retrieval during chat)`);
|
|
15972
16022
|
}
|
|
15973
16023
|
if (knowledgeInfoEntries.length === 0) {
|
|
15974
|
-
return
|
|
16024
|
+
return nextRequirements;
|
|
15975
16025
|
}
|
|
15976
|
-
return
|
|
15977
|
-
}
|
|
15978
|
-
/**
|
|
15979
|
-
* Gets human-readable titles for tool functions provided by this commitment.
|
|
15980
|
-
*/
|
|
15981
|
-
getToolTitles() {
|
|
15982
|
-
return {
|
|
15983
|
-
[KNOWLEDGE_SEARCH_TOOL_NAME]: 'Knowledge search',
|
|
15984
|
-
};
|
|
16026
|
+
return this.appendToSystemMessage(nextRequirements, knowledgeInfoEntries.join('\n'), '\n\n');
|
|
15985
16027
|
}
|
|
15986
16028
|
}
|
|
15987
16029
|
/**
|
|
@@ -15995,128 +16037,6 @@ function hasMeaningfulNonUrlText(content, urls) {
|
|
|
15995
16037
|
const significantText = contentWithoutUrls.replace(/[\s.,!?;:'"`()[\]{}<>/-]+/g, '');
|
|
15996
16038
|
return significantText.length > 0;
|
|
15997
16039
|
}
|
|
15998
|
-
/**
|
|
15999
|
-
* Adds the shared `knowledge_search` tool definition and the consolidated system-message section.
|
|
16000
|
-
*
|
|
16001
|
-
* @param requirements - Requirements after one `KNOWLEDGE` commitment was applied.
|
|
16002
|
-
* @returns Requirements with the knowledge search instructions and tool definition.
|
|
16003
|
-
*
|
|
16004
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
16005
|
-
*/
|
|
16006
|
-
function addKnowledgeSearchToolAndSystemSection(requirements) {
|
|
16007
|
-
const nextRequirements = addKnowledgeSearchTool(requirements);
|
|
16008
|
-
const section = createKnowledgeSearchSystemSection(nextRequirements);
|
|
16009
|
-
const sectionHeader = `## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}`;
|
|
16010
|
-
if (nextRequirements.systemMessage.includes(sectionHeader)) {
|
|
16011
|
-
return {
|
|
16012
|
-
...nextRequirements,
|
|
16013
|
-
systemMessage: nextRequirements.systemMessage.replace(new RegExp(`## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\s\\S]*?(?=\\n\\n##|$)`), section),
|
|
16014
|
-
};
|
|
16015
|
-
}
|
|
16016
|
-
return {
|
|
16017
|
-
...nextRequirements,
|
|
16018
|
-
systemMessage: nextRequirements.systemMessage.trim()
|
|
16019
|
-
? `${nextRequirements.systemMessage}\n\n${section}`
|
|
16020
|
-
: section,
|
|
16021
|
-
};
|
|
16022
|
-
}
|
|
16023
|
-
/**
|
|
16024
|
-
* Adds the `knowledge_search` model tool when it is not already present.
|
|
16025
|
-
*
|
|
16026
|
-
* @param requirements - Current model requirements.
|
|
16027
|
-
* @returns Requirements with the tool definition available to the model.
|
|
16028
|
-
*
|
|
16029
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
16030
|
-
*/
|
|
16031
|
-
function addKnowledgeSearchTool(requirements) {
|
|
16032
|
-
const existingTools = requirements.tools || [];
|
|
16033
|
-
if (existingTools.some((tool) => tool.name === KNOWLEDGE_SEARCH_TOOL_NAME)) {
|
|
16034
|
-
return requirements;
|
|
16035
|
-
}
|
|
16036
|
-
return {
|
|
16037
|
-
...requirements,
|
|
16038
|
-
tools: [
|
|
16039
|
-
...existingTools,
|
|
16040
|
-
{
|
|
16041
|
-
name: KNOWLEDGE_SEARCH_TOOL_NAME,
|
|
16042
|
-
description: spaceTrim$1(`
|
|
16043
|
-
Search the agent's configured knowledge sources and return relevant excerpts with citation ids.
|
|
16044
|
-
Use this before answering questions that may depend on the agent's KNOWLEDGE commitments.
|
|
16045
|
-
`),
|
|
16046
|
-
parameters: {
|
|
16047
|
-
type: 'object',
|
|
16048
|
-
properties: {
|
|
16049
|
-
query: {
|
|
16050
|
-
type: 'string',
|
|
16051
|
-
description: 'The natural-language search query for the knowledge base.',
|
|
16052
|
-
},
|
|
16053
|
-
limit: {
|
|
16054
|
-
type: 'integer',
|
|
16055
|
-
description: 'Maximum number of matching source excerpts to return.',
|
|
16056
|
-
},
|
|
16057
|
-
},
|
|
16058
|
-
required: ['query'],
|
|
16059
|
-
},
|
|
16060
|
-
},
|
|
16061
|
-
],
|
|
16062
|
-
};
|
|
16063
|
-
}
|
|
16064
|
-
/**
|
|
16065
|
-
* Creates the model-facing system-message section for knowledge search.
|
|
16066
|
-
*
|
|
16067
|
-
* @param requirements - Current model requirements.
|
|
16068
|
-
* @returns Markdown system-message section.
|
|
16069
|
-
*
|
|
16070
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
16071
|
-
*/
|
|
16072
|
-
function createKnowledgeSearchSystemSection(requirements) {
|
|
16073
|
-
const sourceEntries = createKnowledgeSourceSystemEntries(requirements);
|
|
16074
|
-
const sourceList = sourceEntries.length > 0 ? sourceEntries.map((entry) => `- ${entry}`).join('\n') : '- None';
|
|
16075
|
-
return spaceTrim$1(`
|
|
16076
|
-
## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}
|
|
16077
|
-
|
|
16078
|
-
- Use \`${KNOWLEDGE_SEARCH_TOOL_NAME}\` to search the configured knowledge sources before answering questions that depend on this agent's knowledge base.
|
|
16079
|
-
- Base source-backed factual answers on the returned excerpts.
|
|
16080
|
-
- When you use a returned excerpt, include its citation marker in the answer body, for example \`[0:0]\`.
|
|
16081
|
-
- If the search returns no relevant information, say that the knowledge base did not contain the answer instead of inventing it.
|
|
16082
|
-
|
|
16083
|
-
Configured knowledge sources:
|
|
16084
|
-
${sourceList}
|
|
16085
|
-
`);
|
|
16086
|
-
}
|
|
16087
|
-
/**
|
|
16088
|
-
* Builds a stable list of configured knowledge sources for system-message diagnostics.
|
|
16089
|
-
*
|
|
16090
|
-
* @param requirements - Current model requirements.
|
|
16091
|
-
* @returns Human-readable source entries.
|
|
16092
|
-
*
|
|
16093
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
16094
|
-
*/
|
|
16095
|
-
function createKnowledgeSourceSystemEntries(requirements) {
|
|
16096
|
-
var _a;
|
|
16097
|
-
const entries = [];
|
|
16098
|
-
const seenEntries = new Set();
|
|
16099
|
-
for (const source of requirements.knowledgeSources || []) {
|
|
16100
|
-
const entry = `Source URL: ${source} (processed for retrieval during chat)`;
|
|
16101
|
-
if (seenEntries.has(entry)) {
|
|
16102
|
-
continue;
|
|
16103
|
-
}
|
|
16104
|
-
seenEntries.add(entry);
|
|
16105
|
-
entries.push(entry);
|
|
16106
|
-
}
|
|
16107
|
-
const inlineSources = (((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.inlineKnowledgeSources) || [])
|
|
16108
|
-
.map((source) => source.filename)
|
|
16109
|
-
.filter(Boolean);
|
|
16110
|
-
for (const filename of inlineSources) {
|
|
16111
|
-
const entry = `Knowledge Source Inline: ${filename} (Inline source: processed for retrieval during chat)`;
|
|
16112
|
-
if (seenEntries.has(entry)) {
|
|
16113
|
-
continue;
|
|
16114
|
-
}
|
|
16115
|
-
seenEntries.add(entry);
|
|
16116
|
-
entries.push(entry);
|
|
16117
|
-
}
|
|
16118
|
-
return entries;
|
|
16119
|
-
}
|
|
16120
16040
|
|
|
16121
16041
|
/**
|
|
16122
16042
|
* LANGUAGE commitment definition
|
|
@@ -18768,6 +18688,177 @@ function drawFractalCore(context, size, palette, timeMs, corePhase) {
|
|
|
18768
18688
|
context.restore();
|
|
18769
18689
|
}
|
|
18770
18690
|
|
|
18691
|
+
/* eslint-disable no-magic-numbers */
|
|
18692
|
+
/**
|
|
18693
|
+
* Builds the seeded six-face texture pack used by the Minecraft-style head cuboid.
|
|
18694
|
+
*
|
|
18695
|
+
* @param random Seeded random generator.
|
|
18696
|
+
* @param palette Derived avatar palette.
|
|
18697
|
+
* @param hasHeadband Whether the generated avatar should include a colored headband.
|
|
18698
|
+
* @returns Head cuboid textures.
|
|
18699
|
+
*
|
|
18700
|
+
* @private helper of the Minecraft avatar visuals
|
|
18701
|
+
*/
|
|
18702
|
+
function createMinecraftHeadTextures(random, palette, hasHeadband) {
|
|
18703
|
+
const faceTexture = createMinecraftFaceTexture(random, palette, hasHeadband);
|
|
18704
|
+
const hairColor = random() < 0.5 ? palette.primary : palette.secondary;
|
|
18705
|
+
const skinColor = palette.highlight;
|
|
18706
|
+
const headbandColor = hasHeadband ? palette.accent : hairColor;
|
|
18707
|
+
const sideTexture = createFilledTexture(skinColor);
|
|
18708
|
+
const backTexture = createFilledTexture(skinColor);
|
|
18709
|
+
const topTexture = createFilledTexture(hairColor);
|
|
18710
|
+
const bottomTexture = createFilledTexture(`${palette.shadow}cc`);
|
|
18711
|
+
fillTextureRect(sideTexture, 0, 0, 8, 3, hairColor);
|
|
18712
|
+
fillTextureRect(backTexture, 0, 0, 8, 5, hairColor);
|
|
18713
|
+
fillTextureRect(backTexture, 1, 5, 6, 1, hairColor);
|
|
18714
|
+
if (hasHeadband) {
|
|
18715
|
+
fillTextureRect(sideTexture, 0, 2, 8, 1, headbandColor);
|
|
18716
|
+
fillTextureRect(backTexture, 0, 2, 8, 1, headbandColor);
|
|
18717
|
+
fillTextureRect(topTexture, 0, 4, 8, 1, headbandColor);
|
|
18718
|
+
}
|
|
18719
|
+
sideTexture[4][4] = `${palette.shadow}99`;
|
|
18720
|
+
sideTexture[5][4] = `${palette.shadow}cc`;
|
|
18721
|
+
backTexture[6][2] = `${palette.shadow}99`;
|
|
18722
|
+
backTexture[6][5] = `${palette.shadow}99`;
|
|
18723
|
+
return {
|
|
18724
|
+
front: faceTexture,
|
|
18725
|
+
back: backTexture,
|
|
18726
|
+
left: sideTexture,
|
|
18727
|
+
right: mirrorMinecraftTexture(sideTexture),
|
|
18728
|
+
top: topTexture,
|
|
18729
|
+
bottom: bottomTexture,
|
|
18730
|
+
};
|
|
18731
|
+
}
|
|
18732
|
+
/**
|
|
18733
|
+
* Builds the seeded six-face texture pack used by the Minecraft-style torso cuboid.
|
|
18734
|
+
*
|
|
18735
|
+
* @param random Seeded random generator.
|
|
18736
|
+
* @param palette Derived avatar palette.
|
|
18737
|
+
* @returns Torso cuboid textures.
|
|
18738
|
+
*
|
|
18739
|
+
* @private helper of the Minecraft avatar visuals
|
|
18740
|
+
*/
|
|
18741
|
+
function createMinecraftTorsoTextures(random, palette) {
|
|
18742
|
+
const frontTexture = createMinecraftShirtTexture(random, palette);
|
|
18743
|
+
const sideTexture = createFilledTexture(palette.primary);
|
|
18744
|
+
const backTexture = createFilledTexture(palette.primary);
|
|
18745
|
+
const topTexture = createFilledTexture(`${palette.highlight}dd`);
|
|
18746
|
+
const bottomTexture = createFilledTexture(`${palette.shadow}dd`);
|
|
18747
|
+
const stripeColor = random() < 0.5 ? palette.secondary : palette.highlight;
|
|
18748
|
+
fillTextureRect(sideTexture, 0, 0, 8, 2, palette.shadow);
|
|
18749
|
+
fillTextureRect(backTexture, 0, 0, 8, 2, palette.shadow);
|
|
18750
|
+
fillTextureRect(backTexture, 3, 2, 2, 6, stripeColor);
|
|
18751
|
+
fillTextureRect(sideTexture, 4, 2, 1, 6, stripeColor);
|
|
18752
|
+
fillTextureRect(topTexture, 0, 0, 8, 2, palette.shadow);
|
|
18753
|
+
fillTextureRect(topTexture, 2, 2, 4, 4, stripeColor);
|
|
18754
|
+
return {
|
|
18755
|
+
front: frontTexture,
|
|
18756
|
+
back: backTexture,
|
|
18757
|
+
left: sideTexture,
|
|
18758
|
+
right: mirrorMinecraftTexture(sideTexture),
|
|
18759
|
+
top: topTexture,
|
|
18760
|
+
bottom: bottomTexture,
|
|
18761
|
+
};
|
|
18762
|
+
}
|
|
18763
|
+
/**
|
|
18764
|
+
* Mirrors one Minecraft texture horizontally.
|
|
18765
|
+
*
|
|
18766
|
+
* @param texture Source texture.
|
|
18767
|
+
* @returns Mirrored texture copy.
|
|
18768
|
+
*
|
|
18769
|
+
* @private helper of the Minecraft avatar visuals
|
|
18770
|
+
*/
|
|
18771
|
+
function mirrorMinecraftTexture(texture) {
|
|
18772
|
+
return texture.map((row) => [...row].reverse());
|
|
18773
|
+
}
|
|
18774
|
+
/**
|
|
18775
|
+
* Creates the front-face pixel texture for the cube head.
|
|
18776
|
+
*
|
|
18777
|
+
* @param random Seeded random generator.
|
|
18778
|
+
* @param palette Derived avatar palette.
|
|
18779
|
+
* @param hasHeadband Whether the avatar should render a headband row.
|
|
18780
|
+
* @returns 8x8 pixel texture.
|
|
18781
|
+
*
|
|
18782
|
+
* @private helper of the Minecraft avatar visuals
|
|
18783
|
+
*/
|
|
18784
|
+
function createMinecraftFaceTexture(random, palette, hasHeadband) {
|
|
18785
|
+
const texture = createFilledTexture(palette.highlight);
|
|
18786
|
+
const hairlineColor = random() < 0.5 ? palette.primary : palette.secondary;
|
|
18787
|
+
const cheekColor = random() < 0.5 ? `${palette.accent}bb` : `${palette.secondary}bb`;
|
|
18788
|
+
fillTextureRect(texture, 0, 0, 8, 2, hairlineColor);
|
|
18789
|
+
texture[2][0] = hairlineColor;
|
|
18790
|
+
texture[2][7] = hairlineColor;
|
|
18791
|
+
texture[3][0] = hairlineColor;
|
|
18792
|
+
texture[3][7] = hairlineColor;
|
|
18793
|
+
if (hasHeadband) {
|
|
18794
|
+
fillTextureRect(texture, 0, 2, 8, 1, palette.accent);
|
|
18795
|
+
}
|
|
18796
|
+
texture[3][2] = palette.ink;
|
|
18797
|
+
texture[3][5] = palette.ink;
|
|
18798
|
+
texture[4][2] = '#ffffff';
|
|
18799
|
+
texture[4][5] = '#ffffff';
|
|
18800
|
+
texture[5][1] = cheekColor;
|
|
18801
|
+
texture[5][6] = cheekColor;
|
|
18802
|
+
texture[5][3] = palette.shadow;
|
|
18803
|
+
texture[5][4] = palette.shadow;
|
|
18804
|
+
texture[6][3] = palette.shadow;
|
|
18805
|
+
texture[6][4] = palette.shadow;
|
|
18806
|
+
return texture;
|
|
18807
|
+
}
|
|
18808
|
+
/**
|
|
18809
|
+
* Creates the front-face pixel texture for the torso.
|
|
18810
|
+
*
|
|
18811
|
+
* @param random Seeded random generator.
|
|
18812
|
+
* @param palette Derived avatar palette.
|
|
18813
|
+
* @returns 8x8 torso texture.
|
|
18814
|
+
*
|
|
18815
|
+
* @private helper of the Minecraft avatar visuals
|
|
18816
|
+
*/
|
|
18817
|
+
function createMinecraftShirtTexture(random, palette) {
|
|
18818
|
+
const texture = createFilledTexture(palette.primary);
|
|
18819
|
+
const stripeColor = random() < 0.5 ? palette.secondary : palette.highlight;
|
|
18820
|
+
fillTextureRect(texture, 0, 0, 8, 2, palette.shadow);
|
|
18821
|
+
for (let rowIndex = 2; rowIndex < 8; rowIndex++) {
|
|
18822
|
+
texture[rowIndex][3] = stripeColor;
|
|
18823
|
+
texture[rowIndex][4] = stripeColor;
|
|
18824
|
+
}
|
|
18825
|
+
texture[4][1] = palette.accent;
|
|
18826
|
+
texture[4][6] = palette.accent;
|
|
18827
|
+
texture[5][2] = palette.highlight;
|
|
18828
|
+
texture[5][5] = palette.highlight;
|
|
18829
|
+
return texture;
|
|
18830
|
+
}
|
|
18831
|
+
/**
|
|
18832
|
+
* Creates one solid-color 8x8 Minecraft texture.
|
|
18833
|
+
*
|
|
18834
|
+
* @param color Fill color.
|
|
18835
|
+
* @returns Filled 8x8 texture.
|
|
18836
|
+
*
|
|
18837
|
+
* @private helper of the Minecraft avatar visuals
|
|
18838
|
+
*/
|
|
18839
|
+
function createFilledTexture(color) {
|
|
18840
|
+
return Array.from({ length: 8 }, () => Array.from({ length: 8 }, () => color));
|
|
18841
|
+
}
|
|
18842
|
+
/**
|
|
18843
|
+
* Fills one rectangular area inside a mutable Minecraft texture.
|
|
18844
|
+
*
|
|
18845
|
+
* @param texture Mutable target texture.
|
|
18846
|
+
* @param x Left texture coordinate.
|
|
18847
|
+
* @param y Top texture coordinate.
|
|
18848
|
+
* @param width Rectangle width.
|
|
18849
|
+
* @param height Rectangle height.
|
|
18850
|
+
* @param color Fill color.
|
|
18851
|
+
*
|
|
18852
|
+
* @private helper of the Minecraft avatar visuals
|
|
18853
|
+
*/
|
|
18854
|
+
function fillTextureRect(texture, x, y, width, height, color) {
|
|
18855
|
+
for (let rowIndex = y; rowIndex < y + height; rowIndex++) {
|
|
18856
|
+
for (let columnIndex = x; columnIndex < x + width; columnIndex++) {
|
|
18857
|
+
texture[rowIndex][columnIndex] = color;
|
|
18858
|
+
}
|
|
18859
|
+
}
|
|
18860
|
+
}
|
|
18861
|
+
|
|
18771
18862
|
/* eslint-disable no-magic-numbers */
|
|
18772
18863
|
/**
|
|
18773
18864
|
* Minecraft-style 3D avatar visual.
|
|
@@ -18792,8 +18883,8 @@ const minecraftAvatarVisual = {
|
|
|
18792
18883
|
const bodyX = size * 0.33;
|
|
18793
18884
|
const bodyY = headY + headSize * 0.96;
|
|
18794
18885
|
const hasHeadband = random() < 0.5;
|
|
18795
|
-
const
|
|
18796
|
-
const
|
|
18886
|
+
const headTextures = createMinecraftHeadTextures(createRandom('minecraft-face'), palette, hasHeadband);
|
|
18887
|
+
const torsoTextures = createMinecraftTorsoTextures(createRandom('minecraft-shirt'), palette);
|
|
18797
18888
|
drawAvatarFrame(context, size, palette);
|
|
18798
18889
|
const spotlight = context.createRadialGradient(size * 0.5, size * 0.18, size * 0.05, size * 0.5, size * 0.18, size * 0.5);
|
|
18799
18890
|
spotlight.addColorStop(0, `${palette.highlight}66`);
|
|
@@ -18813,7 +18904,7 @@ const minecraftAvatarVisual = {
|
|
|
18813
18904
|
width: bodyWidth,
|
|
18814
18905
|
height: bodyHeight,
|
|
18815
18906
|
depth: bodyDepth,
|
|
18816
|
-
frontTexture:
|
|
18907
|
+
frontTexture: torsoTextures.front,
|
|
18817
18908
|
topColor: `${palette.highlight}cc`,
|
|
18818
18909
|
sideColor: `${palette.secondary}dd`,
|
|
18819
18910
|
outlineColor: `${palette.shadow}aa`,
|
|
@@ -18824,7 +18915,7 @@ const minecraftAvatarVisual = {
|
|
|
18824
18915
|
width: headSize,
|
|
18825
18916
|
height: headSize,
|
|
18826
18917
|
depth,
|
|
18827
|
-
frontTexture:
|
|
18918
|
+
frontTexture: headTextures.front,
|
|
18828
18919
|
topColor: `${palette.highlight}ee`,
|
|
18829
18920
|
sideColor: `${palette.secondary}ee`,
|
|
18830
18921
|
outlineColor: `${palette.shadow}cc`,
|
|
@@ -18889,72 +18980,505 @@ function drawVoxelCuboid(context, cuboid) {
|
|
|
18889
18980
|
context.closePath();
|
|
18890
18981
|
context.stroke();
|
|
18891
18982
|
}
|
|
18983
|
+
|
|
18984
|
+
/* eslint-disable no-magic-numbers */
|
|
18892
18985
|
/**
|
|
18893
|
-
*
|
|
18986
|
+
* Fixed scene camera distance used for the proper-3D projection.
|
|
18894
18987
|
*
|
|
18895
|
-
* @
|
|
18988
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
18989
|
+
*/
|
|
18990
|
+
const CAMERA_DISTANCE_RATIO = 1.4;
|
|
18991
|
+
/**
|
|
18992
|
+
* Shared light direction used to shade projected cuboid faces.
|
|
18993
|
+
*
|
|
18994
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
18995
|
+
*/
|
|
18996
|
+
const LIGHT_DIRECTION = normalizeVector3({
|
|
18997
|
+
x: 0.4,
|
|
18998
|
+
y: -0.65,
|
|
18999
|
+
z: 0.92,
|
|
19000
|
+
});
|
|
19001
|
+
/**
|
|
19002
|
+
* Minecraft 3D 2 avatar visual.
|
|
19003
|
+
*
|
|
19004
|
+
* @private built-in avatar visual
|
|
19005
|
+
*/
|
|
19006
|
+
const minecraft2AvatarVisual = {
|
|
19007
|
+
id: 'minecraft2',
|
|
19008
|
+
title: 'Minecraft 3D 2',
|
|
19009
|
+
description: 'Proper 3D Minecraft-style portrait with textured cuboids and pointer-driven head turns.',
|
|
19010
|
+
isAnimated: true,
|
|
19011
|
+
supportsPointerTracking: true,
|
|
19012
|
+
render({ context, size, palette, createRandom, timeMs, interaction }) {
|
|
19013
|
+
const spotlightY = size * 0.22;
|
|
19014
|
+
const headRandom = createRandom('minecraft2-head');
|
|
19015
|
+
const hasHeadband = headRandom() < 0.5;
|
|
19016
|
+
const headTextures = createMinecraftHeadTextures(createRandom('minecraft2-head-textures'), palette, hasHeadband);
|
|
19017
|
+
const torsoTextures = createMinecraftTorsoTextures(createRandom('minecraft2-body-textures'), palette);
|
|
19018
|
+
const bob = Math.sin(timeMs / 880) * size * 0.014;
|
|
19019
|
+
const bodyYaw = -0.24 + Math.sin(timeMs / 2300) * 0.06 + interaction.bodyOffsetX * 0.16;
|
|
19020
|
+
const bodyPitch = -0.12 + Math.cos(timeMs / 2800) * 0.02 - interaction.bodyOffsetY * 0.06;
|
|
19021
|
+
const headYaw = -0.18 + Math.sin(timeMs / 1900 + 0.6) * 0.05 + interaction.gazeX * 0.62;
|
|
19022
|
+
const headPitch = -0.12 + Math.cos(timeMs / 2400 + 1.1) * 0.03 - interaction.gazeY * 0.38;
|
|
19023
|
+
const sceneCenterX = size * 0.5;
|
|
19024
|
+
const sceneCenterY = size * 0.57;
|
|
19025
|
+
const bodyWidth = size * 0.225;
|
|
19026
|
+
const bodyHeight = size * 0.245;
|
|
19027
|
+
const bodyDepth = size * 0.145;
|
|
19028
|
+
const headSize = size * 0.24;
|
|
19029
|
+
const headLift = size * 0.205;
|
|
19030
|
+
const headForwardShift = interaction.intensity * size * 0.018;
|
|
19031
|
+
const sceneCuboids = [
|
|
19032
|
+
{
|
|
19033
|
+
center: {
|
|
19034
|
+
x: interaction.bodyOffsetX * size * 0.026,
|
|
19035
|
+
y: size * 0.05 + interaction.bodyOffsetY * size * 0.018 + bob,
|
|
19036
|
+
z: 0,
|
|
19037
|
+
},
|
|
19038
|
+
width: bodyWidth,
|
|
19039
|
+
height: bodyHeight,
|
|
19040
|
+
depth: bodyDepth,
|
|
19041
|
+
rotationX: bodyPitch,
|
|
19042
|
+
rotationY: bodyYaw,
|
|
19043
|
+
textures: torsoTextures,
|
|
19044
|
+
outlineColor: `${palette.shadow}cc`,
|
|
19045
|
+
},
|
|
19046
|
+
{
|
|
19047
|
+
center: {
|
|
19048
|
+
x: interaction.bodyOffsetX * size * 0.018 + interaction.gazeX * size * 0.016,
|
|
19049
|
+
y: -headLift + bob * 1.15,
|
|
19050
|
+
z: headForwardShift,
|
|
19051
|
+
},
|
|
19052
|
+
width: headSize,
|
|
19053
|
+
height: headSize,
|
|
19054
|
+
depth: headSize,
|
|
19055
|
+
rotationX: headPitch,
|
|
19056
|
+
rotationY: headYaw,
|
|
19057
|
+
textures: headTextures,
|
|
19058
|
+
outlineColor: `${palette.shadow}dd`,
|
|
19059
|
+
},
|
|
19060
|
+
];
|
|
19061
|
+
const visibleFaces = sceneCuboids
|
|
19062
|
+
.flatMap((cuboid) => resolveVisibleCuboidFaces(cuboid, size, sceneCenterX, sceneCenterY))
|
|
19063
|
+
.sort((firstFace, secondFace) => firstFace.averageDepth - secondFace.averageDepth);
|
|
19064
|
+
drawAvatarFrame(context, size, palette);
|
|
19065
|
+
drawMinecraftBackdrop(context, size, palette, sceneCenterX, spotlightY, interaction, timeMs);
|
|
19066
|
+
drawMinecraftShadow(context, size, palette, interaction, timeMs);
|
|
19067
|
+
for (const visibleFace of visibleFaces) {
|
|
19068
|
+
drawTexturedProjectedFace(context, visibleFace);
|
|
19069
|
+
}
|
|
19070
|
+
},
|
|
19071
|
+
};
|
|
19072
|
+
/**
|
|
19073
|
+
* Draws the shared background atmosphere behind the Minecraft 3D 2 portrait.
|
|
19074
|
+
*
|
|
19075
|
+
* @param context Canvas 2D context.
|
|
19076
|
+
* @param size Canvas size in CSS pixels.
|
|
18896
19077
|
* @param palette Derived avatar palette.
|
|
18897
|
-
* @param
|
|
18898
|
-
* @
|
|
19078
|
+
* @param sceneCenterX Horizontal scene center.
|
|
19079
|
+
* @param spotlightY Vertical spotlight anchor.
|
|
19080
|
+
* @param interaction Smoothed pointer-aware interaction state.
|
|
19081
|
+
* @param timeMs Current animation time in milliseconds.
|
|
18899
19082
|
*
|
|
18900
|
-
* @private helper of `
|
|
19083
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
18901
19084
|
*/
|
|
18902
|
-
function
|
|
18903
|
-
const
|
|
18904
|
-
|
|
18905
|
-
|
|
18906
|
-
|
|
18907
|
-
|
|
18908
|
-
|
|
19085
|
+
function drawMinecraftBackdrop(context, size, palette, sceneCenterX, spotlightY, interaction, timeMs) {
|
|
19086
|
+
const spotlightGradient = context.createRadialGradient(sceneCenterX + interaction.gazeX * size * 0.08, spotlightY + interaction.gazeY * size * 0.05, size * 0.03, sceneCenterX, spotlightY, size * 0.52);
|
|
19087
|
+
spotlightGradient.addColorStop(0, `${palette.highlight}66`);
|
|
19088
|
+
spotlightGradient.addColorStop(0.42, `${palette.accent}1d`);
|
|
19089
|
+
spotlightGradient.addColorStop(1, `${palette.highlight}00`);
|
|
19090
|
+
context.fillStyle = spotlightGradient;
|
|
19091
|
+
context.fillRect(0, 0, size, size);
|
|
19092
|
+
const rimGradient = context.createLinearGradient(0, size * 0.14, 0, size * 0.92);
|
|
19093
|
+
rimGradient.addColorStop(0, `${palette.highlight}12`);
|
|
19094
|
+
rimGradient.addColorStop(0.55, `${palette.secondary}0a`);
|
|
19095
|
+
rimGradient.addColorStop(1, `${palette.shadow}00`);
|
|
19096
|
+
context.fillStyle = rimGradient;
|
|
19097
|
+
context.fillRect(0, 0, size, size);
|
|
19098
|
+
context.save();
|
|
19099
|
+
context.globalAlpha = 0.08 + interaction.intensity * 0.04;
|
|
19100
|
+
context.fillStyle = palette.highlight;
|
|
19101
|
+
context.beginPath();
|
|
19102
|
+
context.arc(size * 0.72 + Math.sin(timeMs / 1600) * size * 0.03, size * 0.2 + Math.cos(timeMs / 1400) * size * 0.018, size * 0.025, 0, Math.PI * 2);
|
|
19103
|
+
context.fill();
|
|
19104
|
+
context.restore();
|
|
19105
|
+
}
|
|
19106
|
+
/**
|
|
19107
|
+
* Draws the soft floor shadow used to anchor the cuboids in the frame.
|
|
19108
|
+
*
|
|
19109
|
+
* @param context Canvas 2D context.
|
|
19110
|
+
* @param size Canvas size in CSS pixels.
|
|
19111
|
+
* @param palette Derived avatar palette.
|
|
19112
|
+
* @param interaction Smoothed pointer-aware interaction state.
|
|
19113
|
+
* @param timeMs Current animation time in milliseconds.
|
|
19114
|
+
*
|
|
19115
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19116
|
+
*/
|
|
19117
|
+
function drawMinecraftShadow(context, size, palette, interaction, timeMs) {
|
|
19118
|
+
context.save();
|
|
19119
|
+
context.fillStyle = `${palette.shadow}66`;
|
|
19120
|
+
context.filter = `blur(${size * 0.02}px)`;
|
|
19121
|
+
context.beginPath();
|
|
19122
|
+
context.ellipse(size * 0.5 + interaction.gazeX * size * 0.03, size * 0.85 + Math.sin(timeMs / 880) * size * 0.01, size * (0.16 + interaction.intensity * 0.015), size * 0.055, 0, 0, Math.PI * 2);
|
|
19123
|
+
context.fill();
|
|
19124
|
+
context.restore();
|
|
19125
|
+
}
|
|
19126
|
+
/**
|
|
19127
|
+
* Resolves all visible projected faces for one scene cuboid.
|
|
19128
|
+
*
|
|
19129
|
+
* @param cuboid Scene cuboid definition.
|
|
19130
|
+
* @param size Canvas size in CSS pixels.
|
|
19131
|
+
* @param sceneCenterX Horizontal scene center.
|
|
19132
|
+
* @param sceneCenterY Vertical scene center.
|
|
19133
|
+
* @returns Visible faces sorted later by depth.
|
|
19134
|
+
*
|
|
19135
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19136
|
+
*/
|
|
19137
|
+
function resolveVisibleCuboidFaces(cuboid, size, sceneCenterX, sceneCenterY) {
|
|
19138
|
+
const halfWidth = cuboid.width / 2;
|
|
19139
|
+
const halfHeight = cuboid.height / 2;
|
|
19140
|
+
const halfDepth = cuboid.depth / 2;
|
|
19141
|
+
const faceDefinitions = [
|
|
19142
|
+
{
|
|
19143
|
+
texture: cuboid.textures.front,
|
|
19144
|
+
corners: [
|
|
19145
|
+
{ x: -halfWidth, y: -halfHeight, z: halfDepth },
|
|
19146
|
+
{ x: halfWidth, y: -halfHeight, z: halfDepth },
|
|
19147
|
+
{ x: halfWidth, y: halfHeight, z: halfDepth },
|
|
19148
|
+
{ x: -halfWidth, y: halfHeight, z: halfDepth },
|
|
19149
|
+
],
|
|
19150
|
+
},
|
|
19151
|
+
{
|
|
19152
|
+
texture: cuboid.textures.back,
|
|
19153
|
+
corners: [
|
|
19154
|
+
{ x: halfWidth, y: -halfHeight, z: -halfDepth },
|
|
19155
|
+
{ x: -halfWidth, y: -halfHeight, z: -halfDepth },
|
|
19156
|
+
{ x: -halfWidth, y: halfHeight, z: -halfDepth },
|
|
19157
|
+
{ x: halfWidth, y: halfHeight, z: -halfDepth },
|
|
19158
|
+
],
|
|
19159
|
+
},
|
|
19160
|
+
{
|
|
19161
|
+
texture: cuboid.textures.right,
|
|
19162
|
+
corners: [
|
|
19163
|
+
{ x: halfWidth, y: -halfHeight, z: halfDepth },
|
|
19164
|
+
{ x: halfWidth, y: -halfHeight, z: -halfDepth },
|
|
19165
|
+
{ x: halfWidth, y: halfHeight, z: -halfDepth },
|
|
19166
|
+
{ x: halfWidth, y: halfHeight, z: halfDepth },
|
|
19167
|
+
],
|
|
19168
|
+
},
|
|
19169
|
+
{
|
|
19170
|
+
texture: cuboid.textures.left,
|
|
19171
|
+
corners: [
|
|
19172
|
+
{ x: -halfWidth, y: -halfHeight, z: -halfDepth },
|
|
19173
|
+
{ x: -halfWidth, y: -halfHeight, z: halfDepth },
|
|
19174
|
+
{ x: -halfWidth, y: halfHeight, z: halfDepth },
|
|
19175
|
+
{ x: -halfWidth, y: halfHeight, z: -halfDepth },
|
|
19176
|
+
],
|
|
19177
|
+
},
|
|
19178
|
+
{
|
|
19179
|
+
texture: cuboid.textures.top,
|
|
19180
|
+
corners: [
|
|
19181
|
+
{ x: -halfWidth, y: -halfHeight, z: -halfDepth },
|
|
19182
|
+
{ x: halfWidth, y: -halfHeight, z: -halfDepth },
|
|
19183
|
+
{ x: halfWidth, y: -halfHeight, z: halfDepth },
|
|
19184
|
+
{ x: -halfWidth, y: -halfHeight, z: halfDepth },
|
|
19185
|
+
],
|
|
19186
|
+
},
|
|
19187
|
+
{
|
|
19188
|
+
texture: cuboid.textures.bottom,
|
|
19189
|
+
corners: [
|
|
19190
|
+
{ x: -halfWidth, y: halfHeight, z: halfDepth },
|
|
19191
|
+
{ x: halfWidth, y: halfHeight, z: halfDepth },
|
|
19192
|
+
{ x: halfWidth, y: halfHeight, z: -halfDepth },
|
|
19193
|
+
{ x: -halfWidth, y: halfHeight, z: -halfDepth },
|
|
19194
|
+
],
|
|
19195
|
+
},
|
|
19196
|
+
];
|
|
19197
|
+
const visibleFaces = faceDefinitions
|
|
19198
|
+
.map((faceDefinition) => {
|
|
19199
|
+
const transformedCorners = faceDefinition.corners.map((corner) => transformScenePoint(corner, cuboid.center, cuboid.rotationX, cuboid.rotationY));
|
|
19200
|
+
const faceNormal = normalizeVector3(crossProduct3D(subtractPoint3D(transformedCorners[1], transformedCorners[0]), subtractPoint3D(transformedCorners[2], transformedCorners[0])));
|
|
19201
|
+
if (faceNormal.z <= 0.02) {
|
|
19202
|
+
return null;
|
|
18909
19203
|
}
|
|
19204
|
+
const projectedCorners = transformedCorners.map((corner) => projectScenePoint(corner, size, sceneCenterX, sceneCenterY));
|
|
19205
|
+
return {
|
|
19206
|
+
corners: projectedCorners,
|
|
19207
|
+
texture: faceDefinition.texture,
|
|
19208
|
+
averageDepth: transformedCorners.reduce((depthSum, corner) => depthSum + corner.z, 0) / transformedCorners.length,
|
|
19209
|
+
lightIntensity: clampNumber$1(dotProduct3D(faceNormal, LIGHT_DIRECTION), -1, 1),
|
|
19210
|
+
outlineColor: cuboid.outlineColor,
|
|
19211
|
+
};
|
|
19212
|
+
});
|
|
19213
|
+
return visibleFaces.filter((visibleFace) => visibleFace !== null);
|
|
19214
|
+
}
|
|
19215
|
+
/**
|
|
19216
|
+
* Draws one projected textured face by tessellating its texture cells into quads.
|
|
19217
|
+
*
|
|
19218
|
+
* @param context Canvas 2D context.
|
|
19219
|
+
* @param face Visible projected face.
|
|
19220
|
+
*
|
|
19221
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19222
|
+
*/
|
|
19223
|
+
function drawTexturedProjectedFace(context, face) {
|
|
19224
|
+
var _a;
|
|
19225
|
+
const rows = face.texture.length;
|
|
19226
|
+
const columns = ((_a = face.texture[0]) === null || _a === void 0 ? void 0 : _a.length) || 0;
|
|
19227
|
+
if (rows === 0 || columns === 0) {
|
|
19228
|
+
return;
|
|
18910
19229
|
}
|
|
18911
|
-
|
|
18912
|
-
|
|
18913
|
-
|
|
18914
|
-
|
|
18915
|
-
|
|
18916
|
-
|
|
18917
|
-
|
|
19230
|
+
for (let rowIndex = 0; rowIndex < rows; rowIndex++) {
|
|
19231
|
+
for (let columnIndex = 0; columnIndex < columns; columnIndex++) {
|
|
19232
|
+
const startX = columnIndex / columns;
|
|
19233
|
+
const endX = (columnIndex + 1) / columns;
|
|
19234
|
+
const startY = rowIndex / rows;
|
|
19235
|
+
const endY = (rowIndex + 1) / rows;
|
|
19236
|
+
drawProjectedQuad(context, [
|
|
19237
|
+
interpolateProjectedQuad(face.corners, startX, startY),
|
|
19238
|
+
interpolateProjectedQuad(face.corners, endX, startY),
|
|
19239
|
+
interpolateProjectedQuad(face.corners, endX, endY),
|
|
19240
|
+
interpolateProjectedQuad(face.corners, startX, endY),
|
|
19241
|
+
], face.texture[rowIndex][columnIndex]);
|
|
18918
19242
|
}
|
|
18919
19243
|
}
|
|
18920
|
-
|
|
18921
|
-
|
|
18922
|
-
|
|
18923
|
-
|
|
18924
|
-
|
|
18925
|
-
|
|
18926
|
-
|
|
18927
|
-
|
|
18928
|
-
|
|
18929
|
-
|
|
18930
|
-
|
|
19244
|
+
if (face.lightIntensity > 0) {
|
|
19245
|
+
drawProjectedQuad(context, face.corners, `rgba(255, 255, 255, ${0.15 * face.lightIntensity})`);
|
|
19246
|
+
}
|
|
19247
|
+
else if (face.lightIntensity < 0) {
|
|
19248
|
+
drawProjectedQuad(context, face.corners, `rgba(0, 0, 0, ${0.22 * Math.abs(face.lightIntensity)})`);
|
|
19249
|
+
}
|
|
19250
|
+
context.save();
|
|
19251
|
+
context.beginPath();
|
|
19252
|
+
context.moveTo(face.corners[0].x, face.corners[0].y);
|
|
19253
|
+
for (let cornerIndex = 1; cornerIndex < face.corners.length; cornerIndex++) {
|
|
19254
|
+
context.lineTo(face.corners[cornerIndex].x, face.corners[cornerIndex].y);
|
|
19255
|
+
}
|
|
19256
|
+
context.closePath();
|
|
19257
|
+
context.strokeStyle = face.outlineColor;
|
|
19258
|
+
context.lineWidth = Math.max(1.1, getProjectedQuadPerimeter(face.corners) * 0.0045);
|
|
19259
|
+
context.lineJoin = 'round';
|
|
19260
|
+
context.stroke();
|
|
19261
|
+
context.restore();
|
|
18931
19262
|
}
|
|
18932
19263
|
/**
|
|
18933
|
-
*
|
|
19264
|
+
* Draws one filled projected quad.
|
|
18934
19265
|
*
|
|
18935
|
-
* @param
|
|
18936
|
-
* @param
|
|
18937
|
-
* @
|
|
19266
|
+
* @param context Canvas 2D context.
|
|
19267
|
+
* @param corners Quad corners in clockwise order.
|
|
19268
|
+
* @param fillStyle CSS fill style.
|
|
18938
19269
|
*
|
|
18939
|
-
* @private helper of `
|
|
19270
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
18940
19271
|
*/
|
|
18941
|
-
function
|
|
18942
|
-
|
|
18943
|
-
|
|
18944
|
-
|
|
18945
|
-
|
|
18946
|
-
|
|
18947
|
-
|
|
19272
|
+
function drawProjectedQuad(context, corners, fillStyle) {
|
|
19273
|
+
context.beginPath();
|
|
19274
|
+
context.moveTo(corners[0].x, corners[0].y);
|
|
19275
|
+
context.lineTo(corners[1].x, corners[1].y);
|
|
19276
|
+
context.lineTo(corners[2].x, corners[2].y);
|
|
19277
|
+
context.lineTo(corners[3].x, corners[3].y);
|
|
19278
|
+
context.closePath();
|
|
19279
|
+
context.fillStyle = fillStyle;
|
|
19280
|
+
context.fill();
|
|
19281
|
+
}
|
|
19282
|
+
/**
|
|
19283
|
+
* Interpolates one point inside a projected quad across both quad axes.
|
|
19284
|
+
*
|
|
19285
|
+
* @param corners Quad corners in clockwise order.
|
|
19286
|
+
* @param horizontalRatio Horizontal ratio in the range `[0, 1]`.
|
|
19287
|
+
* @param verticalRatio Vertical ratio in the range `[0, 1]`.
|
|
19288
|
+
* @returns Interpolated projected point.
|
|
19289
|
+
*
|
|
19290
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19291
|
+
*/
|
|
19292
|
+
function interpolateProjectedQuad(corners, horizontalRatio, verticalRatio) {
|
|
19293
|
+
const topPoint = interpolateProjectedPoint(corners[0], corners[1], horizontalRatio);
|
|
19294
|
+
const bottomPoint = interpolateProjectedPoint(corners[3], corners[2], horizontalRatio);
|
|
19295
|
+
return interpolateProjectedPoint(topPoint, bottomPoint, verticalRatio);
|
|
19296
|
+
}
|
|
19297
|
+
/**
|
|
19298
|
+
* Interpolates between two projected points.
|
|
19299
|
+
*
|
|
19300
|
+
* @param startPoint Start point.
|
|
19301
|
+
* @param endPoint End point.
|
|
19302
|
+
* @param ratio Interpolation ratio in the range `[0, 1]`.
|
|
19303
|
+
* @returns Interpolated projected point.
|
|
19304
|
+
*
|
|
19305
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19306
|
+
*/
|
|
19307
|
+
function interpolateProjectedPoint(startPoint, endPoint, ratio) {
|
|
19308
|
+
return {
|
|
19309
|
+
x: startPoint.x + (endPoint.x - startPoint.x) * ratio,
|
|
19310
|
+
y: startPoint.y + (endPoint.y - startPoint.y) * ratio,
|
|
19311
|
+
z: startPoint.z + (endPoint.z - startPoint.z) * ratio,
|
|
19312
|
+
};
|
|
19313
|
+
}
|
|
19314
|
+
/**
|
|
19315
|
+
* Projects one rotated scene point into canvas coordinates.
|
|
19316
|
+
*
|
|
19317
|
+
* @param point Scene point.
|
|
19318
|
+
* @param size Canvas size in CSS pixels.
|
|
19319
|
+
* @param sceneCenterX Horizontal scene center.
|
|
19320
|
+
* @param sceneCenterY Vertical scene center.
|
|
19321
|
+
* @returns Projected point.
|
|
19322
|
+
*
|
|
19323
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19324
|
+
*/
|
|
19325
|
+
function projectScenePoint(point, size, sceneCenterX, sceneCenterY) {
|
|
19326
|
+
const cameraDistance = size * CAMERA_DISTANCE_RATIO;
|
|
19327
|
+
const perspectiveScale = cameraDistance / Math.max(cameraDistance - point.z, cameraDistance * 0.35);
|
|
19328
|
+
return {
|
|
19329
|
+
x: sceneCenterX + point.x * perspectiveScale,
|
|
19330
|
+
y: sceneCenterY + point.y * perspectiveScale,
|
|
19331
|
+
z: point.z,
|
|
19332
|
+
};
|
|
19333
|
+
}
|
|
19334
|
+
/**
|
|
19335
|
+
* Applies the local cuboid rotations and translation to one scene point.
|
|
19336
|
+
*
|
|
19337
|
+
* @param localPoint Point in cuboid-local space.
|
|
19338
|
+
* @param center Cuboid center in scene space.
|
|
19339
|
+
* @param rotationX Cuboid pitch in radians.
|
|
19340
|
+
* @param rotationY Cuboid yaw in radians.
|
|
19341
|
+
* @returns Transformed scene-space point.
|
|
19342
|
+
*
|
|
19343
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19344
|
+
*/
|
|
19345
|
+
function transformScenePoint(localPoint, center, rotationX, rotationY) {
|
|
19346
|
+
const yawedPoint = rotatePointAroundY(localPoint, rotationY);
|
|
19347
|
+
const pitchedPoint = rotatePointAroundX(yawedPoint, rotationX);
|
|
19348
|
+
return {
|
|
19349
|
+
x: center.x + pitchedPoint.x,
|
|
19350
|
+
y: center.y + pitchedPoint.y,
|
|
19351
|
+
z: center.z + pitchedPoint.z,
|
|
19352
|
+
};
|
|
19353
|
+
}
|
|
19354
|
+
/**
|
|
19355
|
+
* Rotates one point around the local Y axis.
|
|
19356
|
+
*
|
|
19357
|
+
* @param point Source point.
|
|
19358
|
+
* @param angle Rotation angle in radians.
|
|
19359
|
+
* @returns Rotated point.
|
|
19360
|
+
*
|
|
19361
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19362
|
+
*/
|
|
19363
|
+
function rotatePointAroundY(point, angle) {
|
|
19364
|
+
const cosine = Math.cos(angle);
|
|
19365
|
+
const sine = Math.sin(angle);
|
|
19366
|
+
return {
|
|
19367
|
+
x: point.x * cosine + point.z * sine,
|
|
19368
|
+
y: point.y,
|
|
19369
|
+
z: -point.x * sine + point.z * cosine,
|
|
19370
|
+
};
|
|
19371
|
+
}
|
|
19372
|
+
/**
|
|
19373
|
+
* Rotates one point around the local X axis.
|
|
19374
|
+
*
|
|
19375
|
+
* @param point Source point.
|
|
19376
|
+
* @param angle Rotation angle in radians.
|
|
19377
|
+
* @returns Rotated point.
|
|
19378
|
+
*
|
|
19379
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19380
|
+
*/
|
|
19381
|
+
function rotatePointAroundX(point, angle) {
|
|
19382
|
+
const cosine = Math.cos(angle);
|
|
19383
|
+
const sine = Math.sin(angle);
|
|
19384
|
+
return {
|
|
19385
|
+
x: point.x,
|
|
19386
|
+
y: point.y * cosine - point.z * sine,
|
|
19387
|
+
z: point.y * sine + point.z * cosine,
|
|
19388
|
+
};
|
|
19389
|
+
}
|
|
19390
|
+
/**
|
|
19391
|
+
* Subtracts one 3D point from another.
|
|
19392
|
+
*
|
|
19393
|
+
* @param leftPoint Left point.
|
|
19394
|
+
* @param rightPoint Right point.
|
|
19395
|
+
* @returns Difference vector.
|
|
19396
|
+
*
|
|
19397
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19398
|
+
*/
|
|
19399
|
+
function subtractPoint3D(leftPoint, rightPoint) {
|
|
19400
|
+
return {
|
|
19401
|
+
x: leftPoint.x - rightPoint.x,
|
|
19402
|
+
y: leftPoint.y - rightPoint.y,
|
|
19403
|
+
z: leftPoint.z - rightPoint.z,
|
|
19404
|
+
};
|
|
19405
|
+
}
|
|
19406
|
+
/**
|
|
19407
|
+
* Computes the 3D cross product of two vectors.
|
|
19408
|
+
*
|
|
19409
|
+
* @param leftVector Left vector.
|
|
19410
|
+
* @param rightVector Right vector.
|
|
19411
|
+
* @returns Cross product.
|
|
19412
|
+
*
|
|
19413
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19414
|
+
*/
|
|
19415
|
+
function crossProduct3D(leftVector, rightVector) {
|
|
19416
|
+
return {
|
|
19417
|
+
x: leftVector.y * rightVector.z - leftVector.z * rightVector.y,
|
|
19418
|
+
y: leftVector.z * rightVector.x - leftVector.x * rightVector.z,
|
|
19419
|
+
z: leftVector.x * rightVector.y - leftVector.y * rightVector.x,
|
|
19420
|
+
};
|
|
19421
|
+
}
|
|
19422
|
+
/**
|
|
19423
|
+
* Computes the 3D dot product of two vectors.
|
|
19424
|
+
*
|
|
19425
|
+
* @param leftVector Left vector.
|
|
19426
|
+
* @param rightVector Right vector.
|
|
19427
|
+
* @returns Dot product.
|
|
19428
|
+
*
|
|
19429
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19430
|
+
*/
|
|
19431
|
+
function dotProduct3D(leftVector, rightVector) {
|
|
19432
|
+
return leftVector.x * rightVector.x + leftVector.y * rightVector.y + leftVector.z * rightVector.z;
|
|
19433
|
+
}
|
|
19434
|
+
/**
|
|
19435
|
+
* Normalizes one 3D vector while keeping zero vectors stable.
|
|
19436
|
+
*
|
|
19437
|
+
* @param vector Source vector.
|
|
19438
|
+
* @returns Normalized vector.
|
|
19439
|
+
*
|
|
19440
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19441
|
+
*/
|
|
19442
|
+
function normalizeVector3(vector) {
|
|
19443
|
+
const length = Math.hypot(vector.x, vector.y, vector.z);
|
|
19444
|
+
if (length === 0) {
|
|
19445
|
+
return vector;
|
|
18948
19446
|
}
|
|
18949
|
-
|
|
18950
|
-
|
|
18951
|
-
|
|
19447
|
+
return {
|
|
19448
|
+
x: vector.x / length,
|
|
19449
|
+
y: vector.y / length,
|
|
19450
|
+
z: vector.z / length,
|
|
19451
|
+
};
|
|
19452
|
+
}
|
|
19453
|
+
/**
|
|
19454
|
+
* Clamps one number into the provided range.
|
|
19455
|
+
*
|
|
19456
|
+
* @param value Input value.
|
|
19457
|
+
* @param minimumValue Inclusive lower bound.
|
|
19458
|
+
* @param maximumValue Inclusive upper bound.
|
|
19459
|
+
* @returns Clamped value.
|
|
19460
|
+
*
|
|
19461
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19462
|
+
*/
|
|
19463
|
+
function clampNumber$1(value, minimumValue, maximumValue) {
|
|
19464
|
+
return Math.min(maximumValue, Math.max(minimumValue, value));
|
|
19465
|
+
}
|
|
19466
|
+
/**
|
|
19467
|
+
* Measures the perimeter of one projected quad.
|
|
19468
|
+
*
|
|
19469
|
+
* @param corners Quad corners.
|
|
19470
|
+
* @returns Perimeter length.
|
|
19471
|
+
*
|
|
19472
|
+
* @private helper of `minecraft2AvatarVisual`
|
|
19473
|
+
*/
|
|
19474
|
+
function getProjectedQuadPerimeter(corners) {
|
|
19475
|
+
let perimeter = 0;
|
|
19476
|
+
for (let cornerIndex = 0; cornerIndex < corners.length; cornerIndex++) {
|
|
19477
|
+
const currentCorner = corners[cornerIndex];
|
|
19478
|
+
const nextCorner = corners[(cornerIndex + 1) % corners.length];
|
|
19479
|
+
perimeter += Math.hypot(nextCorner.x - currentCorner.x, nextCorner.y - currentCorner.y);
|
|
18952
19480
|
}
|
|
18953
|
-
|
|
18954
|
-
texture[4][6] = palette.accent;
|
|
18955
|
-
texture[5][2] = palette.highlight;
|
|
18956
|
-
texture[5][5] = palette.highlight;
|
|
18957
|
-
return texture;
|
|
19481
|
+
return perimeter;
|
|
18958
19482
|
}
|
|
18959
19483
|
|
|
18960
19484
|
/* eslint-disable no-magic-numbers */
|
|
@@ -20559,6 +21083,7 @@ const AVATAR_VISUALS = [
|
|
|
20559
21083
|
octopus3AvatarVisual,
|
|
20560
21084
|
asciiOctopusAvatarVisual,
|
|
20561
21085
|
minecraftAvatarVisual,
|
|
21086
|
+
minecraft2AvatarVisual,
|
|
20562
21087
|
fractalAvatarVisual,
|
|
20563
21088
|
orbAvatarVisual,
|
|
20564
21089
|
];
|
|
@@ -21861,7 +22386,11 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
21861
22386
|
// Create new system message with persona at the beginning
|
|
21862
22387
|
// Format: "You are {agentName}\n{personaContent}"
|
|
21863
22388
|
// The # PERSONA comment will be removed later by removeCommentsFromSystemMessage
|
|
21864
|
-
const personaSection =
|
|
22389
|
+
const personaSection = spaceTrim$1((block) => `
|
|
22390
|
+
# PERSONA
|
|
22391
|
+
You are ${agentName}
|
|
22392
|
+
${block(mergedPersonaContent)}
|
|
22393
|
+
`);
|
|
21865
22394
|
const newSystemMessage = cleanedMessage ? `${personaSection}\n\n${cleanedMessage}` : personaSection;
|
|
21866
22395
|
return {
|
|
21867
22396
|
...requirements,
|
|
@@ -22763,7 +23292,10 @@ function buildTeamSystemMessageBody(teamEntries) {
|
|
|
22763
23292
|
*/
|
|
22764
23293
|
function buildTeamToolDescription(entry) {
|
|
22765
23294
|
const detailLines = collectTeamEntryDetails(entry).map(({ label, content }) => `${label}: ${content}`);
|
|
22766
|
-
return
|
|
23295
|
+
return spaceTrim$1((block) => `
|
|
23296
|
+
Consult teammate ${entry.teammate.label}
|
|
23297
|
+
${block(detailLines.join('\n'))}
|
|
23298
|
+
`);
|
|
22767
23299
|
}
|
|
22768
23300
|
/**
|
|
22769
23301
|
* Collects structured teammate details that should stay visible to the model.
|
|
@@ -28260,7 +28792,10 @@ function createListedTimeoutsAssistantMessage(options) {
|
|
|
28260
28792
|
if (hiddenCount > 0) {
|
|
28261
28793
|
summaryRows.push(`...and ${hiddenCount} more.`);
|
|
28262
28794
|
}
|
|
28263
|
-
return
|
|
28795
|
+
return spaceTrim$1((block) => `
|
|
28796
|
+
Found ${options.total} ${options.total === 1 ? 'timeout' : 'timeouts'}:
|
|
28797
|
+
${block(summaryRows.join('\n'))}
|
|
28798
|
+
`);
|
|
28264
28799
|
}
|
|
28265
28800
|
/**
|
|
28266
28801
|
* Formats one timeout row for assistant-visible timeout listings.
|
|
@@ -34083,11 +34618,11 @@ function formatChatAttachmentContext(attachments) {
|
|
|
34083
34618
|
if (attachments.length === 0) {
|
|
34084
34619
|
return '';
|
|
34085
34620
|
}
|
|
34086
|
-
return
|
|
34087
|
-
|
|
34088
|
-
|
|
34089
|
-
|
|
34090
|
-
|
|
34621
|
+
return spaceTrim$1((block) => `
|
|
34622
|
+
${CHAT_ATTACHMENTS_HEADING}
|
|
34623
|
+
${block(attachments.map((attachment) => formatChatAttachmentLine(attachment)).join('\n'))}
|
|
34624
|
+
${CHAT_ATTACHMENTS_INSTRUCTION}
|
|
34625
|
+
`);
|
|
34091
34626
|
}
|
|
34092
34627
|
|
|
34093
34628
|
/**
|
|
@@ -34328,24 +34863,24 @@ function formatResolvedChatAttachmentContent(contentResolution) {
|
|
|
34328
34863
|
: ''}`
|
|
34329
34864
|
: null;
|
|
34330
34865
|
const warningsLine = contentResolution.warnings.length > 0 ? `Warnings: ${contentResolution.warnings.join(' | ')}` : null;
|
|
34331
|
-
|
|
34866
|
+
const metadataLines = [decodingLine, warningsLine].filter((line) => Boolean(line)).join('\n');
|
|
34867
|
+
const resolvedContent = contentResolution.content;
|
|
34868
|
+
if (!resolvedContent) {
|
|
34332
34869
|
const reason = contentResolution.reason || 'content unavailable';
|
|
34333
|
-
return
|
|
34334
|
-
|
|
34335
|
-
|
|
34870
|
+
return spaceTrim$1((block) => `
|
|
34871
|
+
- ${attachmentLabel}: ${reason}. URL: ${contentResolution.attachment.url}
|
|
34872
|
+
${block(metadataLines)}
|
|
34873
|
+
`);
|
|
34336
34874
|
}
|
|
34337
34875
|
const truncatedLabel = contentResolution.isTruncated ? ' [truncated]' : '';
|
|
34338
|
-
return
|
|
34339
|
-
|
|
34340
|
-
|
|
34341
|
-
|
|
34342
|
-
|
|
34343
|
-
|
|
34344
|
-
|
|
34345
|
-
|
|
34346
|
-
]
|
|
34347
|
-
.filter(Boolean)
|
|
34348
|
-
.join('\n');
|
|
34876
|
+
return spaceTrim$1((block) => `
|
|
34877
|
+
File: ${attachmentLabel}${truncatedLabel}
|
|
34878
|
+
URL: ${contentResolution.attachment.url}
|
|
34879
|
+
${block(metadataLines)}
|
|
34880
|
+
\`\`\`text
|
|
34881
|
+
${block(resolvedContent)}
|
|
34882
|
+
\`\`\`
|
|
34883
|
+
`);
|
|
34349
34884
|
}
|
|
34350
34885
|
/**
|
|
34351
34886
|
* Formats inline attachment-content context section for the model.
|
|
@@ -34359,11 +34894,14 @@ function formatChatAttachmentContentContext(resolvedContents) {
|
|
|
34359
34894
|
if (resolvedContents.length === 0) {
|
|
34360
34895
|
return '';
|
|
34361
34896
|
}
|
|
34362
|
-
return
|
|
34363
|
-
|
|
34364
|
-
|
|
34365
|
-
|
|
34366
|
-
|
|
34897
|
+
return spaceTrim$1((block) => `
|
|
34898
|
+
${CHAT_ATTACHMENT_CONTENT_HEADING}
|
|
34899
|
+
${CHAT_ATTACHMENT_CONTENT_INSTRUCTION}
|
|
34900
|
+
|
|
34901
|
+
${block(resolvedContents
|
|
34902
|
+
.map((resolvedContent) => formatResolvedChatAttachmentContent(resolvedContent))
|
|
34903
|
+
.join('\n\n'))}
|
|
34904
|
+
`);
|
|
34367
34905
|
}
|
|
34368
34906
|
|
|
34369
34907
|
/**
|
|
@@ -35508,9 +36046,11 @@ class OpenAiCompatibleUnsupportedParameterRetrier {
|
|
|
35508
36046
|
* Creates the retry-history error message shared by all OpenAI-compatible model variants.
|
|
35509
36047
|
*/
|
|
35510
36048
|
createAttemptHistoryError(finalErrorMessage) {
|
|
35511
|
-
return new PipelineExecutionError(
|
|
35512
|
-
|
|
35513
|
-
|
|
36049
|
+
return new PipelineExecutionError(spaceTrim$1((block) => `
|
|
36050
|
+
All attempts failed. Attempt history:
|
|
36051
|
+
${block(formatUnsupportedParameterAttemptHistory(this.attemptStack))}
|
|
36052
|
+
Final error: ${finalErrorMessage}
|
|
36053
|
+
`));
|
|
35514
36054
|
}
|
|
35515
36055
|
}
|
|
35516
36056
|
|
|
@@ -38104,7 +38644,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
38104
38644
|
});
|
|
38105
38645
|
}
|
|
38106
38646
|
let vectorStoreId = cachedVectorStoreId;
|
|
38107
|
-
if (
|
|
38647
|
+
if (!vectorStoreId && knowledgeSources && knowledgeSources.length > 0) {
|
|
38108
38648
|
const vectorStoreResult = await this.createVectorStoreWithKnowledgeSources({
|
|
38109
38649
|
client: await this.getClient(),
|
|
38110
38650
|
name,
|
|
@@ -38113,19 +38653,13 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
38113
38653
|
});
|
|
38114
38654
|
vectorStoreId = vectorStoreResult.vectorStoreId;
|
|
38115
38655
|
}
|
|
38116
|
-
else if (
|
|
38656
|
+
else if (vectorStoreId && this.options.isVerbose) {
|
|
38117
38657
|
console.info('[🤰]', 'Using cached vector store for AgentKit agent', {
|
|
38118
38658
|
name,
|
|
38119
38659
|
vectorStoreId,
|
|
38120
38660
|
});
|
|
38121
38661
|
}
|
|
38122
|
-
|
|
38123
|
-
vectorStoreId = undefined;
|
|
38124
|
-
}
|
|
38125
|
-
const agentKitTools = this.buildAgentKitTools({
|
|
38126
|
-
tools,
|
|
38127
|
-
vectorStoreId,
|
|
38128
|
-
});
|
|
38662
|
+
const agentKitTools = this.buildAgentKitTools({ tools, vectorStoreId });
|
|
38129
38663
|
const openAiAgentKitAgent = new Agent$1({
|
|
38130
38664
|
name,
|
|
38131
38665
|
model: this.agentKitModelName,
|
|
@@ -38144,7 +38678,7 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
38144
38678
|
name,
|
|
38145
38679
|
model: this.agentKitModelName,
|
|
38146
38680
|
toolCount: agentKitTools.length,
|
|
38147
|
-
hasVectorStore:
|
|
38681
|
+
hasVectorStore: Boolean(vectorStoreId),
|
|
38148
38682
|
});
|
|
38149
38683
|
}
|
|
38150
38684
|
return preparedAgent;
|
|
@@ -38643,12 +39177,6 @@ class OpenAiAgentKitExecutionTools extends OpenAiVectorStoreHandler {
|
|
|
38643
39177
|
get agentKitOptions() {
|
|
38644
39178
|
return this.options;
|
|
38645
39179
|
}
|
|
38646
|
-
/**
|
|
38647
|
-
* Returns true when hosted OpenAI vector-store search should back `knowledgeSources`.
|
|
38648
|
-
*/
|
|
38649
|
-
get isNativeKnowledgeSearchEnabled() {
|
|
38650
|
-
return this.agentKitOptions.isNativeKnowledgeSearchEnabled !== false;
|
|
38651
|
-
}
|
|
38652
39180
|
/**
|
|
38653
39181
|
* Discriminant for type guards.
|
|
38654
39182
|
*/
|