@promptbook/components 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 +209 -59
- 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 +209 -59
- 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
|
@@ -567,6 +567,7 @@ Prompts marked with `[-]` are not ready yet, prompts containing `@@@` are treate
|
|
|
567
567
|
- **Reasoning control:** `--thinking-level low|medium|high|xhigh` for supported runners
|
|
568
568
|
- **Interactive or unattended runs:** default wait mode, or `--no-wait` for batch execution
|
|
569
569
|
- **Git safety:** clean working tree check by default, optional `--ignore-git-changes`
|
|
570
|
+
- **Opt-in remote pushes:** commits stay local unless you explicitly pass `--auto-push`
|
|
570
571
|
- **Prompt triage:** `--priority` to process only more important tasks first
|
|
571
572
|
- **Failure logging:** failed runs write a neighboring `.error.log`
|
|
572
573
|
- **Line-ending normalization:** changed files are normalized back to LF by default
|
|
@@ -584,6 +585,8 @@ npx ts-node ./src/cli/test/ptbk.ts coder generate-boilerplates --template prompt
|
|
|
584
585
|
|
|
585
586
|
npx ts-node ./src/cli/test/ptbk.ts coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md
|
|
586
587
|
|
|
588
|
+
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
|
|
589
|
+
|
|
587
590
|
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
|
|
588
591
|
|
|
589
592
|
npx ts-node ./src/cli/test/ptbk.ts coder find-refactor-candidates
|
|
@@ -606,9 +609,11 @@ npx ptbk coder generate-boilerplates
|
|
|
606
609
|
|
|
607
610
|
npx ptbk coder generate-boilerplates --template prompts/templates/common.md
|
|
608
611
|
|
|
609
|
-
npx ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md
|
|
612
|
+
npx ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --test npm run test
|
|
613
|
+
|
|
614
|
+
npx ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --auto-push
|
|
610
615
|
|
|
611
|
-
npx ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --ignore-git-changes --no-wait
|
|
616
|
+
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
|
|
612
617
|
|
|
613
618
|
npx ptbk coder find-refactor-candidates
|
|
614
619
|
|
|
@@ -625,7 +630,7 @@ npx ptbk coder verify
|
|
|
625
630
|
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------ | ---- | ----- | ------------------------------------------------------------------------ |
|
|
626
631
|
| `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/`. |
|
|
627
632
|
| `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. |
|
|
628
|
-
| `ptbk coder run` | Picks the next ready prompt, appends optional context, runs it through the selected coding agent, marks success or failure,
|
|
633
|
+
| `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. |
|
|
629
634
|
| `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. |
|
|
630
635
|
| `ptbk coder verify` | Walks through completed prompts, archives truly finished work, and adds follow-up repair prompts for unfinished results. |
|
|
631
636
|
|
|
@@ -636,12 +641,14 @@ npx ptbk coder verify
|
|
|
636
641
|
| `--agent <name>` | Selects the coding backend. |
|
|
637
642
|
| `--model <model>` | Chooses the runner model; required for `openai-codex` and `gemini`, optional for `github-copilot`. |
|
|
638
643
|
| `--context <text-or-file>` | Appends extra instructions inline or from a file like `AGENTS.md`. |
|
|
644
|
+
| `--test <command>` | Runs a verification command after each prompt attempt and feeds failing output back for retries. |
|
|
639
645
|
| `--thinking-level <level>` | Sets reasoning effort for supported runners. |
|
|
640
646
|
| `--no-wait` | Skips interactive pauses between prompts for unattended execution. |
|
|
641
647
|
| `--ignore-git-changes` | Disables the clean-working-tree guard. |
|
|
642
648
|
| `--priority <n>` | Runs only prompts at or above the given priority. |
|
|
643
649
|
| `--dry-run` | Prints which prompts are ready instead of executing them. |
|
|
644
650
|
| `--allow-credits` | Lets OpenAI Codex spend credits when required. |
|
|
651
|
+
| `--auto-push` | Pushes each successful coding-agent commit to the configured remote. |
|
|
645
652
|
| `--auto-migrate` | Runs testing-server database migrations after each successful prompt. |
|
|
646
653
|
|
|
647
654
|
#### Typical usage pattern
|
package/esm/index.es.js
CHANGED
|
@@ -40,7 +40,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
40
40
|
* @generated
|
|
41
41
|
* @see https://github.com/webgptorg/promptbook
|
|
42
42
|
*/
|
|
43
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
43
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-44';
|
|
44
44
|
/**
|
|
45
45
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
46
46
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -7254,7 +7254,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
7254
7254
|
* Short one-line description of GOAL.
|
|
7255
7255
|
*/
|
|
7256
7256
|
get description() {
|
|
7257
|
-
return 'Define
|
|
7257
|
+
return 'Define the effective agent **goal**; when multiple goals exist, only the last one stays effective.';
|
|
7258
7258
|
}
|
|
7259
7259
|
/**
|
|
7260
7260
|
* Icon for this commitment.
|
|
@@ -7269,12 +7269,14 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
7269
7269
|
return spaceTrim$1(`
|
|
7270
7270
|
# ${this.type}
|
|
7271
7271
|
|
|
7272
|
-
Defines the main goal which should be achieved by the AI assistant.
|
|
7272
|
+
Defines the main goal which should be achieved by the AI assistant.
|
|
7273
|
+
There can be multiple goals in source, but after inheritance/source rewriting only the last \`GOAL\` /\`GOALS\` remains effective.
|
|
7273
7274
|
|
|
7274
7275
|
## Key aspects
|
|
7275
7276
|
|
|
7276
7277
|
- Both terms work identically and can be used interchangeably.
|
|
7277
|
-
- Later goals
|
|
7278
|
+
- Later goals overwrite earlier goals.
|
|
7279
|
+
- The public agent profile text is derived from the last goal.
|
|
7278
7280
|
- Goals provide clear direction and purpose for the agent's responses.
|
|
7279
7281
|
- Goals influence decision-making and response prioritization.
|
|
7280
7282
|
|
|
@@ -7287,9 +7289,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
7287
7289
|
\`\`\`book
|
|
7288
7290
|
Customer Support Agent
|
|
7289
7291
|
|
|
7290
|
-
PERSONA You are a helpful customer support representative
|
|
7291
7292
|
GOAL Resolve customer issues quickly and efficiently
|
|
7292
|
-
GOAL Maintain high customer satisfaction scores
|
|
7293
7293
|
GOAL Always follow company policies and procedures
|
|
7294
7294
|
RULE Be polite and professional at all times
|
|
7295
7295
|
\`\`\`
|
|
@@ -7297,9 +7297,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
7297
7297
|
\`\`\`book
|
|
7298
7298
|
Educational Assistant
|
|
7299
7299
|
|
|
7300
|
-
PERSONA You are an educational assistant specializing in mathematics
|
|
7301
7300
|
GOAL Help students understand mathematical concepts clearly
|
|
7302
|
-
GOAL Encourage critical thinking and problem-solving skills
|
|
7303
7301
|
GOAL Ensure all explanations are age-appropriate and accessible
|
|
7304
7302
|
STYLE Use simple language and provide step-by-step explanations
|
|
7305
7303
|
\`\`\`
|
|
@@ -7307,9 +7305,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
7307
7305
|
\`\`\`book
|
|
7308
7306
|
Safety-First Assistant
|
|
7309
7307
|
|
|
7310
|
-
PERSONA You are a general-purpose AI assistant
|
|
7311
7308
|
GOAL Be helpful and informative in all interactions
|
|
7312
|
-
GOAL Provide accurate and reliable information
|
|
7313
7309
|
GOAL Always prioritize user safety and ethical guidelines
|
|
7314
7310
|
RULE Never provide harmful or dangerous advice
|
|
7315
7311
|
\`\`\`
|
|
@@ -10068,7 +10064,16 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
10068
10064
|
* Short one-line description of PERSONA.
|
|
10069
10065
|
*/
|
|
10070
10066
|
get description() {
|
|
10071
|
-
return '
|
|
10067
|
+
return 'Deprecated legacy profile commitment. Prefer `GOAL` for agent profile text and inheritance-safe rewrites.';
|
|
10068
|
+
}
|
|
10069
|
+
/**
|
|
10070
|
+
* Optional UI/docs-only deprecation metadata.
|
|
10071
|
+
*/
|
|
10072
|
+
get deprecation() {
|
|
10073
|
+
return {
|
|
10074
|
+
message: 'Use `GOAL` for agent profile text and inheritance-safe rewrites.',
|
|
10075
|
+
replacedBy: ['GOAL'],
|
|
10076
|
+
};
|
|
10072
10077
|
}
|
|
10073
10078
|
/**
|
|
10074
10079
|
* Icon for this commitment.
|
|
@@ -10083,16 +10088,24 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
10083
10088
|
return spaceTrim$1(`
|
|
10084
10089
|
# ${this.type}
|
|
10085
10090
|
|
|
10086
|
-
|
|
10091
|
+
Deprecated legacy commitment that defines who the agent is, their background, expertise, and personality traits.
|
|
10087
10092
|
|
|
10088
|
-
##
|
|
10093
|
+
## Migration
|
|
10089
10094
|
|
|
10090
|
-
-
|
|
10091
|
-
-
|
|
10092
|
-
-
|
|
10093
|
-
-
|
|
10095
|
+
- Existing \`${this.type}\` books still parse and compile.
|
|
10096
|
+
- New books should prefer \`GOAL\`.
|
|
10097
|
+
- Agent profile rendering now prefers the last \`GOAL\` and only falls back to \`${this.type}\` when no goal exists.
|
|
10098
|
+
- Runtime compilation keeps the legacy multi-\`PERSONA\` merge behavior for backward compatibility.
|
|
10094
10099
|
|
|
10095
|
-
##
|
|
10100
|
+
## Preferred replacement
|
|
10101
|
+
|
|
10102
|
+
\`\`\`book
|
|
10103
|
+
Programming Assistant
|
|
10104
|
+
|
|
10105
|
+
GOAL Help the user solve programming problems with practical TypeScript and React guidance.
|
|
10106
|
+
\`\`\`
|
|
10107
|
+
|
|
10108
|
+
## Legacy compatibility example
|
|
10096
10109
|
|
|
10097
10110
|
\`\`\`book
|
|
10098
10111
|
Programming Assistant
|
|
@@ -10800,6 +10813,15 @@ const teamToolFunctions = {};
|
|
|
10800
10813
|
* Map of team tool titles.
|
|
10801
10814
|
*/
|
|
10802
10815
|
const teamToolTitles = {};
|
|
10816
|
+
/**
|
|
10817
|
+
* Shared TEAM usage rules appended ahead of teammate listings.
|
|
10818
|
+
*
|
|
10819
|
+
* @private
|
|
10820
|
+
*/
|
|
10821
|
+
const TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES = [
|
|
10822
|
+
'- If a teammate is relevant to the request, consult that teammate using the matching tool.',
|
|
10823
|
+
'- Do not ask the user for information that a listed teammate can provide directly.',
|
|
10824
|
+
];
|
|
10803
10825
|
/**
|
|
10804
10826
|
* Constant for remote agents by Url.
|
|
10805
10827
|
*/
|
|
@@ -10848,7 +10870,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
10848
10870
|
\`\`\`book
|
|
10849
10871
|
Legal Assistant
|
|
10850
10872
|
|
|
10851
|
-
|
|
10873
|
+
GOAL Get expert software-development advice from the teammate when legal discussion needs technical context.
|
|
10852
10874
|
TEAM You can talk with http://localhost:4440/agents/GMw67JN8TXxN7y to discuss the legal aspects.
|
|
10853
10875
|
\`\`\`
|
|
10854
10876
|
`);
|
|
@@ -10889,12 +10911,9 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
10889
10911
|
if (updatedTools.some((tool) => tool.name === entry.toolName)) {
|
|
10890
10912
|
continue;
|
|
10891
10913
|
}
|
|
10892
|
-
const toolDescription = entry.description
|
|
10893
|
-
? `Consult teammate ${entry.teammate.label}\n${entry.description}`
|
|
10894
|
-
: `Consult teammate ${entry.teammate.label}`;
|
|
10895
10914
|
updatedTools.push({
|
|
10896
10915
|
name: entry.toolName,
|
|
10897
|
-
description:
|
|
10916
|
+
description: buildTeamToolDescription(entry),
|
|
10898
10917
|
parameters: {
|
|
10899
10918
|
type: 'object',
|
|
10900
10919
|
properties: {
|
|
@@ -10963,22 +10982,72 @@ function resolveTeamTeammateLabels(teamContent, teammates) {
|
|
|
10963
10982
|
/**
|
|
10964
10983
|
* Builds the textual TEAM section body for the final system message.
|
|
10965
10984
|
*
|
|
10966
|
-
* Each teammate is listed with its tool name
|
|
10967
|
-
* Uses `spaceTrim` to ensure consistent whitespace and indentation.
|
|
10985
|
+
* Each teammate is listed with its tool name, TEAM instructions, and optional profile hints.
|
|
10968
10986
|
*/
|
|
10969
10987
|
function buildTeamSystemMessageBody(teamEntries) {
|
|
10970
|
-
const lines =
|
|
10971
|
-
|
|
10972
|
-
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
|
|
10976
|
-
|
|
10977
|
-
|
|
10978
|
-
|
|
10979
|
-
});
|
|
10988
|
+
const lines = [
|
|
10989
|
+
...TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES,
|
|
10990
|
+
'',
|
|
10991
|
+
...teamEntries.map((entry, index) => {
|
|
10992
|
+
const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
|
|
10993
|
+
const detailLines = collectTeamEntryDetails(entry).map(formatTeamEntryDetailLine);
|
|
10994
|
+
return [toolLine, ...detailLines].join('\n');
|
|
10995
|
+
}),
|
|
10996
|
+
];
|
|
10980
10997
|
return lines.join('\n');
|
|
10981
10998
|
}
|
|
10999
|
+
/**
|
|
11000
|
+
* Builds the model-visible description for one teammate tool.
|
|
11001
|
+
*
|
|
11002
|
+
* @private
|
|
11003
|
+
*/
|
|
11004
|
+
function buildTeamToolDescription(entry) {
|
|
11005
|
+
const detailLines = collectTeamEntryDetails(entry).map(({ label, content }) => `${label}: ${content}`);
|
|
11006
|
+
return [`Consult teammate ${entry.teammate.label}`, ...detailLines].join('\n');
|
|
11007
|
+
}
|
|
11008
|
+
/**
|
|
11009
|
+
* Collects structured teammate details that should stay visible to the model.
|
|
11010
|
+
*
|
|
11011
|
+
* @private
|
|
11012
|
+
*/
|
|
11013
|
+
function collectTeamEntryDetails(entry) {
|
|
11014
|
+
var _a;
|
|
11015
|
+
const details = [];
|
|
11016
|
+
const instructions = entry.teammate.instructions.trim();
|
|
11017
|
+
const description = ((_a = entry.description) === null || _a === void 0 ? void 0 : _a.trim()) || '';
|
|
11018
|
+
if (instructions) {
|
|
11019
|
+
details.push({
|
|
11020
|
+
label: 'TEAM instructions',
|
|
11021
|
+
content: instructions,
|
|
11022
|
+
});
|
|
11023
|
+
}
|
|
11024
|
+
if (description) {
|
|
11025
|
+
details.push({
|
|
11026
|
+
label: 'Profile',
|
|
11027
|
+
content: description,
|
|
11028
|
+
});
|
|
11029
|
+
}
|
|
11030
|
+
return details;
|
|
11031
|
+
}
|
|
11032
|
+
/**
|
|
11033
|
+
* Formats one teammate detail line for the TEAM system-message section.
|
|
11034
|
+
*
|
|
11035
|
+
* @private
|
|
11036
|
+
*/
|
|
11037
|
+
function formatTeamEntryDetailLine(detail) {
|
|
11038
|
+
return indentMultilineText(`${detail.label}: ${detail.content}`, ' ');
|
|
11039
|
+
}
|
|
11040
|
+
/**
|
|
11041
|
+
* Indents all lines of one potentially multi-line text block.
|
|
11042
|
+
*
|
|
11043
|
+
* @private
|
|
11044
|
+
*/
|
|
11045
|
+
function indentMultilineText(text, prefix) {
|
|
11046
|
+
return text
|
|
11047
|
+
.split('\n')
|
|
11048
|
+
.map((line) => `${prefix}${line}`)
|
|
11049
|
+
.join('\n');
|
|
11050
|
+
}
|
|
10982
11051
|
/**
|
|
10983
11052
|
* Registers tool function and title for a teammate tool.
|
|
10984
11053
|
*/
|
|
@@ -17390,7 +17459,7 @@ function parseParameters(text) {
|
|
|
17390
17459
|
function parseAgentSource(agentSource) {
|
|
17391
17460
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
17392
17461
|
const resolvedAgentName = parseResult.agentName || createDefaultAgentName(agentSource);
|
|
17393
|
-
const personaDescription =
|
|
17462
|
+
const personaDescription = extractAgentProfileText(parseResult.commitments);
|
|
17394
17463
|
const initialMessage = extractInitialMessage(parseResult.commitments);
|
|
17395
17464
|
const parsedProfile = extractParsedAgentProfile(parseResult.commitments);
|
|
17396
17465
|
ensureMetaFullname(parsedProfile.meta, resolvedAgentName);
|
|
@@ -17494,25 +17563,33 @@ const META_COMMITMENT_APPLIERS = {
|
|
|
17494
17563
|
*/
|
|
17495
17564
|
const LOCAL_AGENT_REFERENCE_PREFIXES = ['./', '../', '/'];
|
|
17496
17565
|
/**
|
|
17497
|
-
*
|
|
17566
|
+
* Resolves the public agent profile text from the last GOAL/GOALS commitment,
|
|
17567
|
+
* falling back to the deprecated PERSONA/PERSONAE commitments when no goal exists.
|
|
17498
17568
|
*
|
|
17499
17569
|
* @private internal utility of `parseAgentSource`
|
|
17500
17570
|
*/
|
|
17501
|
-
function
|
|
17502
|
-
let
|
|
17571
|
+
function extractAgentProfileText(commitments) {
|
|
17572
|
+
let goalDescription = '';
|
|
17573
|
+
let hasGoalDescription = false;
|
|
17574
|
+
let personaDescription = '';
|
|
17575
|
+
let hasPersonaDescription = false;
|
|
17503
17576
|
for (const commitment of commitments) {
|
|
17504
|
-
if (commitment.type
|
|
17505
|
-
|
|
17577
|
+
if (commitment.type === 'GOAL' || commitment.type === 'GOALS') {
|
|
17578
|
+
goalDescription = commitment.content;
|
|
17579
|
+
hasGoalDescription = true;
|
|
17506
17580
|
}
|
|
17507
|
-
if (
|
|
17508
|
-
personaDescription =
|
|
17581
|
+
if (commitment.type === 'PERSONA' || commitment.type === 'PERSONAE') {
|
|
17582
|
+
personaDescription = commitment.content;
|
|
17583
|
+
hasPersonaDescription = true;
|
|
17509
17584
|
}
|
|
17510
|
-
else {
|
|
17511
|
-
personaDescription += `\n\n${personaDescription}`;
|
|
17512
|
-
}
|
|
17513
|
-
personaDescription += commitment.content;
|
|
17514
17585
|
}
|
|
17515
|
-
|
|
17586
|
+
if (hasGoalDescription) {
|
|
17587
|
+
return goalDescription;
|
|
17588
|
+
}
|
|
17589
|
+
if (hasPersonaDescription) {
|
|
17590
|
+
return personaDescription;
|
|
17591
|
+
}
|
|
17592
|
+
return null;
|
|
17516
17593
|
}
|
|
17517
17594
|
/**
|
|
17518
17595
|
* Resolves the last INITIAL MESSAGE commitment, which is the public initial-message value.
|
|
@@ -30916,7 +30993,7 @@ function createEmptyAgentModelRequirements() {
|
|
|
30916
30993
|
systemMessage: '',
|
|
30917
30994
|
promptSuffix: '',
|
|
30918
30995
|
// modelName: 'gpt-5',
|
|
30919
|
-
modelName: '
|
|
30996
|
+
modelName: 'gpt-5.4-mini',
|
|
30920
30997
|
temperature: 0.7,
|
|
30921
30998
|
topP: 0.9,
|
|
30922
30999
|
topK: 50,
|
|
@@ -31065,6 +31142,15 @@ const COMMITMENTS_WITH_AGENT_REFERENCES = new Set(['FROM', 'IMPORT', 'IMPORTS',
|
|
|
31065
31142
|
* @private internal constant of `createAgentModelRequirementsWithCommitments`
|
|
31066
31143
|
*/
|
|
31067
31144
|
const DELETE_COMMITMENT_TYPES = new Set(['DELETE', 'CANCEL', 'DISCARD', 'REMOVE']);
|
|
31145
|
+
/**
|
|
31146
|
+
* Commitments whose earlier occurrences are overwritten by the last occurrence in source order.
|
|
31147
|
+
*
|
|
31148
|
+
* @private internal constant of `createAgentModelRequirementsWithCommitments`
|
|
31149
|
+
*/
|
|
31150
|
+
const OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE = new Map([
|
|
31151
|
+
['GOAL', 'GOAL'],
|
|
31152
|
+
['GOALS', 'GOAL'],
|
|
31153
|
+
]);
|
|
31068
31154
|
/**
|
|
31069
31155
|
* Regex pattern matching markdown horizontal lines that should not be copied into the final system message.
|
|
31070
31156
|
*
|
|
@@ -31115,7 +31201,7 @@ function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
|
|
|
31115
31201
|
*/
|
|
31116
31202
|
async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
|
|
31117
31203
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
31118
|
-
const filteredCommitments = filterDeletedCommitments(parseResult.commitments);
|
|
31204
|
+
const filteredCommitments = filterOverwrittenCommitments(filterDeletedCommitments(parseResult.commitments));
|
|
31119
31205
|
let requirements = createInitialAgentModelRequirements(parseResult.agentName, modelName);
|
|
31120
31206
|
requirements = await applyCommitmentsToRequirements(requirements, filteredCommitments, options);
|
|
31121
31207
|
requirements = aggregateUseCommitmentSystemMessages(requirements, filteredCommitments);
|
|
@@ -31126,6 +31212,35 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
|
|
|
31126
31212
|
requirements = await applyPendingInlineKnowledgeSources(requirements, options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader);
|
|
31127
31213
|
return finalizeRequirements(requirements);
|
|
31128
31214
|
}
|
|
31215
|
+
/**
|
|
31216
|
+
* Removes earlier commitments that are overwritten by later commitments of the same semantic group.
|
|
31217
|
+
*
|
|
31218
|
+
* This currently keeps only the last `GOAL` / `GOALS` commitment so inheritance rewrites
|
|
31219
|
+
* and multi-goal sources expose one effective goal to the runtime.
|
|
31220
|
+
*
|
|
31221
|
+
* @param commitments - Parsed commitments after DELETE-like filtering.
|
|
31222
|
+
* @returns Commitments with overwritten entries removed while preserving source order.
|
|
31223
|
+
*
|
|
31224
|
+
* @private internal utility of `createAgentModelRequirementsWithCommitments`
|
|
31225
|
+
*/
|
|
31226
|
+
function filterOverwrittenCommitments(commitments) {
|
|
31227
|
+
const seenOverwriteGroups = new Set();
|
|
31228
|
+
const keptCommitments = [];
|
|
31229
|
+
for (let index = commitments.length - 1; index >= 0; index--) {
|
|
31230
|
+
const commitment = commitments[index];
|
|
31231
|
+
const overwriteGroup = OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE.get(commitment.type);
|
|
31232
|
+
if (!overwriteGroup) {
|
|
31233
|
+
keptCommitments.push(commitment);
|
|
31234
|
+
continue;
|
|
31235
|
+
}
|
|
31236
|
+
if (seenOverwriteGroups.has(overwriteGroup)) {
|
|
31237
|
+
continue;
|
|
31238
|
+
}
|
|
31239
|
+
seenOverwriteGroups.add(overwriteGroup);
|
|
31240
|
+
keptCommitments.push(commitment);
|
|
31241
|
+
}
|
|
31242
|
+
return keptCommitments.reverse();
|
|
31243
|
+
}
|
|
31129
31244
|
/**
|
|
31130
31245
|
* Creates the initial requirements object with the parsed agent name stored in metadata and an optional model override.
|
|
31131
31246
|
*
|
|
@@ -31717,7 +31832,7 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
|
|
|
31717
31832
|
* Selects the best model using the preparePersona function
|
|
31718
31833
|
* This directly uses preparePersona to ensure DRY principle
|
|
31719
31834
|
*
|
|
31720
|
-
* @param agentSource The agent source to derive
|
|
31835
|
+
* @param agentSource The agent source to derive effective profile text from
|
|
31721
31836
|
* @param llmTools LLM tools for preparing persona
|
|
31722
31837
|
* @returns The name of the best selected model
|
|
31723
31838
|
*
|
|
@@ -31725,9 +31840,9 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
|
|
|
31725
31840
|
*/
|
|
31726
31841
|
async function selectBestModelUsingPersona(agentSource, llmTools) {
|
|
31727
31842
|
var _a;
|
|
31728
|
-
// Parse agent source to get
|
|
31843
|
+
// Parse agent source to get the effective profile description
|
|
31729
31844
|
const { agentName, personaDescription } = parseAgentSource(agentSource);
|
|
31730
|
-
// Use agent name as fallback if no
|
|
31845
|
+
// Use agent name as fallback if no profile description is available
|
|
31731
31846
|
const description = personaDescription || agentName || 'AI Agent';
|
|
31732
31847
|
try {
|
|
31733
31848
|
// Use preparePersona directly
|
|
@@ -35787,7 +35902,7 @@ class OpenAiVectorStoreHandler extends OpenAiExecutionTools {
|
|
|
35787
35902
|
/**
|
|
35788
35903
|
* Constant for default agent kit model name.
|
|
35789
35904
|
*/
|
|
35790
|
-
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-
|
|
35905
|
+
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-mini';
|
|
35791
35906
|
/**
|
|
35792
35907
|
* Creates one structured log entry for streamed tool-call updates.
|
|
35793
35908
|
*
|
|
@@ -37853,6 +37968,7 @@ class AgentLlmExecutionTools {
|
|
|
37853
37968
|
* @param agentSource The agent source string that defines the agent's behavior
|
|
37854
37969
|
*/
|
|
37855
37970
|
constructor(options) {
|
|
37971
|
+
var _a;
|
|
37856
37972
|
this.options = options;
|
|
37857
37973
|
/**
|
|
37858
37974
|
* Cached model requirements to avoid re-parsing the agent source
|
|
@@ -37862,6 +37978,7 @@ class AgentLlmExecutionTools {
|
|
|
37862
37978
|
* Cached parsed agent information
|
|
37863
37979
|
*/
|
|
37864
37980
|
this._cachedAgentInfo = null;
|
|
37981
|
+
this.precomputedModelRequirements = (_a = options.precomputedModelRequirements) !== null && _a !== void 0 ? _a : null;
|
|
37865
37982
|
}
|
|
37866
37983
|
/**
|
|
37867
37984
|
* Updates the agent source and clears the cache
|
|
@@ -37869,9 +37986,13 @@ class AgentLlmExecutionTools {
|
|
|
37869
37986
|
* @param agentSource The new agent source string
|
|
37870
37987
|
*/
|
|
37871
37988
|
updateAgentSource(agentSource) {
|
|
37989
|
+
if (this.options.agentSource === agentSource) {
|
|
37990
|
+
return;
|
|
37991
|
+
}
|
|
37872
37992
|
this.options.agentSource = agentSource;
|
|
37873
37993
|
this._cachedAgentInfo = null;
|
|
37874
37994
|
this._cachedModelRequirements = null;
|
|
37995
|
+
this.precomputedModelRequirements = null;
|
|
37875
37996
|
}
|
|
37876
37997
|
/**
|
|
37877
37998
|
* Get cached or parse agent information
|
|
@@ -37888,6 +38009,16 @@ class AgentLlmExecutionTools {
|
|
|
37888
38009
|
* Note: [🐤] This is names `getModelRequirements` *(not `getAgentModelRequirements`)* because in future these two will be united
|
|
37889
38010
|
*/
|
|
37890
38011
|
async getModelRequirements() {
|
|
38012
|
+
var _a, _b;
|
|
38013
|
+
if (this.precomputedModelRequirements !== null) {
|
|
38014
|
+
if (this.options.isVerbose) {
|
|
38015
|
+
console.info('[🤰]', 'Using precomputed agent model requirements', {
|
|
38016
|
+
agent: this.title,
|
|
38017
|
+
toolCount: (_b = (_a = this.precomputedModelRequirements.tools) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
|
|
38018
|
+
});
|
|
38019
|
+
}
|
|
38020
|
+
return this.precomputedModelRequirements;
|
|
38021
|
+
}
|
|
37891
38022
|
if (this._cachedModelRequirements === null) {
|
|
37892
38023
|
const preparationStartedAtMs = Date.now();
|
|
37893
38024
|
if (this.options.isVerbose) {
|
|
@@ -37997,6 +38128,7 @@ class AgentLlmExecutionTools {
|
|
|
37997
38128
|
* Resolves agent requirements, attachments, and runtime overrides into one forwarded chat prompt.
|
|
37998
38129
|
*/
|
|
37999
38130
|
async prepareChatPrompt(prompt) {
|
|
38131
|
+
var _a;
|
|
38000
38132
|
const chatPrompt = this.requireChatPrompt(prompt);
|
|
38001
38133
|
const { sanitizedRequirements, promptSuffix } = await this.getSanitizedAgentModelRequirements();
|
|
38002
38134
|
const attachments = normalizeChatAttachments(chatPrompt.attachments);
|
|
@@ -38014,7 +38146,16 @@ class AgentLlmExecutionTools {
|
|
|
38014
38146
|
mergedTools,
|
|
38015
38147
|
knowledgeSourcesForAgent,
|
|
38016
38148
|
});
|
|
38017
|
-
|
|
38149
|
+
if (this.options.isVerbose) {
|
|
38150
|
+
console.info('[🤰]', 'Prepared agent chat prompt', {
|
|
38151
|
+
agent: this.title,
|
|
38152
|
+
usedPrecomputedModelRequirements: this.precomputedModelRequirements !== null,
|
|
38153
|
+
toolNames: mergedTools.map((tool) => tool.name),
|
|
38154
|
+
knowledgeSourcesCount: (_a = knowledgeSourcesForAgent === null || knowledgeSourcesForAgent === void 0 ? void 0 : knowledgeSourcesForAgent.length) !== null && _a !== void 0 ? _a : 0,
|
|
38155
|
+
promptSuffixLength: promptSuffix.length,
|
|
38156
|
+
systemMessageLength: sanitizedRequirements.systemMessage.length,
|
|
38157
|
+
});
|
|
38158
|
+
}
|
|
38018
38159
|
return {
|
|
38019
38160
|
forwardedPrompt,
|
|
38020
38161
|
sanitizedRequirements,
|
|
@@ -38201,6 +38342,7 @@ class AgentLlmExecutionTools {
|
|
|
38201
38342
|
* Runs one prepared prompt through the deprecated OpenAI Assistant backend.
|
|
38202
38343
|
*/
|
|
38203
38344
|
async callOpenAiAssistantChatModelStream(options) {
|
|
38345
|
+
var _a, _b, _c, _d;
|
|
38204
38346
|
const assistant = await this.getOrPrepareOpenAiAssistant({
|
|
38205
38347
|
llmTools: options.llmTools,
|
|
38206
38348
|
originalPrompt: options.originalPrompt,
|
|
@@ -38208,7 +38350,14 @@ class AgentLlmExecutionTools {
|
|
|
38208
38350
|
onProgress: options.onProgress,
|
|
38209
38351
|
});
|
|
38210
38352
|
const promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools = createOpenAiAssistantPrompt(options.preparedChatPrompt.forwardedPrompt);
|
|
38211
|
-
|
|
38353
|
+
if (this.options.isVerbose) {
|
|
38354
|
+
console.info('[🤰]', 'Prepared OpenAI Assistant prompt', {
|
|
38355
|
+
agent: this.title,
|
|
38356
|
+
toolNames: (_b = (_a = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements.tools) === null || _a === void 0 ? void 0 : _a.map((tool) => tool.name)) !== null && _b !== void 0 ? _b : [],
|
|
38357
|
+
knowledgeSourcesCount: (_d = (_c = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements
|
|
38358
|
+
.knowledgeSources) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
|
|
38359
|
+
});
|
|
38360
|
+
}
|
|
38212
38361
|
return assistant.callChatModelStream(promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools, options.onProgress, options.streamOptions);
|
|
38213
38362
|
}
|
|
38214
38363
|
/**
|
|
@@ -38899,7 +39048,8 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
38899
39048
|
isVerbose: options.isVerbose,
|
|
38900
39049
|
llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
|
|
38901
39050
|
assistantPreparationMode: options.assistantPreparationMode,
|
|
38902
|
-
agentSource: agentSource.value,
|
|
39051
|
+
agentSource: agentSource.value,
|
|
39052
|
+
precomputedModelRequirements: options.precomputedModelRequirements,
|
|
38903
39053
|
});
|
|
38904
39054
|
this._agentName = undefined;
|
|
38905
39055
|
/**
|
|
@@ -43162,7 +43312,7 @@ const ChatMessageItem = memo(
|
|
|
43162
43312
|
// <- TODO: [🧠] Should we wrap more components in `React.memo`
|
|
43163
43313
|
// Or make normal function from this?
|
|
43164
43314
|
(props) => {
|
|
43165
|
-
const { message, participant, participants, isLastMessage, onMessage, onActionButton, onQuickMessageButton, setExpandedMessageId, isExpanded, currentRating, handleRating, mode, isCopyButtonEnabled, isFeedbackEnabled, feedbackMode = 'stars', feedbackTranslations, timingTranslations, chatLocale, onCopy, onCreateAgent, toolTitles, teammates, onReplyToMessage, canReplyToMessage, teamAgentProfiles, CHAT_VISUAL_MODE = '
|
|
43315
|
+
const { message, participant, participants, isLastMessage, onMessage, onActionButton, onQuickMessageButton, setExpandedMessageId, isExpanded, currentRating, handleRating, mode, isCopyButtonEnabled, isFeedbackEnabled, feedbackMode = 'stars', feedbackTranslations, timingTranslations, chatLocale, onCopy, onCreateAgent, toolTitles, teammates, onReplyToMessage, canReplyToMessage, teamAgentProfiles, CHAT_VISUAL_MODE = 'ARTICLE_MODE', onToolCallClick, onCitationClick, soundSystem, isSpeechPlaybackEnabled, elevenLabsVoiceId, chatUiTranslations, } = props;
|
|
43166
43316
|
const { isComplete = true,
|
|
43167
43317
|
// <- TODO: Destruct all `messages` properties like `isComplete`
|
|
43168
43318
|
} = message;
|
|
@@ -46962,7 +47112,7 @@ function hasChatActions(postprocessedMessages, { onReset, newChatButtonHref, onU
|
|
|
46962
47112
|
* @public exported from `@promptbook/components`
|
|
46963
47113
|
*/
|
|
46964
47114
|
function Chat(props) {
|
|
46965
|
-
const { title = 'Chat', messages, onChange, onMessage, onActionButton, onQuickMessageButton, onReplyToMessage, onCancelReply, onReset, resetRequiresConfirmation = true, newChatButtonHref, onFeedback, feedbackMode = 'stars', feedbackTranslations, timingTranslations, onFileUpload, chatLocale, speechRecognition, placeholderMessageContent, defaultMessage, enterBehavior, resolveEnterBehavior, children, className, style, isAiTextHumanizedAndPromptbookified = true, isVoiceCalling = false, isFocusedOnLoad, participants = [], canReplyToMessage, replyingToMessage, extraActions, actionsContainer, saveFormats, isSaveButtonEnabled = true, isCopyButtonEnabled = true, buttonColor: buttonColorRaw, onUseTemplate, onCreateAgent, toolTitles, teammates, teamAgentProfiles, visual, CHAT_VISUAL_MODE = '
|
|
47115
|
+
const { title = 'Chat', messages, onChange, onMessage, onActionButton, onQuickMessageButton, onReplyToMessage, onCancelReply, onReset, resetRequiresConfirmation = true, newChatButtonHref, onFeedback, feedbackMode = 'stars', feedbackTranslations, timingTranslations, onFileUpload, chatLocale, speechRecognition, placeholderMessageContent, defaultMessage, enterBehavior, resolveEnterBehavior, children, className, style, isAiTextHumanizedAndPromptbookified = true, isVoiceCalling = false, isFocusedOnLoad, participants = [], canReplyToMessage, replyingToMessage, extraActions, actionsContainer, saveFormats, isSaveButtonEnabled = true, isCopyButtonEnabled = true, buttonColor: buttonColorRaw, onUseTemplate, onCreateAgent, toolTitles, teammates, teamAgentProfiles, visual, CHAT_VISUAL_MODE = 'ARTICLE_MODE', effectConfigs, soundSystem, speechRecognitionLanguage, isSpeechPlaybackEnabled = true, elevenLabsVoiceId, chatUiTranslations, } = props;
|
|
46966
47116
|
const buttonColor = useMemo(() => Color.from(buttonColorRaw || '#0066cc'), [buttonColorRaw]);
|
|
46967
47117
|
const agentParticipant = useMemo(() => participants.find((participant) => participant.name === 'AGENT'), [participants]);
|
|
46968
47118
|
const postprocessedMessages = useChatPostprocessedMessages({
|