@promptbook/core 0.112.0-41 → 0.112.0-43
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/README.md +10 -3
- package/esm/index.es.js +174 -62
- package/esm/index.es.js.map +1 -1
- package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +1 -1
- package/esm/src/cli/cli-commands/coder/getTypescriptModule.d.ts +19 -0
- package/esm/src/cli/cli-commands/coder/getTypescriptModule.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/coder/mergeStringRecordJsonFile.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/coder/verify.test.d.ts +1 -0
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +2 -14
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.d.ts +40 -0
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.test.d.ts +1 -0
- package/esm/src/llm-providers/agent/Agent.test.d.ts +1 -0
- package/esm/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +4 -0
- package/esm/src/llm-providers/agent/AgentOptions.d.ts +8 -0
- package/esm/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +9 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +174 -62
- package/umd/index.umd.js.map +1 -1
- package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +1 -1
- package/umd/src/cli/cli-commands/coder/getTypescriptModule.d.ts +19 -0
- package/umd/src/cli/cli-commands/coder/getTypescriptModule.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/coder/mergeStringRecordJsonFile.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/coder/verify.test.d.ts +1 -0
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +2 -14
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.d.ts +40 -0
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.test.d.ts +1 -0
- package/umd/src/llm-providers/agent/Agent.test.d.ts +1 -0
- package/umd/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +4 -0
- package/umd/src/llm-providers/agent/AgentOptions.d.ts +8 -0
- package/umd/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +9 -0
- package/umd/src/version.d.ts +1 -1
package/README.md
CHANGED
|
@@ -688,6 +688,7 @@ Prompts marked with `[-]` are not ready yet, prompts containing `@@@` are treate
|
|
|
688
688
|
- **Reasoning control:** `--thinking-level low|medium|high|xhigh` for supported runners
|
|
689
689
|
- **Interactive or unattended runs:** default wait mode, or `--no-wait` for batch execution
|
|
690
690
|
- **Git safety:** clean working tree check by default, optional `--ignore-git-changes`
|
|
691
|
+
- **Opt-in remote pushes:** commits stay local unless you explicitly pass `--auto-push`
|
|
691
692
|
- **Prompt triage:** `--priority` to process only more important tasks first
|
|
692
693
|
- **Failure logging:** failed runs write a neighboring `.error.log`
|
|
693
694
|
- **Line-ending normalization:** changed files are normalized back to LF by default
|
|
@@ -705,6 +706,8 @@ npx ts-node ./src/cli/test/ptbk.ts coder generate-boilerplates --template prompt
|
|
|
705
706
|
|
|
706
707
|
npx ts-node ./src/cli/test/ptbk.ts coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md
|
|
707
708
|
|
|
709
|
+
npx ts-node ./src/cli/test/ptbk.ts coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --auto-push
|
|
710
|
+
|
|
708
711
|
npx ts-node ./src/cli/test/ptbk.ts coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --ignore-git-changes --no-wait
|
|
709
712
|
|
|
710
713
|
npx ts-node ./src/cli/test/ptbk.ts coder find-refactor-candidates
|
|
@@ -727,9 +730,11 @@ npx ptbk coder generate-boilerplates
|
|
|
727
730
|
|
|
728
731
|
npx ptbk coder generate-boilerplates --template prompts/templates/common.md
|
|
729
732
|
|
|
730
|
-
npx ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md
|
|
733
|
+
npx ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --test npm run test
|
|
734
|
+
|
|
735
|
+
npx ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --auto-push
|
|
731
736
|
|
|
732
|
-
npx ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --ignore-git-changes --no-wait
|
|
737
|
+
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
|
|
733
738
|
|
|
734
739
|
npx ptbk coder find-refactor-candidates
|
|
735
740
|
|
|
@@ -746,7 +751,7 @@ npx ptbk coder verify
|
|
|
746
751
|
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------ | ---- | ----- | ------------------------------------------------------------------------ |
|
|
747
752
|
| `ptbk coder init` | Creates `prompts/`, `prompts/done/`, the project-generic template files materialized in `prompts/templates/` (currently `common.md`), and a starter `AGENTS.md`; ensures `.env` contains `CODING_AGENT_GIT_NAME`, `CODING_AGENT_GIT_EMAIL`, and `CODING_AGENT_GIT_SIGNING_KEY`; adds helper coder scripts to `package.json`; ensures `.gitignore` contains `/.tmp`; and configures `.vscode/settings.json` to save pasted prompt images into `prompts/screenshots/`. |
|
|
748
753
|
| `ptbk coder generate-boilerplates` | Creates new prompt markdown files with fresh emoji tags so you can quickly fill in coding tasks; `--template` accepts either a built-in alias or a markdown file path relative to the project root. |
|
|
749
|
-
| `ptbk coder run` | Picks the next ready prompt, appends optional context, runs it through the selected coding agent, marks success or failure,
|
|
754
|
+
| `ptbk coder run` | Picks the next ready prompt, appends optional context, runs it through the selected coding agent, can optionally verify each attempt with a shell test command and feed failing output back for retries, then marks success or failure, commits the result, and pushes only when `--auto-push` is enabled. |
|
|
750
755
|
| `ptbk coder find-refactor-candidates` | Scans the repository for oversized or overpacked files and writes prompt files for likely refactors; `--level <xlow | low | medium | high | xhigh | extreme>` ranges from a very benevolent scan to a very aggressive sweep. |
|
|
751
756
|
| `ptbk coder verify` | Walks through completed prompts, archives truly finished work, and adds follow-up repair prompts for unfinished results. |
|
|
752
757
|
|
|
@@ -757,12 +762,14 @@ npx ptbk coder verify
|
|
|
757
762
|
| `--agent <name>` | Selects the coding backend. |
|
|
758
763
|
| `--model <model>` | Chooses the runner model; required for `openai-codex` and `gemini`, optional for `github-copilot`. |
|
|
759
764
|
| `--context <text-or-file>` | Appends extra instructions inline or from a file like `AGENTS.md`. |
|
|
765
|
+
| `--test <command>` | Runs a verification command after each prompt attempt and feeds failing output back for retries. |
|
|
760
766
|
| `--thinking-level <level>` | Sets reasoning effort for supported runners. |
|
|
761
767
|
| `--no-wait` | Skips interactive pauses between prompts for unattended execution. |
|
|
762
768
|
| `--ignore-git-changes` | Disables the clean-working-tree guard. |
|
|
763
769
|
| `--priority <n>` | Runs only prompts at or above the given priority. |
|
|
764
770
|
| `--dry-run` | Prints which prompts are ready instead of executing them. |
|
|
765
771
|
| `--allow-credits` | Lets OpenAI Codex spend credits when required. |
|
|
772
|
+
| `--auto-push` | Pushes each successful coding-agent commit to the configured remote. |
|
|
766
773
|
| `--auto-migrate` | Runs testing-server database migrations after each successful prompt. |
|
|
767
774
|
|
|
768
775
|
#### Typical usage pattern
|
package/esm/index.es.js
CHANGED
|
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-43';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -7868,7 +7868,7 @@ function createEmptyAgentModelRequirements() {
|
|
|
7868
7868
|
systemMessage: '',
|
|
7869
7869
|
promptSuffix: '',
|
|
7870
7870
|
// modelName: 'gpt-5',
|
|
7871
|
-
modelName: '
|
|
7871
|
+
modelName: 'gpt-5.4-mini',
|
|
7872
7872
|
temperature: 0.7,
|
|
7873
7873
|
topP: 0.9,
|
|
7874
7874
|
topK: 50,
|
|
@@ -15056,6 +15056,15 @@ const teamToolFunctions = {};
|
|
|
15056
15056
|
* Map of team tool titles.
|
|
15057
15057
|
*/
|
|
15058
15058
|
const teamToolTitles = {};
|
|
15059
|
+
/**
|
|
15060
|
+
* Shared TEAM usage rules appended ahead of teammate listings.
|
|
15061
|
+
*
|
|
15062
|
+
* @private
|
|
15063
|
+
*/
|
|
15064
|
+
const TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES = [
|
|
15065
|
+
'- If a teammate is relevant to the request, consult that teammate using the matching tool.',
|
|
15066
|
+
'- Do not ask the user for information that a listed teammate can provide directly.',
|
|
15067
|
+
];
|
|
15059
15068
|
/**
|
|
15060
15069
|
* Constant for remote agents by Url.
|
|
15061
15070
|
*/
|
|
@@ -15145,12 +15154,9 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
15145
15154
|
if (updatedTools.some((tool) => tool.name === entry.toolName)) {
|
|
15146
15155
|
continue;
|
|
15147
15156
|
}
|
|
15148
|
-
const toolDescription = entry.description
|
|
15149
|
-
? `Consult teammate ${entry.teammate.label}\n${entry.description}`
|
|
15150
|
-
: `Consult teammate ${entry.teammate.label}`;
|
|
15151
15157
|
updatedTools.push({
|
|
15152
15158
|
name: entry.toolName,
|
|
15153
|
-
description:
|
|
15159
|
+
description: buildTeamToolDescription(entry),
|
|
15154
15160
|
parameters: {
|
|
15155
15161
|
type: 'object',
|
|
15156
15162
|
properties: {
|
|
@@ -15219,22 +15225,72 @@ function resolveTeamTeammateLabels(teamContent, teammates) {
|
|
|
15219
15225
|
/**
|
|
15220
15226
|
* Builds the textual TEAM section body for the final system message.
|
|
15221
15227
|
*
|
|
15222
|
-
* Each teammate is listed with its tool name
|
|
15223
|
-
* Uses `spaceTrim` to ensure consistent whitespace and indentation.
|
|
15228
|
+
* Each teammate is listed with its tool name, TEAM instructions, and optional profile hints.
|
|
15224
15229
|
*/
|
|
15225
15230
|
function buildTeamSystemMessageBody(teamEntries) {
|
|
15226
|
-
const lines =
|
|
15227
|
-
|
|
15228
|
-
|
|
15229
|
-
|
|
15230
|
-
|
|
15231
|
-
|
|
15232
|
-
|
|
15233
|
-
|
|
15234
|
-
|
|
15235
|
-
});
|
|
15231
|
+
const lines = [
|
|
15232
|
+
...TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES,
|
|
15233
|
+
'',
|
|
15234
|
+
...teamEntries.map((entry, index) => {
|
|
15235
|
+
const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
|
|
15236
|
+
const detailLines = collectTeamEntryDetails(entry).map(formatTeamEntryDetailLine);
|
|
15237
|
+
return [toolLine, ...detailLines].join('\n');
|
|
15238
|
+
}),
|
|
15239
|
+
];
|
|
15236
15240
|
return lines.join('\n');
|
|
15237
15241
|
}
|
|
15242
|
+
/**
|
|
15243
|
+
* Builds the model-visible description for one teammate tool.
|
|
15244
|
+
*
|
|
15245
|
+
* @private
|
|
15246
|
+
*/
|
|
15247
|
+
function buildTeamToolDescription(entry) {
|
|
15248
|
+
const detailLines = collectTeamEntryDetails(entry).map(({ label, content }) => `${label}: ${content}`);
|
|
15249
|
+
return [`Consult teammate ${entry.teammate.label}`, ...detailLines].join('\n');
|
|
15250
|
+
}
|
|
15251
|
+
/**
|
|
15252
|
+
* Collects structured teammate details that should stay visible to the model.
|
|
15253
|
+
*
|
|
15254
|
+
* @private
|
|
15255
|
+
*/
|
|
15256
|
+
function collectTeamEntryDetails(entry) {
|
|
15257
|
+
var _a;
|
|
15258
|
+
const details = [];
|
|
15259
|
+
const instructions = entry.teammate.instructions.trim();
|
|
15260
|
+
const description = ((_a = entry.description) === null || _a === void 0 ? void 0 : _a.trim()) || '';
|
|
15261
|
+
if (instructions) {
|
|
15262
|
+
details.push({
|
|
15263
|
+
label: 'TEAM instructions',
|
|
15264
|
+
content: instructions,
|
|
15265
|
+
});
|
|
15266
|
+
}
|
|
15267
|
+
if (description) {
|
|
15268
|
+
details.push({
|
|
15269
|
+
label: 'Profile',
|
|
15270
|
+
content: description,
|
|
15271
|
+
});
|
|
15272
|
+
}
|
|
15273
|
+
return details;
|
|
15274
|
+
}
|
|
15275
|
+
/**
|
|
15276
|
+
* Formats one teammate detail line for the TEAM system-message section.
|
|
15277
|
+
*
|
|
15278
|
+
* @private
|
|
15279
|
+
*/
|
|
15280
|
+
function formatTeamEntryDetailLine(detail) {
|
|
15281
|
+
return indentMultilineText(`${detail.label}: ${detail.content}`, ' ');
|
|
15282
|
+
}
|
|
15283
|
+
/**
|
|
15284
|
+
* Indents all lines of one potentially multi-line text block.
|
|
15285
|
+
*
|
|
15286
|
+
* @private
|
|
15287
|
+
*/
|
|
15288
|
+
function indentMultilineText(text, prefix) {
|
|
15289
|
+
return text
|
|
15290
|
+
.split('\n')
|
|
15291
|
+
.map((line) => `${prefix}${line}`)
|
|
15292
|
+
.join('\n');
|
|
15293
|
+
}
|
|
15238
15294
|
/**
|
|
15239
15295
|
* Registers tool function and title for a teammate tool.
|
|
15240
15296
|
*/
|
|
@@ -23457,6 +23513,60 @@ function stripMetaIdLines(agentSource) {
|
|
|
23457
23513
|
return strippedLines.join('\n');
|
|
23458
23514
|
}
|
|
23459
23515
|
|
|
23516
|
+
/**
|
|
23517
|
+
* Builds normalized insert rows for a newly created persisted agent.
|
|
23518
|
+
*
|
|
23519
|
+
* @param agentSource - Source content of the agent.
|
|
23520
|
+
* @param options - Optional folder placement, ordering, and visibility overrides.
|
|
23521
|
+
* @param createdAt - Shared creation timestamp used across all persisted rows.
|
|
23522
|
+
* @returns Insert rows and the created agent profile.
|
|
23523
|
+
*
|
|
23524
|
+
* @private shared persistence helper for `AgentCollectionInSupabase`
|
|
23525
|
+
*/
|
|
23526
|
+
function createAgentPersistenceRecords(agentSource, options = {}, createdAt = new Date().toISOString()) {
|
|
23527
|
+
const preparedAgentSource = prepareAgentSourceForPersistence(agentSource);
|
|
23528
|
+
const { agentProfile, agentSource: normalizedAgentSource } = preparedAgentSource;
|
|
23529
|
+
const permanentId = preparedAgentSource.permanentId || $randomBase58(14);
|
|
23530
|
+
const { agentName, agentHash } = agentProfile;
|
|
23531
|
+
const agentInsertRecord = {
|
|
23532
|
+
agentName,
|
|
23533
|
+
agentHash,
|
|
23534
|
+
permanentId,
|
|
23535
|
+
agentProfile,
|
|
23536
|
+
createdAt,
|
|
23537
|
+
updatedAt: null,
|
|
23538
|
+
promptbookEngineVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
23539
|
+
usage: ZERO_USAGE,
|
|
23540
|
+
agentSource: normalizedAgentSource,
|
|
23541
|
+
};
|
|
23542
|
+
if (options.folderId !== undefined) {
|
|
23543
|
+
agentInsertRecord.folderId = options.folderId;
|
|
23544
|
+
}
|
|
23545
|
+
if (options.sortOrder !== undefined) {
|
|
23546
|
+
agentInsertRecord.sortOrder = options.sortOrder;
|
|
23547
|
+
}
|
|
23548
|
+
if (options.visibility !== undefined) {
|
|
23549
|
+
agentInsertRecord.visibility = options.visibility;
|
|
23550
|
+
}
|
|
23551
|
+
return {
|
|
23552
|
+
createdAgent: {
|
|
23553
|
+
...agentProfile,
|
|
23554
|
+
permanentId,
|
|
23555
|
+
},
|
|
23556
|
+
agentInsertRecord,
|
|
23557
|
+
agentHistoryInsertRecord: {
|
|
23558
|
+
createdAt,
|
|
23559
|
+
agentName,
|
|
23560
|
+
permanentId,
|
|
23561
|
+
agentHash,
|
|
23562
|
+
previousAgentHash: null,
|
|
23563
|
+
agentSource: normalizedAgentSource,
|
|
23564
|
+
promptbookEngineVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
23565
|
+
versionName: null,
|
|
23566
|
+
},
|
|
23567
|
+
};
|
|
23568
|
+
}
|
|
23569
|
+
|
|
23460
23570
|
/**
|
|
23461
23571
|
* Normalizes optional history version name before persistence.
|
|
23462
23572
|
*
|
|
@@ -23580,52 +23690,18 @@ class AgentCollectionInSupabase /* TODO: [🌈][🐱🚀] implements AgentCol
|
|
|
23580
23690
|
* @param options - Optional folder placement and ordering data.
|
|
23581
23691
|
*/
|
|
23582
23692
|
async createAgent(agentSource, options = {}) {
|
|
23583
|
-
const
|
|
23584
|
-
const {
|
|
23585
|
-
|
|
23586
|
-
const { agentName, agentHash } = agentProfile;
|
|
23587
|
-
if (!permanentId) {
|
|
23588
|
-
permanentId = $randomBase58(14);
|
|
23589
|
-
}
|
|
23590
|
-
const insertPayload = {
|
|
23591
|
-
agentName,
|
|
23592
|
-
agentHash,
|
|
23593
|
-
permanentId,
|
|
23594
|
-
agentProfile,
|
|
23595
|
-
createdAt: new Date().toISOString(),
|
|
23596
|
-
updatedAt: null,
|
|
23597
|
-
promptbookEngineVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
23598
|
-
usage: ZERO_USAGE,
|
|
23599
|
-
agentSource: normalizedAgentSource,
|
|
23600
|
-
};
|
|
23601
|
-
if (options.folderId !== undefined) {
|
|
23602
|
-
insertPayload.folderId = options.folderId;
|
|
23603
|
-
}
|
|
23604
|
-
if (options.sortOrder !== undefined) {
|
|
23605
|
-
insertPayload.sortOrder = options.sortOrder;
|
|
23606
|
-
}
|
|
23607
|
-
if (options.visibility !== undefined) {
|
|
23608
|
-
insertPayload.visibility = options.visibility;
|
|
23609
|
-
}
|
|
23610
|
-
const insertAgentResult = await this.supabaseClient.from(this.getTableName('Agent')).insert(insertPayload);
|
|
23693
|
+
const createdAt = new Date().toISOString();
|
|
23694
|
+
const { createdAgent, agentInsertRecord, agentHistoryInsertRecord } = createAgentPersistenceRecords(agentSource, options, createdAt);
|
|
23695
|
+
const insertAgentResult = await this.supabaseClient.from(this.getTableName('Agent')).insert(agentInsertRecord);
|
|
23611
23696
|
if (insertAgentResult.error) {
|
|
23612
23697
|
throw new DatabaseError(spaceTrim((block) => `
|
|
23613
|
-
Error creating agent "${
|
|
23698
|
+
Error creating agent "${createdAgent.agentName}" in Supabase:
|
|
23614
23699
|
|
|
23615
23700
|
${block(insertAgentResult.error.message)}
|
|
23616
23701
|
`));
|
|
23617
23702
|
}
|
|
23618
|
-
await this.insertAgentHistoryRow(
|
|
23619
|
-
|
|
23620
|
-
agentName,
|
|
23621
|
-
permanentId,
|
|
23622
|
-
agentHash,
|
|
23623
|
-
previousAgentHash: null,
|
|
23624
|
-
agentSource: normalizedAgentSource,
|
|
23625
|
-
promptbookEngineVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
23626
|
-
versionName: null,
|
|
23627
|
-
});
|
|
23628
|
-
return { ...agentProfile, permanentId };
|
|
23703
|
+
await this.insertAgentHistoryRow(agentHistoryInsertRecord);
|
|
23704
|
+
return createdAgent;
|
|
23629
23705
|
}
|
|
23630
23706
|
/**
|
|
23631
23707
|
* Updates an existing agent in the collection
|
|
@@ -32681,7 +32757,7 @@ class OpenAiVectorStoreHandler extends OpenAiExecutionTools {
|
|
|
32681
32757
|
/**
|
|
32682
32758
|
* Constant for default agent kit model name.
|
|
32683
32759
|
*/
|
|
32684
|
-
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-
|
|
32760
|
+
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-mini';
|
|
32685
32761
|
/**
|
|
32686
32762
|
* Creates one structured log entry for streamed tool-call updates.
|
|
32687
32763
|
*
|
|
@@ -34747,6 +34823,7 @@ class AgentLlmExecutionTools {
|
|
|
34747
34823
|
* @param agentSource The agent source string that defines the agent's behavior
|
|
34748
34824
|
*/
|
|
34749
34825
|
constructor(options) {
|
|
34826
|
+
var _a;
|
|
34750
34827
|
this.options = options;
|
|
34751
34828
|
/**
|
|
34752
34829
|
* Cached model requirements to avoid re-parsing the agent source
|
|
@@ -34756,6 +34833,7 @@ class AgentLlmExecutionTools {
|
|
|
34756
34833
|
* Cached parsed agent information
|
|
34757
34834
|
*/
|
|
34758
34835
|
this._cachedAgentInfo = null;
|
|
34836
|
+
this.precomputedModelRequirements = (_a = options.precomputedModelRequirements) !== null && _a !== void 0 ? _a : null;
|
|
34759
34837
|
}
|
|
34760
34838
|
/**
|
|
34761
34839
|
* Updates the agent source and clears the cache
|
|
@@ -34763,9 +34841,13 @@ class AgentLlmExecutionTools {
|
|
|
34763
34841
|
* @param agentSource The new agent source string
|
|
34764
34842
|
*/
|
|
34765
34843
|
updateAgentSource(agentSource) {
|
|
34844
|
+
if (this.options.agentSource === agentSource) {
|
|
34845
|
+
return;
|
|
34846
|
+
}
|
|
34766
34847
|
this.options.agentSource = agentSource;
|
|
34767
34848
|
this._cachedAgentInfo = null;
|
|
34768
34849
|
this._cachedModelRequirements = null;
|
|
34850
|
+
this.precomputedModelRequirements = null;
|
|
34769
34851
|
}
|
|
34770
34852
|
/**
|
|
34771
34853
|
* Get cached or parse agent information
|
|
@@ -34782,6 +34864,16 @@ class AgentLlmExecutionTools {
|
|
|
34782
34864
|
* Note: [🐤] This is names `getModelRequirements` *(not `getAgentModelRequirements`)* because in future these two will be united
|
|
34783
34865
|
*/
|
|
34784
34866
|
async getModelRequirements() {
|
|
34867
|
+
var _a, _b;
|
|
34868
|
+
if (this.precomputedModelRequirements !== null) {
|
|
34869
|
+
if (this.options.isVerbose) {
|
|
34870
|
+
console.info('[🤰]', 'Using precomputed agent model requirements', {
|
|
34871
|
+
agent: this.title,
|
|
34872
|
+
toolCount: (_b = (_a = this.precomputedModelRequirements.tools) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
|
|
34873
|
+
});
|
|
34874
|
+
}
|
|
34875
|
+
return this.precomputedModelRequirements;
|
|
34876
|
+
}
|
|
34785
34877
|
if (this._cachedModelRequirements === null) {
|
|
34786
34878
|
const preparationStartedAtMs = Date.now();
|
|
34787
34879
|
if (this.options.isVerbose) {
|
|
@@ -34891,6 +34983,7 @@ class AgentLlmExecutionTools {
|
|
|
34891
34983
|
* Resolves agent requirements, attachments, and runtime overrides into one forwarded chat prompt.
|
|
34892
34984
|
*/
|
|
34893
34985
|
async prepareChatPrompt(prompt) {
|
|
34986
|
+
var _a;
|
|
34894
34987
|
const chatPrompt = this.requireChatPrompt(prompt);
|
|
34895
34988
|
const { sanitizedRequirements, promptSuffix } = await this.getSanitizedAgentModelRequirements();
|
|
34896
34989
|
const attachments = normalizeChatAttachments(chatPrompt.attachments);
|
|
@@ -34908,7 +35001,16 @@ class AgentLlmExecutionTools {
|
|
|
34908
35001
|
mergedTools,
|
|
34909
35002
|
knowledgeSourcesForAgent,
|
|
34910
35003
|
});
|
|
34911
|
-
|
|
35004
|
+
if (this.options.isVerbose) {
|
|
35005
|
+
console.info('[🤰]', 'Prepared agent chat prompt', {
|
|
35006
|
+
agent: this.title,
|
|
35007
|
+
usedPrecomputedModelRequirements: this.precomputedModelRequirements !== null,
|
|
35008
|
+
toolNames: mergedTools.map((tool) => tool.name),
|
|
35009
|
+
knowledgeSourcesCount: (_a = knowledgeSourcesForAgent === null || knowledgeSourcesForAgent === void 0 ? void 0 : knowledgeSourcesForAgent.length) !== null && _a !== void 0 ? _a : 0,
|
|
35010
|
+
promptSuffixLength: promptSuffix.length,
|
|
35011
|
+
systemMessageLength: sanitizedRequirements.systemMessage.length,
|
|
35012
|
+
});
|
|
35013
|
+
}
|
|
34912
35014
|
return {
|
|
34913
35015
|
forwardedPrompt,
|
|
34914
35016
|
sanitizedRequirements,
|
|
@@ -35095,6 +35197,7 @@ class AgentLlmExecutionTools {
|
|
|
35095
35197
|
* Runs one prepared prompt through the deprecated OpenAI Assistant backend.
|
|
35096
35198
|
*/
|
|
35097
35199
|
async callOpenAiAssistantChatModelStream(options) {
|
|
35200
|
+
var _a, _b, _c, _d;
|
|
35098
35201
|
const assistant = await this.getOrPrepareOpenAiAssistant({
|
|
35099
35202
|
llmTools: options.llmTools,
|
|
35100
35203
|
originalPrompt: options.originalPrompt,
|
|
@@ -35102,7 +35205,14 @@ class AgentLlmExecutionTools {
|
|
|
35102
35205
|
onProgress: options.onProgress,
|
|
35103
35206
|
});
|
|
35104
35207
|
const promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools = createOpenAiAssistantPrompt(options.preparedChatPrompt.forwardedPrompt);
|
|
35105
|
-
|
|
35208
|
+
if (this.options.isVerbose) {
|
|
35209
|
+
console.info('[🤰]', 'Prepared OpenAI Assistant prompt', {
|
|
35210
|
+
agent: this.title,
|
|
35211
|
+
toolNames: (_b = (_a = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements.tools) === null || _a === void 0 ? void 0 : _a.map((tool) => tool.name)) !== null && _b !== void 0 ? _b : [],
|
|
35212
|
+
knowledgeSourcesCount: (_d = (_c = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements
|
|
35213
|
+
.knowledgeSources) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
|
|
35214
|
+
});
|
|
35215
|
+
}
|
|
35106
35216
|
return assistant.callChatModelStream(promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools, options.onProgress, options.streamOptions);
|
|
35107
35217
|
}
|
|
35108
35218
|
/**
|
|
@@ -35793,7 +35903,8 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
35793
35903
|
isVerbose: options.isVerbose,
|
|
35794
35904
|
llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
|
|
35795
35905
|
assistantPreparationMode: options.assistantPreparationMode,
|
|
35796
|
-
agentSource: agentSource.value,
|
|
35906
|
+
agentSource: agentSource.value,
|
|
35907
|
+
precomputedModelRequirements: options.precomputedModelRequirements,
|
|
35797
35908
|
});
|
|
35798
35909
|
this._agentName = undefined;
|
|
35799
35910
|
/**
|
|
@@ -38411,6 +38522,7 @@ function $generateBookBoilerplate(options) {
|
|
|
38411
38522
|
|
|
38412
38523
|
PERSONA ${block(personaDescription)}
|
|
38413
38524
|
${block(initialRules.map((rule) => `RULE ${rule}`).join('\n'))}
|
|
38525
|
+
CLOSED
|
|
38414
38526
|
`));
|
|
38415
38527
|
// Note: `META COLOR ${color || PROMPTBOOK_COLOR.toHex()}` was removed for now
|
|
38416
38528
|
// Note: `META FONT Playfair Display, sans-serif` was removed for now
|