@promptbook/core 0.112.0-42 → 0.112.0-44
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 +208 -57
- package/esm/index.es.js.map +1 -1
- package/esm/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -1
- package/esm/src/book-2.0/agent-source/TeammateProfileResolver.d.ts +2 -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/commitments/PERSONA/PERSONA.d.ts +7 -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 +208 -57
- package/umd/index.umd.js.map +1 -1
- package/umd/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -1
- package/umd/src/book-2.0/agent-source/TeammateProfileResolver.d.ts +2 -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/commitments/PERSONA/PERSONA.d.ts +7 -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-44';
|
|
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,
|
|
@@ -11410,7 +11410,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11410
11410
|
* Short one-line description of GOAL.
|
|
11411
11411
|
*/
|
|
11412
11412
|
get description() {
|
|
11413
|
-
return 'Define
|
|
11413
|
+
return 'Define the effective agent **goal**; when multiple goals exist, only the last one stays effective.';
|
|
11414
11414
|
}
|
|
11415
11415
|
/**
|
|
11416
11416
|
* Icon for this commitment.
|
|
@@ -11425,12 +11425,14 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11425
11425
|
return spaceTrim$1(`
|
|
11426
11426
|
# ${this.type}
|
|
11427
11427
|
|
|
11428
|
-
Defines the main goal which should be achieved by the AI assistant.
|
|
11428
|
+
Defines the main goal which should be achieved by the AI assistant.
|
|
11429
|
+
There can be multiple goals in source, but after inheritance/source rewriting only the last \`GOAL\` /\`GOALS\` remains effective.
|
|
11429
11430
|
|
|
11430
11431
|
## Key aspects
|
|
11431
11432
|
|
|
11432
11433
|
- Both terms work identically and can be used interchangeably.
|
|
11433
|
-
- Later goals
|
|
11434
|
+
- Later goals overwrite earlier goals.
|
|
11435
|
+
- The public agent profile text is derived from the last goal.
|
|
11434
11436
|
- Goals provide clear direction and purpose for the agent's responses.
|
|
11435
11437
|
- Goals influence decision-making and response prioritization.
|
|
11436
11438
|
|
|
@@ -11443,9 +11445,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11443
11445
|
\`\`\`book
|
|
11444
11446
|
Customer Support Agent
|
|
11445
11447
|
|
|
11446
|
-
PERSONA You are a helpful customer support representative
|
|
11447
11448
|
GOAL Resolve customer issues quickly and efficiently
|
|
11448
|
-
GOAL Maintain high customer satisfaction scores
|
|
11449
11449
|
GOAL Always follow company policies and procedures
|
|
11450
11450
|
RULE Be polite and professional at all times
|
|
11451
11451
|
\`\`\`
|
|
@@ -11453,9 +11453,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11453
11453
|
\`\`\`book
|
|
11454
11454
|
Educational Assistant
|
|
11455
11455
|
|
|
11456
|
-
PERSONA You are an educational assistant specializing in mathematics
|
|
11457
11456
|
GOAL Help students understand mathematical concepts clearly
|
|
11458
|
-
GOAL Encourage critical thinking and problem-solving skills
|
|
11459
11457
|
GOAL Ensure all explanations are age-appropriate and accessible
|
|
11460
11458
|
STYLE Use simple language and provide step-by-step explanations
|
|
11461
11459
|
\`\`\`
|
|
@@ -11463,9 +11461,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11463
11461
|
\`\`\`book
|
|
11464
11462
|
Safety-First Assistant
|
|
11465
11463
|
|
|
11466
|
-
PERSONA You are a general-purpose AI assistant
|
|
11467
11464
|
GOAL Be helpful and informative in all interactions
|
|
11468
|
-
GOAL Provide accurate and reliable information
|
|
11469
11465
|
GOAL Always prioritize user safety and ethical guidelines
|
|
11470
11466
|
RULE Never provide harmful or dangerous advice
|
|
11471
11467
|
\`\`\`
|
|
@@ -14324,7 +14320,16 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14324
14320
|
* Short one-line description of PERSONA.
|
|
14325
14321
|
*/
|
|
14326
14322
|
get description() {
|
|
14327
|
-
return '
|
|
14323
|
+
return 'Deprecated legacy profile commitment. Prefer `GOAL` for agent profile text and inheritance-safe rewrites.';
|
|
14324
|
+
}
|
|
14325
|
+
/**
|
|
14326
|
+
* Optional UI/docs-only deprecation metadata.
|
|
14327
|
+
*/
|
|
14328
|
+
get deprecation() {
|
|
14329
|
+
return {
|
|
14330
|
+
message: 'Use `GOAL` for agent profile text and inheritance-safe rewrites.',
|
|
14331
|
+
replacedBy: ['GOAL'],
|
|
14332
|
+
};
|
|
14328
14333
|
}
|
|
14329
14334
|
/**
|
|
14330
14335
|
* Icon for this commitment.
|
|
@@ -14339,16 +14344,24 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
14339
14344
|
return spaceTrim$1(`
|
|
14340
14345
|
# ${this.type}
|
|
14341
14346
|
|
|
14342
|
-
|
|
14347
|
+
Deprecated legacy commitment that defines who the agent is, their background, expertise, and personality traits.
|
|
14343
14348
|
|
|
14344
|
-
##
|
|
14349
|
+
## Migration
|
|
14345
14350
|
|
|
14346
|
-
-
|
|
14347
|
-
-
|
|
14348
|
-
-
|
|
14349
|
-
-
|
|
14351
|
+
- Existing \`${this.type}\` books still parse and compile.
|
|
14352
|
+
- New books should prefer \`GOAL\`.
|
|
14353
|
+
- Agent profile rendering now prefers the last \`GOAL\` and only falls back to \`${this.type}\` when no goal exists.
|
|
14354
|
+
- Runtime compilation keeps the legacy multi-\`PERSONA\` merge behavior for backward compatibility.
|
|
14350
14355
|
|
|
14351
|
-
##
|
|
14356
|
+
## Preferred replacement
|
|
14357
|
+
|
|
14358
|
+
\`\`\`book
|
|
14359
|
+
Programming Assistant
|
|
14360
|
+
|
|
14361
|
+
GOAL Help the user solve programming problems with practical TypeScript and React guidance.
|
|
14362
|
+
\`\`\`
|
|
14363
|
+
|
|
14364
|
+
## Legacy compatibility example
|
|
14352
14365
|
|
|
14353
14366
|
\`\`\`book
|
|
14354
14367
|
Programming Assistant
|
|
@@ -15056,6 +15069,15 @@ const teamToolFunctions = {};
|
|
|
15056
15069
|
* Map of team tool titles.
|
|
15057
15070
|
*/
|
|
15058
15071
|
const teamToolTitles = {};
|
|
15072
|
+
/**
|
|
15073
|
+
* Shared TEAM usage rules appended ahead of teammate listings.
|
|
15074
|
+
*
|
|
15075
|
+
* @private
|
|
15076
|
+
*/
|
|
15077
|
+
const TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES = [
|
|
15078
|
+
'- If a teammate is relevant to the request, consult that teammate using the matching tool.',
|
|
15079
|
+
'- Do not ask the user for information that a listed teammate can provide directly.',
|
|
15080
|
+
];
|
|
15059
15081
|
/**
|
|
15060
15082
|
* Constant for remote agents by Url.
|
|
15061
15083
|
*/
|
|
@@ -15104,7 +15126,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
15104
15126
|
\`\`\`book
|
|
15105
15127
|
Legal Assistant
|
|
15106
15128
|
|
|
15107
|
-
|
|
15129
|
+
GOAL Get expert software-development advice from the teammate when legal discussion needs technical context.
|
|
15108
15130
|
TEAM You can talk with http://localhost:4440/agents/GMw67JN8TXxN7y to discuss the legal aspects.
|
|
15109
15131
|
\`\`\`
|
|
15110
15132
|
`);
|
|
@@ -15145,12 +15167,9 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
15145
15167
|
if (updatedTools.some((tool) => tool.name === entry.toolName)) {
|
|
15146
15168
|
continue;
|
|
15147
15169
|
}
|
|
15148
|
-
const toolDescription = entry.description
|
|
15149
|
-
? `Consult teammate ${entry.teammate.label}\n${entry.description}`
|
|
15150
|
-
: `Consult teammate ${entry.teammate.label}`;
|
|
15151
15170
|
updatedTools.push({
|
|
15152
15171
|
name: entry.toolName,
|
|
15153
|
-
description:
|
|
15172
|
+
description: buildTeamToolDescription(entry),
|
|
15154
15173
|
parameters: {
|
|
15155
15174
|
type: 'object',
|
|
15156
15175
|
properties: {
|
|
@@ -15219,22 +15238,72 @@ function resolveTeamTeammateLabels(teamContent, teammates) {
|
|
|
15219
15238
|
/**
|
|
15220
15239
|
* Builds the textual TEAM section body for the final system message.
|
|
15221
15240
|
*
|
|
15222
|
-
* Each teammate is listed with its tool name
|
|
15223
|
-
* Uses `spaceTrim` to ensure consistent whitespace and indentation.
|
|
15241
|
+
* Each teammate is listed with its tool name, TEAM instructions, and optional profile hints.
|
|
15224
15242
|
*/
|
|
15225
15243
|
function buildTeamSystemMessageBody(teamEntries) {
|
|
15226
|
-
const lines =
|
|
15227
|
-
|
|
15228
|
-
|
|
15229
|
-
|
|
15230
|
-
|
|
15231
|
-
|
|
15232
|
-
|
|
15233
|
-
|
|
15234
|
-
|
|
15235
|
-
});
|
|
15244
|
+
const lines = [
|
|
15245
|
+
...TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES,
|
|
15246
|
+
'',
|
|
15247
|
+
...teamEntries.map((entry, index) => {
|
|
15248
|
+
const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
|
|
15249
|
+
const detailLines = collectTeamEntryDetails(entry).map(formatTeamEntryDetailLine);
|
|
15250
|
+
return [toolLine, ...detailLines].join('\n');
|
|
15251
|
+
}),
|
|
15252
|
+
];
|
|
15236
15253
|
return lines.join('\n');
|
|
15237
15254
|
}
|
|
15255
|
+
/**
|
|
15256
|
+
* Builds the model-visible description for one teammate tool.
|
|
15257
|
+
*
|
|
15258
|
+
* @private
|
|
15259
|
+
*/
|
|
15260
|
+
function buildTeamToolDescription(entry) {
|
|
15261
|
+
const detailLines = collectTeamEntryDetails(entry).map(({ label, content }) => `${label}: ${content}`);
|
|
15262
|
+
return [`Consult teammate ${entry.teammate.label}`, ...detailLines].join('\n');
|
|
15263
|
+
}
|
|
15264
|
+
/**
|
|
15265
|
+
* Collects structured teammate details that should stay visible to the model.
|
|
15266
|
+
*
|
|
15267
|
+
* @private
|
|
15268
|
+
*/
|
|
15269
|
+
function collectTeamEntryDetails(entry) {
|
|
15270
|
+
var _a;
|
|
15271
|
+
const details = [];
|
|
15272
|
+
const instructions = entry.teammate.instructions.trim();
|
|
15273
|
+
const description = ((_a = entry.description) === null || _a === void 0 ? void 0 : _a.trim()) || '';
|
|
15274
|
+
if (instructions) {
|
|
15275
|
+
details.push({
|
|
15276
|
+
label: 'TEAM instructions',
|
|
15277
|
+
content: instructions,
|
|
15278
|
+
});
|
|
15279
|
+
}
|
|
15280
|
+
if (description) {
|
|
15281
|
+
details.push({
|
|
15282
|
+
label: 'Profile',
|
|
15283
|
+
content: description,
|
|
15284
|
+
});
|
|
15285
|
+
}
|
|
15286
|
+
return details;
|
|
15287
|
+
}
|
|
15288
|
+
/**
|
|
15289
|
+
* Formats one teammate detail line for the TEAM system-message section.
|
|
15290
|
+
*
|
|
15291
|
+
* @private
|
|
15292
|
+
*/
|
|
15293
|
+
function formatTeamEntryDetailLine(detail) {
|
|
15294
|
+
return indentMultilineText(`${detail.label}: ${detail.content}`, ' ');
|
|
15295
|
+
}
|
|
15296
|
+
/**
|
|
15297
|
+
* Indents all lines of one potentially multi-line text block.
|
|
15298
|
+
*
|
|
15299
|
+
* @private
|
|
15300
|
+
*/
|
|
15301
|
+
function indentMultilineText(text, prefix) {
|
|
15302
|
+
return text
|
|
15303
|
+
.split('\n')
|
|
15304
|
+
.map((line) => `${prefix}${line}`)
|
|
15305
|
+
.join('\n');
|
|
15306
|
+
}
|
|
15238
15307
|
/**
|
|
15239
15308
|
* Registers tool function and title for a teammate tool.
|
|
15240
15309
|
*/
|
|
@@ -21928,6 +21997,15 @@ const COMMITMENTS_WITH_AGENT_REFERENCES = new Set(['FROM', 'IMPORT', 'IMPORTS',
|
|
|
21928
21997
|
* @private internal constant of `createAgentModelRequirementsWithCommitments`
|
|
21929
21998
|
*/
|
|
21930
21999
|
const DELETE_COMMITMENT_TYPES = new Set(['DELETE', 'CANCEL', 'DISCARD', 'REMOVE']);
|
|
22000
|
+
/**
|
|
22001
|
+
* Commitments whose earlier occurrences are overwritten by the last occurrence in source order.
|
|
22002
|
+
*
|
|
22003
|
+
* @private internal constant of `createAgentModelRequirementsWithCommitments`
|
|
22004
|
+
*/
|
|
22005
|
+
const OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE = new Map([
|
|
22006
|
+
['GOAL', 'GOAL'],
|
|
22007
|
+
['GOALS', 'GOAL'],
|
|
22008
|
+
]);
|
|
21931
22009
|
/**
|
|
21932
22010
|
* Regex pattern matching markdown horizontal lines that should not be copied into the final system message.
|
|
21933
22011
|
*
|
|
@@ -21978,7 +22056,7 @@ function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
|
|
|
21978
22056
|
*/
|
|
21979
22057
|
async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
|
|
21980
22058
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
21981
|
-
const filteredCommitments = filterDeletedCommitments(parseResult.commitments);
|
|
22059
|
+
const filteredCommitments = filterOverwrittenCommitments(filterDeletedCommitments(parseResult.commitments));
|
|
21982
22060
|
let requirements = createInitialAgentModelRequirements(parseResult.agentName, modelName);
|
|
21983
22061
|
requirements = await applyCommitmentsToRequirements(requirements, filteredCommitments, options);
|
|
21984
22062
|
requirements = aggregateUseCommitmentSystemMessages(requirements, filteredCommitments);
|
|
@@ -21989,6 +22067,35 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
|
|
|
21989
22067
|
requirements = await applyPendingInlineKnowledgeSources(requirements, options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader);
|
|
21990
22068
|
return finalizeRequirements(requirements);
|
|
21991
22069
|
}
|
|
22070
|
+
/**
|
|
22071
|
+
* Removes earlier commitments that are overwritten by later commitments of the same semantic group.
|
|
22072
|
+
*
|
|
22073
|
+
* This currently keeps only the last `GOAL` / `GOALS` commitment so inheritance rewrites
|
|
22074
|
+
* and multi-goal sources expose one effective goal to the runtime.
|
|
22075
|
+
*
|
|
22076
|
+
* @param commitments - Parsed commitments after DELETE-like filtering.
|
|
22077
|
+
* @returns Commitments with overwritten entries removed while preserving source order.
|
|
22078
|
+
*
|
|
22079
|
+
* @private internal utility of `createAgentModelRequirementsWithCommitments`
|
|
22080
|
+
*/
|
|
22081
|
+
function filterOverwrittenCommitments(commitments) {
|
|
22082
|
+
const seenOverwriteGroups = new Set();
|
|
22083
|
+
const keptCommitments = [];
|
|
22084
|
+
for (let index = commitments.length - 1; index >= 0; index--) {
|
|
22085
|
+
const commitment = commitments[index];
|
|
22086
|
+
const overwriteGroup = OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE.get(commitment.type);
|
|
22087
|
+
if (!overwriteGroup) {
|
|
22088
|
+
keptCommitments.push(commitment);
|
|
22089
|
+
continue;
|
|
22090
|
+
}
|
|
22091
|
+
if (seenOverwriteGroups.has(overwriteGroup)) {
|
|
22092
|
+
continue;
|
|
22093
|
+
}
|
|
22094
|
+
seenOverwriteGroups.add(overwriteGroup);
|
|
22095
|
+
keptCommitments.push(commitment);
|
|
22096
|
+
}
|
|
22097
|
+
return keptCommitments.reverse();
|
|
22098
|
+
}
|
|
21992
22099
|
/**
|
|
21993
22100
|
* Creates the initial requirements object with the parsed agent name stored in metadata and an optional model override.
|
|
21994
22101
|
*
|
|
@@ -22622,7 +22729,7 @@ function createDefaultAgentName(agentSource) {
|
|
|
22622
22729
|
function parseAgentSource(agentSource) {
|
|
22623
22730
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
22624
22731
|
const resolvedAgentName = parseResult.agentName || createDefaultAgentName(agentSource);
|
|
22625
|
-
const personaDescription =
|
|
22732
|
+
const personaDescription = extractAgentProfileText(parseResult.commitments);
|
|
22626
22733
|
const initialMessage = extractInitialMessage(parseResult.commitments);
|
|
22627
22734
|
const parsedProfile = extractParsedAgentProfile(parseResult.commitments);
|
|
22628
22735
|
ensureMetaFullname(parsedProfile.meta, resolvedAgentName);
|
|
@@ -22726,25 +22833,33 @@ const META_COMMITMENT_APPLIERS = {
|
|
|
22726
22833
|
*/
|
|
22727
22834
|
const LOCAL_AGENT_REFERENCE_PREFIXES = ['./', '../', '/'];
|
|
22728
22835
|
/**
|
|
22729
|
-
*
|
|
22836
|
+
* Resolves the public agent profile text from the last GOAL/GOALS commitment,
|
|
22837
|
+
* falling back to the deprecated PERSONA/PERSONAE commitments when no goal exists.
|
|
22730
22838
|
*
|
|
22731
22839
|
* @private internal utility of `parseAgentSource`
|
|
22732
22840
|
*/
|
|
22733
|
-
function
|
|
22734
|
-
let
|
|
22841
|
+
function extractAgentProfileText(commitments) {
|
|
22842
|
+
let goalDescription = '';
|
|
22843
|
+
let hasGoalDescription = false;
|
|
22844
|
+
let personaDescription = '';
|
|
22845
|
+
let hasPersonaDescription = false;
|
|
22735
22846
|
for (const commitment of commitments) {
|
|
22736
|
-
if (commitment.type
|
|
22737
|
-
|
|
22738
|
-
|
|
22739
|
-
if (personaDescription === null) {
|
|
22740
|
-
personaDescription = '';
|
|
22847
|
+
if (commitment.type === 'GOAL' || commitment.type === 'GOALS') {
|
|
22848
|
+
goalDescription = commitment.content;
|
|
22849
|
+
hasGoalDescription = true;
|
|
22741
22850
|
}
|
|
22742
|
-
|
|
22743
|
-
personaDescription
|
|
22851
|
+
if (commitment.type === 'PERSONA' || commitment.type === 'PERSONAE') {
|
|
22852
|
+
personaDescription = commitment.content;
|
|
22853
|
+
hasPersonaDescription = true;
|
|
22744
22854
|
}
|
|
22745
|
-
personaDescription += commitment.content;
|
|
22746
22855
|
}
|
|
22747
|
-
|
|
22856
|
+
if (hasGoalDescription) {
|
|
22857
|
+
return goalDescription;
|
|
22858
|
+
}
|
|
22859
|
+
if (hasPersonaDescription) {
|
|
22860
|
+
return personaDescription;
|
|
22861
|
+
}
|
|
22862
|
+
return null;
|
|
22748
22863
|
}
|
|
22749
22864
|
/**
|
|
22750
22865
|
* Resolves the last INITIAL MESSAGE commitment, which is the public initial-message value.
|
|
@@ -23231,7 +23346,7 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
|
|
|
23231
23346
|
* Selects the best model using the preparePersona function
|
|
23232
23347
|
* This directly uses preparePersona to ensure DRY principle
|
|
23233
23348
|
*
|
|
23234
|
-
* @param agentSource The agent source to derive
|
|
23349
|
+
* @param agentSource The agent source to derive effective profile text from
|
|
23235
23350
|
* @param llmTools LLM tools for preparing persona
|
|
23236
23351
|
* @returns The name of the best selected model
|
|
23237
23352
|
*
|
|
@@ -23239,9 +23354,9 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
|
|
|
23239
23354
|
*/
|
|
23240
23355
|
async function selectBestModelUsingPersona(agentSource, llmTools) {
|
|
23241
23356
|
var _a;
|
|
23242
|
-
// Parse agent source to get
|
|
23357
|
+
// Parse agent source to get the effective profile description
|
|
23243
23358
|
const { agentName, personaDescription } = parseAgentSource(agentSource);
|
|
23244
|
-
// Use agent name as fallback if no
|
|
23359
|
+
// Use agent name as fallback if no profile description is available
|
|
23245
23360
|
const description = personaDescription || agentName || 'AI Agent';
|
|
23246
23361
|
try {
|
|
23247
23362
|
// Use preparePersona directly
|
|
@@ -32701,7 +32816,7 @@ class OpenAiVectorStoreHandler extends OpenAiExecutionTools {
|
|
|
32701
32816
|
/**
|
|
32702
32817
|
* Constant for default agent kit model name.
|
|
32703
32818
|
*/
|
|
32704
|
-
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-
|
|
32819
|
+
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-mini';
|
|
32705
32820
|
/**
|
|
32706
32821
|
* Creates one structured log entry for streamed tool-call updates.
|
|
32707
32822
|
*
|
|
@@ -34767,6 +34882,7 @@ class AgentLlmExecutionTools {
|
|
|
34767
34882
|
* @param agentSource The agent source string that defines the agent's behavior
|
|
34768
34883
|
*/
|
|
34769
34884
|
constructor(options) {
|
|
34885
|
+
var _a;
|
|
34770
34886
|
this.options = options;
|
|
34771
34887
|
/**
|
|
34772
34888
|
* Cached model requirements to avoid re-parsing the agent source
|
|
@@ -34776,6 +34892,7 @@ class AgentLlmExecutionTools {
|
|
|
34776
34892
|
* Cached parsed agent information
|
|
34777
34893
|
*/
|
|
34778
34894
|
this._cachedAgentInfo = null;
|
|
34895
|
+
this.precomputedModelRequirements = (_a = options.precomputedModelRequirements) !== null && _a !== void 0 ? _a : null;
|
|
34779
34896
|
}
|
|
34780
34897
|
/**
|
|
34781
34898
|
* Updates the agent source and clears the cache
|
|
@@ -34783,9 +34900,13 @@ class AgentLlmExecutionTools {
|
|
|
34783
34900
|
* @param agentSource The new agent source string
|
|
34784
34901
|
*/
|
|
34785
34902
|
updateAgentSource(agentSource) {
|
|
34903
|
+
if (this.options.agentSource === agentSource) {
|
|
34904
|
+
return;
|
|
34905
|
+
}
|
|
34786
34906
|
this.options.agentSource = agentSource;
|
|
34787
34907
|
this._cachedAgentInfo = null;
|
|
34788
34908
|
this._cachedModelRequirements = null;
|
|
34909
|
+
this.precomputedModelRequirements = null;
|
|
34789
34910
|
}
|
|
34790
34911
|
/**
|
|
34791
34912
|
* Get cached or parse agent information
|
|
@@ -34802,6 +34923,16 @@ class AgentLlmExecutionTools {
|
|
|
34802
34923
|
* Note: [🐤] This is names `getModelRequirements` *(not `getAgentModelRequirements`)* because in future these two will be united
|
|
34803
34924
|
*/
|
|
34804
34925
|
async getModelRequirements() {
|
|
34926
|
+
var _a, _b;
|
|
34927
|
+
if (this.precomputedModelRequirements !== null) {
|
|
34928
|
+
if (this.options.isVerbose) {
|
|
34929
|
+
console.info('[🤰]', 'Using precomputed agent model requirements', {
|
|
34930
|
+
agent: this.title,
|
|
34931
|
+
toolCount: (_b = (_a = this.precomputedModelRequirements.tools) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
|
|
34932
|
+
});
|
|
34933
|
+
}
|
|
34934
|
+
return this.precomputedModelRequirements;
|
|
34935
|
+
}
|
|
34805
34936
|
if (this._cachedModelRequirements === null) {
|
|
34806
34937
|
const preparationStartedAtMs = Date.now();
|
|
34807
34938
|
if (this.options.isVerbose) {
|
|
@@ -34911,6 +35042,7 @@ class AgentLlmExecutionTools {
|
|
|
34911
35042
|
* Resolves agent requirements, attachments, and runtime overrides into one forwarded chat prompt.
|
|
34912
35043
|
*/
|
|
34913
35044
|
async prepareChatPrompt(prompt) {
|
|
35045
|
+
var _a;
|
|
34914
35046
|
const chatPrompt = this.requireChatPrompt(prompt);
|
|
34915
35047
|
const { sanitizedRequirements, promptSuffix } = await this.getSanitizedAgentModelRequirements();
|
|
34916
35048
|
const attachments = normalizeChatAttachments(chatPrompt.attachments);
|
|
@@ -34928,7 +35060,16 @@ class AgentLlmExecutionTools {
|
|
|
34928
35060
|
mergedTools,
|
|
34929
35061
|
knowledgeSourcesForAgent,
|
|
34930
35062
|
});
|
|
34931
|
-
|
|
35063
|
+
if (this.options.isVerbose) {
|
|
35064
|
+
console.info('[🤰]', 'Prepared agent chat prompt', {
|
|
35065
|
+
agent: this.title,
|
|
35066
|
+
usedPrecomputedModelRequirements: this.precomputedModelRequirements !== null,
|
|
35067
|
+
toolNames: mergedTools.map((tool) => tool.name),
|
|
35068
|
+
knowledgeSourcesCount: (_a = knowledgeSourcesForAgent === null || knowledgeSourcesForAgent === void 0 ? void 0 : knowledgeSourcesForAgent.length) !== null && _a !== void 0 ? _a : 0,
|
|
35069
|
+
promptSuffixLength: promptSuffix.length,
|
|
35070
|
+
systemMessageLength: sanitizedRequirements.systemMessage.length,
|
|
35071
|
+
});
|
|
35072
|
+
}
|
|
34932
35073
|
return {
|
|
34933
35074
|
forwardedPrompt,
|
|
34934
35075
|
sanitizedRequirements,
|
|
@@ -35115,6 +35256,7 @@ class AgentLlmExecutionTools {
|
|
|
35115
35256
|
* Runs one prepared prompt through the deprecated OpenAI Assistant backend.
|
|
35116
35257
|
*/
|
|
35117
35258
|
async callOpenAiAssistantChatModelStream(options) {
|
|
35259
|
+
var _a, _b, _c, _d;
|
|
35118
35260
|
const assistant = await this.getOrPrepareOpenAiAssistant({
|
|
35119
35261
|
llmTools: options.llmTools,
|
|
35120
35262
|
originalPrompt: options.originalPrompt,
|
|
@@ -35122,7 +35264,14 @@ class AgentLlmExecutionTools {
|
|
|
35122
35264
|
onProgress: options.onProgress,
|
|
35123
35265
|
});
|
|
35124
35266
|
const promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools = createOpenAiAssistantPrompt(options.preparedChatPrompt.forwardedPrompt);
|
|
35125
|
-
|
|
35267
|
+
if (this.options.isVerbose) {
|
|
35268
|
+
console.info('[🤰]', 'Prepared OpenAI Assistant prompt', {
|
|
35269
|
+
agent: this.title,
|
|
35270
|
+
toolNames: (_b = (_a = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements.tools) === null || _a === void 0 ? void 0 : _a.map((tool) => tool.name)) !== null && _b !== void 0 ? _b : [],
|
|
35271
|
+
knowledgeSourcesCount: (_d = (_c = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements
|
|
35272
|
+
.knowledgeSources) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
|
|
35273
|
+
});
|
|
35274
|
+
}
|
|
35126
35275
|
return assistant.callChatModelStream(promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools, options.onProgress, options.streamOptions);
|
|
35127
35276
|
}
|
|
35128
35277
|
/**
|
|
@@ -35813,7 +35962,8 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
35813
35962
|
isVerbose: options.isVerbose,
|
|
35814
35963
|
llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
|
|
35815
35964
|
assistantPreparationMode: options.assistantPreparationMode,
|
|
35816
|
-
agentSource: agentSource.value,
|
|
35965
|
+
agentSource: agentSource.value,
|
|
35966
|
+
precomputedModelRequirements: options.precomputedModelRequirements,
|
|
35817
35967
|
});
|
|
35818
35968
|
this._agentName = undefined;
|
|
35819
35969
|
/**
|
|
@@ -38431,6 +38581,7 @@ function $generateBookBoilerplate(options) {
|
|
|
38431
38581
|
|
|
38432
38582
|
PERSONA ${block(personaDescription)}
|
|
38433
38583
|
${block(initialRules.map((rule) => `RULE ${rule}`).join('\n'))}
|
|
38584
|
+
CLOSED
|
|
38434
38585
|
`));
|
|
38435
38586
|
// Note: `META COLOR ${color || PROMPTBOOK_COLOR.toHex()}` was removed for now
|
|
38436
38587
|
// Note: `META FONT Playfair Display, sans-serif` was removed for now
|