@promptbook/browser 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 +207 -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 +2 -2
- package/umd/index.umd.js +207 -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
|
@@ -466,6 +466,7 @@ Prompts marked with `[-]` are not ready yet, prompts containing `@@@` are treate
|
|
|
466
466
|
- **Reasoning control:** `--thinking-level low|medium|high|xhigh` for supported runners
|
|
467
467
|
- **Interactive or unattended runs:** default wait mode, or `--no-wait` for batch execution
|
|
468
468
|
- **Git safety:** clean working tree check by default, optional `--ignore-git-changes`
|
|
469
|
+
- **Opt-in remote pushes:** commits stay local unless you explicitly pass `--auto-push`
|
|
469
470
|
- **Prompt triage:** `--priority` to process only more important tasks first
|
|
470
471
|
- **Failure logging:** failed runs write a neighboring `.error.log`
|
|
471
472
|
- **Line-ending normalization:** changed files are normalized back to LF by default
|
|
@@ -483,6 +484,8 @@ npx ts-node ./src/cli/test/ptbk.ts coder generate-boilerplates --template prompt
|
|
|
483
484
|
|
|
484
485
|
npx ts-node ./src/cli/test/ptbk.ts coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md
|
|
485
486
|
|
|
487
|
+
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
|
|
488
|
+
|
|
486
489
|
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
|
|
487
490
|
|
|
488
491
|
npx ts-node ./src/cli/test/ptbk.ts coder find-refactor-candidates
|
|
@@ -505,9 +508,11 @@ npx ptbk coder generate-boilerplates
|
|
|
505
508
|
|
|
506
509
|
npx ptbk coder generate-boilerplates --template prompts/templates/common.md
|
|
507
510
|
|
|
508
|
-
npx ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md
|
|
511
|
+
npx ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --test npm run test
|
|
512
|
+
|
|
513
|
+
npx ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --auto-push
|
|
509
514
|
|
|
510
|
-
npx ptbk coder run --agent github-copilot --model gpt-5.4 --thinking-level xhigh --context AGENTS.md --ignore-git-changes --no-wait
|
|
515
|
+
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
|
|
511
516
|
|
|
512
517
|
npx ptbk coder find-refactor-candidates
|
|
513
518
|
|
|
@@ -524,7 +529,7 @@ npx ptbk coder verify
|
|
|
524
529
|
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | ------ | ---- | ----- | ------------------------------------------------------------------------ |
|
|
525
530
|
| `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/`. |
|
|
526
531
|
| `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. |
|
|
527
|
-
| `ptbk coder run` | Picks the next ready prompt, appends optional context, runs it through the selected coding agent, marks success or failure,
|
|
532
|
+
| `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. |
|
|
528
533
|
| `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. |
|
|
529
534
|
| `ptbk coder verify` | Walks through completed prompts, archives truly finished work, and adds follow-up repair prompts for unfinished results. |
|
|
530
535
|
|
|
@@ -535,12 +540,14 @@ npx ptbk coder verify
|
|
|
535
540
|
| `--agent <name>` | Selects the coding backend. |
|
|
536
541
|
| `--model <model>` | Chooses the runner model; required for `openai-codex` and `gemini`, optional for `github-copilot`. |
|
|
537
542
|
| `--context <text-or-file>` | Appends extra instructions inline or from a file like `AGENTS.md`. |
|
|
543
|
+
| `--test <command>` | Runs a verification command after each prompt attempt and feeds failing output back for retries. |
|
|
538
544
|
| `--thinking-level <level>` | Sets reasoning effort for supported runners. |
|
|
539
545
|
| `--no-wait` | Skips interactive pauses between prompts for unattended execution. |
|
|
540
546
|
| `--ignore-git-changes` | Disables the clean-working-tree guard. |
|
|
541
547
|
| `--priority <n>` | Runs only prompts at or above the given priority. |
|
|
542
548
|
| `--dry-run` | Prints which prompts are ready instead of executing them. |
|
|
543
549
|
| `--allow-credits` | Lets OpenAI Codex spend credits when required. |
|
|
550
|
+
| `--auto-push` | Pushes each successful coding-agent commit to the configured remote. |
|
|
544
551
|
| `--auto-migrate` | Runs testing-server database migrations after each successful prompt. |
|
|
545
552
|
|
|
546
553
|
#### Typical usage pattern
|
package/esm/index.es.js
CHANGED
|
@@ -29,7 +29,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
29
29
|
* @generated
|
|
30
30
|
* @see https://github.com/webgptorg/promptbook
|
|
31
31
|
*/
|
|
32
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
32
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-44';
|
|
33
33
|
/**
|
|
34
34
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
35
35
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -6481,7 +6481,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6481
6481
|
* Short one-line description of GOAL.
|
|
6482
6482
|
*/
|
|
6483
6483
|
get description() {
|
|
6484
|
-
return 'Define
|
|
6484
|
+
return 'Define the effective agent **goal**; when multiple goals exist, only the last one stays effective.';
|
|
6485
6485
|
}
|
|
6486
6486
|
/**
|
|
6487
6487
|
* Icon for this commitment.
|
|
@@ -6496,12 +6496,14 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6496
6496
|
return spaceTrim$1(`
|
|
6497
6497
|
# ${this.type}
|
|
6498
6498
|
|
|
6499
|
-
Defines the main goal which should be achieved by the AI assistant.
|
|
6499
|
+
Defines the main goal which should be achieved by the AI assistant.
|
|
6500
|
+
There can be multiple goals in source, but after inheritance/source rewriting only the last \`GOAL\` /\`GOALS\` remains effective.
|
|
6500
6501
|
|
|
6501
6502
|
## Key aspects
|
|
6502
6503
|
|
|
6503
6504
|
- Both terms work identically and can be used interchangeably.
|
|
6504
|
-
- Later goals
|
|
6505
|
+
- Later goals overwrite earlier goals.
|
|
6506
|
+
- The public agent profile text is derived from the last goal.
|
|
6505
6507
|
- Goals provide clear direction and purpose for the agent's responses.
|
|
6506
6508
|
- Goals influence decision-making and response prioritization.
|
|
6507
6509
|
|
|
@@ -6514,9 +6516,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6514
6516
|
\`\`\`book
|
|
6515
6517
|
Customer Support Agent
|
|
6516
6518
|
|
|
6517
|
-
PERSONA You are a helpful customer support representative
|
|
6518
6519
|
GOAL Resolve customer issues quickly and efficiently
|
|
6519
|
-
GOAL Maintain high customer satisfaction scores
|
|
6520
6520
|
GOAL Always follow company policies and procedures
|
|
6521
6521
|
RULE Be polite and professional at all times
|
|
6522
6522
|
\`\`\`
|
|
@@ -6524,9 +6524,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6524
6524
|
\`\`\`book
|
|
6525
6525
|
Educational Assistant
|
|
6526
6526
|
|
|
6527
|
-
PERSONA You are an educational assistant specializing in mathematics
|
|
6528
6527
|
GOAL Help students understand mathematical concepts clearly
|
|
6529
|
-
GOAL Encourage critical thinking and problem-solving skills
|
|
6530
6528
|
GOAL Ensure all explanations are age-appropriate and accessible
|
|
6531
6529
|
STYLE Use simple language and provide step-by-step explanations
|
|
6532
6530
|
\`\`\`
|
|
@@ -6534,9 +6532,7 @@ class GoalCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6534
6532
|
\`\`\`book
|
|
6535
6533
|
Safety-First Assistant
|
|
6536
6534
|
|
|
6537
|
-
PERSONA You are a general-purpose AI assistant
|
|
6538
6535
|
GOAL Be helpful and informative in all interactions
|
|
6539
|
-
GOAL Provide accurate and reliable information
|
|
6540
6536
|
GOAL Always prioritize user safety and ethical guidelines
|
|
6541
6537
|
RULE Never provide harmful or dangerous advice
|
|
6542
6538
|
\`\`\`
|
|
@@ -9395,7 +9391,16 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
9395
9391
|
* Short one-line description of PERSONA.
|
|
9396
9392
|
*/
|
|
9397
9393
|
get description() {
|
|
9398
|
-
return '
|
|
9394
|
+
return 'Deprecated legacy profile commitment. Prefer `GOAL` for agent profile text and inheritance-safe rewrites.';
|
|
9395
|
+
}
|
|
9396
|
+
/**
|
|
9397
|
+
* Optional UI/docs-only deprecation metadata.
|
|
9398
|
+
*/
|
|
9399
|
+
get deprecation() {
|
|
9400
|
+
return {
|
|
9401
|
+
message: 'Use `GOAL` for agent profile text and inheritance-safe rewrites.',
|
|
9402
|
+
replacedBy: ['GOAL'],
|
|
9403
|
+
};
|
|
9399
9404
|
}
|
|
9400
9405
|
/**
|
|
9401
9406
|
* Icon for this commitment.
|
|
@@ -9410,16 +9415,24 @@ class PersonaCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
9410
9415
|
return spaceTrim$1(`
|
|
9411
9416
|
# ${this.type}
|
|
9412
9417
|
|
|
9413
|
-
|
|
9418
|
+
Deprecated legacy commitment that defines who the agent is, their background, expertise, and personality traits.
|
|
9414
9419
|
|
|
9415
|
-
##
|
|
9420
|
+
## Migration
|
|
9416
9421
|
|
|
9417
|
-
-
|
|
9418
|
-
-
|
|
9419
|
-
-
|
|
9420
|
-
-
|
|
9422
|
+
- Existing \`${this.type}\` books still parse and compile.
|
|
9423
|
+
- New books should prefer \`GOAL\`.
|
|
9424
|
+
- Agent profile rendering now prefers the last \`GOAL\` and only falls back to \`${this.type}\` when no goal exists.
|
|
9425
|
+
- Runtime compilation keeps the legacy multi-\`PERSONA\` merge behavior for backward compatibility.
|
|
9421
9426
|
|
|
9422
|
-
##
|
|
9427
|
+
## Preferred replacement
|
|
9428
|
+
|
|
9429
|
+
\`\`\`book
|
|
9430
|
+
Programming Assistant
|
|
9431
|
+
|
|
9432
|
+
GOAL Help the user solve programming problems with practical TypeScript and React guidance.
|
|
9433
|
+
\`\`\`
|
|
9434
|
+
|
|
9435
|
+
## Legacy compatibility example
|
|
9423
9436
|
|
|
9424
9437
|
\`\`\`book
|
|
9425
9438
|
Programming Assistant
|
|
@@ -10127,6 +10140,15 @@ const teamToolFunctions = {};
|
|
|
10127
10140
|
* Map of team tool titles.
|
|
10128
10141
|
*/
|
|
10129
10142
|
const teamToolTitles = {};
|
|
10143
|
+
/**
|
|
10144
|
+
* Shared TEAM usage rules appended ahead of teammate listings.
|
|
10145
|
+
*
|
|
10146
|
+
* @private
|
|
10147
|
+
*/
|
|
10148
|
+
const TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES = [
|
|
10149
|
+
'- If a teammate is relevant to the request, consult that teammate using the matching tool.',
|
|
10150
|
+
'- Do not ask the user for information that a listed teammate can provide directly.',
|
|
10151
|
+
];
|
|
10130
10152
|
/**
|
|
10131
10153
|
* Constant for remote agents by Url.
|
|
10132
10154
|
*/
|
|
@@ -10175,7 +10197,7 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
10175
10197
|
\`\`\`book
|
|
10176
10198
|
Legal Assistant
|
|
10177
10199
|
|
|
10178
|
-
|
|
10200
|
+
GOAL Get expert software-development advice from the teammate when legal discussion needs technical context.
|
|
10179
10201
|
TEAM You can talk with http://localhost:4440/agents/GMw67JN8TXxN7y to discuss the legal aspects.
|
|
10180
10202
|
\`\`\`
|
|
10181
10203
|
`);
|
|
@@ -10216,12 +10238,9 @@ class TeamCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
10216
10238
|
if (updatedTools.some((tool) => tool.name === entry.toolName)) {
|
|
10217
10239
|
continue;
|
|
10218
10240
|
}
|
|
10219
|
-
const toolDescription = entry.description
|
|
10220
|
-
? `Consult teammate ${entry.teammate.label}\n${entry.description}`
|
|
10221
|
-
: `Consult teammate ${entry.teammate.label}`;
|
|
10222
10241
|
updatedTools.push({
|
|
10223
10242
|
name: entry.toolName,
|
|
10224
|
-
description:
|
|
10243
|
+
description: buildTeamToolDescription(entry),
|
|
10225
10244
|
parameters: {
|
|
10226
10245
|
type: 'object',
|
|
10227
10246
|
properties: {
|
|
@@ -10290,22 +10309,72 @@ function resolveTeamTeammateLabels(teamContent, teammates) {
|
|
|
10290
10309
|
/**
|
|
10291
10310
|
* Builds the textual TEAM section body for the final system message.
|
|
10292
10311
|
*
|
|
10293
|
-
* Each teammate is listed with its tool name
|
|
10294
|
-
* Uses `spaceTrim` to ensure consistent whitespace and indentation.
|
|
10312
|
+
* Each teammate is listed with its tool name, TEAM instructions, and optional profile hints.
|
|
10295
10313
|
*/
|
|
10296
10314
|
function buildTeamSystemMessageBody(teamEntries) {
|
|
10297
|
-
const lines =
|
|
10298
|
-
|
|
10299
|
-
|
|
10300
|
-
|
|
10301
|
-
|
|
10302
|
-
|
|
10303
|
-
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
});
|
|
10315
|
+
const lines = [
|
|
10316
|
+
...TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES,
|
|
10317
|
+
'',
|
|
10318
|
+
...teamEntries.map((entry, index) => {
|
|
10319
|
+
const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
|
|
10320
|
+
const detailLines = collectTeamEntryDetails(entry).map(formatTeamEntryDetailLine);
|
|
10321
|
+
return [toolLine, ...detailLines].join('\n');
|
|
10322
|
+
}),
|
|
10323
|
+
];
|
|
10307
10324
|
return lines.join('\n');
|
|
10308
10325
|
}
|
|
10326
|
+
/**
|
|
10327
|
+
* Builds the model-visible description for one teammate tool.
|
|
10328
|
+
*
|
|
10329
|
+
* @private
|
|
10330
|
+
*/
|
|
10331
|
+
function buildTeamToolDescription(entry) {
|
|
10332
|
+
const detailLines = collectTeamEntryDetails(entry).map(({ label, content }) => `${label}: ${content}`);
|
|
10333
|
+
return [`Consult teammate ${entry.teammate.label}`, ...detailLines].join('\n');
|
|
10334
|
+
}
|
|
10335
|
+
/**
|
|
10336
|
+
* Collects structured teammate details that should stay visible to the model.
|
|
10337
|
+
*
|
|
10338
|
+
* @private
|
|
10339
|
+
*/
|
|
10340
|
+
function collectTeamEntryDetails(entry) {
|
|
10341
|
+
var _a;
|
|
10342
|
+
const details = [];
|
|
10343
|
+
const instructions = entry.teammate.instructions.trim();
|
|
10344
|
+
const description = ((_a = entry.description) === null || _a === void 0 ? void 0 : _a.trim()) || '';
|
|
10345
|
+
if (instructions) {
|
|
10346
|
+
details.push({
|
|
10347
|
+
label: 'TEAM instructions',
|
|
10348
|
+
content: instructions,
|
|
10349
|
+
});
|
|
10350
|
+
}
|
|
10351
|
+
if (description) {
|
|
10352
|
+
details.push({
|
|
10353
|
+
label: 'Profile',
|
|
10354
|
+
content: description,
|
|
10355
|
+
});
|
|
10356
|
+
}
|
|
10357
|
+
return details;
|
|
10358
|
+
}
|
|
10359
|
+
/**
|
|
10360
|
+
* Formats one teammate detail line for the TEAM system-message section.
|
|
10361
|
+
*
|
|
10362
|
+
* @private
|
|
10363
|
+
*/
|
|
10364
|
+
function formatTeamEntryDetailLine(detail) {
|
|
10365
|
+
return indentMultilineText(`${detail.label}: ${detail.content}`, ' ');
|
|
10366
|
+
}
|
|
10367
|
+
/**
|
|
10368
|
+
* Indents all lines of one potentially multi-line text block.
|
|
10369
|
+
*
|
|
10370
|
+
* @private
|
|
10371
|
+
*/
|
|
10372
|
+
function indentMultilineText(text, prefix) {
|
|
10373
|
+
return text
|
|
10374
|
+
.split('\n')
|
|
10375
|
+
.map((line) => `${prefix}${line}`)
|
|
10376
|
+
.join('\n');
|
|
10377
|
+
}
|
|
10309
10378
|
/**
|
|
10310
10379
|
* Registers tool function and title for a teammate tool.
|
|
10311
10380
|
*/
|
|
@@ -17474,7 +17543,7 @@ function parseParameters(text) {
|
|
|
17474
17543
|
function parseAgentSource(agentSource) {
|
|
17475
17544
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
17476
17545
|
const resolvedAgentName = parseResult.agentName || createDefaultAgentName(agentSource);
|
|
17477
|
-
const personaDescription =
|
|
17546
|
+
const personaDescription = extractAgentProfileText(parseResult.commitments);
|
|
17478
17547
|
const initialMessage = extractInitialMessage(parseResult.commitments);
|
|
17479
17548
|
const parsedProfile = extractParsedAgentProfile(parseResult.commitments);
|
|
17480
17549
|
ensureMetaFullname(parsedProfile.meta, resolvedAgentName);
|
|
@@ -17578,25 +17647,33 @@ const META_COMMITMENT_APPLIERS = {
|
|
|
17578
17647
|
*/
|
|
17579
17648
|
const LOCAL_AGENT_REFERENCE_PREFIXES = ['./', '../', '/'];
|
|
17580
17649
|
/**
|
|
17581
|
-
*
|
|
17650
|
+
* Resolves the public agent profile text from the last GOAL/GOALS commitment,
|
|
17651
|
+
* falling back to the deprecated PERSONA/PERSONAE commitments when no goal exists.
|
|
17582
17652
|
*
|
|
17583
17653
|
* @private internal utility of `parseAgentSource`
|
|
17584
17654
|
*/
|
|
17585
|
-
function
|
|
17586
|
-
let
|
|
17655
|
+
function extractAgentProfileText(commitments) {
|
|
17656
|
+
let goalDescription = '';
|
|
17657
|
+
let hasGoalDescription = false;
|
|
17658
|
+
let personaDescription = '';
|
|
17659
|
+
let hasPersonaDescription = false;
|
|
17587
17660
|
for (const commitment of commitments) {
|
|
17588
|
-
if (commitment.type
|
|
17589
|
-
|
|
17661
|
+
if (commitment.type === 'GOAL' || commitment.type === 'GOALS') {
|
|
17662
|
+
goalDescription = commitment.content;
|
|
17663
|
+
hasGoalDescription = true;
|
|
17590
17664
|
}
|
|
17591
|
-
if (
|
|
17592
|
-
personaDescription =
|
|
17665
|
+
if (commitment.type === 'PERSONA' || commitment.type === 'PERSONAE') {
|
|
17666
|
+
personaDescription = commitment.content;
|
|
17667
|
+
hasPersonaDescription = true;
|
|
17593
17668
|
}
|
|
17594
|
-
else {
|
|
17595
|
-
personaDescription += `\n\n${personaDescription}`;
|
|
17596
|
-
}
|
|
17597
|
-
personaDescription += commitment.content;
|
|
17598
17669
|
}
|
|
17599
|
-
|
|
17670
|
+
if (hasGoalDescription) {
|
|
17671
|
+
return goalDescription;
|
|
17672
|
+
}
|
|
17673
|
+
if (hasPersonaDescription) {
|
|
17674
|
+
return personaDescription;
|
|
17675
|
+
}
|
|
17676
|
+
return null;
|
|
17600
17677
|
}
|
|
17601
17678
|
/**
|
|
17602
17679
|
* Resolves the last INITIAL MESSAGE commitment, which is the public initial-message value.
|
|
@@ -22880,7 +22957,7 @@ function createEmptyAgentModelRequirements() {
|
|
|
22880
22957
|
systemMessage: '',
|
|
22881
22958
|
promptSuffix: '',
|
|
22882
22959
|
// modelName: 'gpt-5',
|
|
22883
|
-
modelName: '
|
|
22960
|
+
modelName: 'gpt-5.4-mini',
|
|
22884
22961
|
temperature: 0.7,
|
|
22885
22962
|
topP: 0.9,
|
|
22886
22963
|
topK: 50,
|
|
@@ -23041,6 +23118,15 @@ const COMMITMENTS_WITH_AGENT_REFERENCES = new Set(['FROM', 'IMPORT', 'IMPORTS',
|
|
|
23041
23118
|
* @private internal constant of `createAgentModelRequirementsWithCommitments`
|
|
23042
23119
|
*/
|
|
23043
23120
|
const DELETE_COMMITMENT_TYPES = new Set(['DELETE', 'CANCEL', 'DISCARD', 'REMOVE']);
|
|
23121
|
+
/**
|
|
23122
|
+
* Commitments whose earlier occurrences are overwritten by the last occurrence in source order.
|
|
23123
|
+
*
|
|
23124
|
+
* @private internal constant of `createAgentModelRequirementsWithCommitments`
|
|
23125
|
+
*/
|
|
23126
|
+
const OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE = new Map([
|
|
23127
|
+
['GOAL', 'GOAL'],
|
|
23128
|
+
['GOALS', 'GOAL'],
|
|
23129
|
+
]);
|
|
23044
23130
|
/**
|
|
23045
23131
|
* Regex pattern matching markdown horizontal lines that should not be copied into the final system message.
|
|
23046
23132
|
*
|
|
@@ -23091,7 +23177,7 @@ function getSafeReferenceCommitmentFallback(commitmentType, originalContent) {
|
|
|
23091
23177
|
*/
|
|
23092
23178
|
async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
|
|
23093
23179
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
23094
|
-
const filteredCommitments = filterDeletedCommitments(parseResult.commitments);
|
|
23180
|
+
const filteredCommitments = filterOverwrittenCommitments(filterDeletedCommitments(parseResult.commitments));
|
|
23095
23181
|
let requirements = createInitialAgentModelRequirements(parseResult.agentName, modelName);
|
|
23096
23182
|
requirements = await applyCommitmentsToRequirements(requirements, filteredCommitments, options);
|
|
23097
23183
|
requirements = aggregateUseCommitmentSystemMessages(requirements, filteredCommitments);
|
|
@@ -23102,6 +23188,35 @@ async function createAgentModelRequirementsWithCommitments(agentSource, modelNam
|
|
|
23102
23188
|
requirements = await applyPendingInlineKnowledgeSources(requirements, options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader);
|
|
23103
23189
|
return finalizeRequirements(requirements);
|
|
23104
23190
|
}
|
|
23191
|
+
/**
|
|
23192
|
+
* Removes earlier commitments that are overwritten by later commitments of the same semantic group.
|
|
23193
|
+
*
|
|
23194
|
+
* This currently keeps only the last `GOAL` / `GOALS` commitment so inheritance rewrites
|
|
23195
|
+
* and multi-goal sources expose one effective goal to the runtime.
|
|
23196
|
+
*
|
|
23197
|
+
* @param commitments - Parsed commitments after DELETE-like filtering.
|
|
23198
|
+
* @returns Commitments with overwritten entries removed while preserving source order.
|
|
23199
|
+
*
|
|
23200
|
+
* @private internal utility of `createAgentModelRequirementsWithCommitments`
|
|
23201
|
+
*/
|
|
23202
|
+
function filterOverwrittenCommitments(commitments) {
|
|
23203
|
+
const seenOverwriteGroups = new Set();
|
|
23204
|
+
const keptCommitments = [];
|
|
23205
|
+
for (let index = commitments.length - 1; index >= 0; index--) {
|
|
23206
|
+
const commitment = commitments[index];
|
|
23207
|
+
const overwriteGroup = OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE.get(commitment.type);
|
|
23208
|
+
if (!overwriteGroup) {
|
|
23209
|
+
keptCommitments.push(commitment);
|
|
23210
|
+
continue;
|
|
23211
|
+
}
|
|
23212
|
+
if (seenOverwriteGroups.has(overwriteGroup)) {
|
|
23213
|
+
continue;
|
|
23214
|
+
}
|
|
23215
|
+
seenOverwriteGroups.add(overwriteGroup);
|
|
23216
|
+
keptCommitments.push(commitment);
|
|
23217
|
+
}
|
|
23218
|
+
return keptCommitments.reverse();
|
|
23219
|
+
}
|
|
23105
23220
|
/**
|
|
23106
23221
|
* Creates the initial requirements object with the parsed agent name stored in metadata and an optional model override.
|
|
23107
23222
|
*
|
|
@@ -23693,7 +23808,7 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
|
|
|
23693
23808
|
* Selects the best model using the preparePersona function
|
|
23694
23809
|
* This directly uses preparePersona to ensure DRY principle
|
|
23695
23810
|
*
|
|
23696
|
-
* @param agentSource The agent source to derive
|
|
23811
|
+
* @param agentSource The agent source to derive effective profile text from
|
|
23697
23812
|
* @param llmTools LLM tools for preparing persona
|
|
23698
23813
|
* @returns The name of the best selected model
|
|
23699
23814
|
*
|
|
@@ -23701,9 +23816,9 @@ async function createAgentModelRequirements(agentSource, modelName, availableMod
|
|
|
23701
23816
|
*/
|
|
23702
23817
|
async function selectBestModelUsingPersona(agentSource, llmTools) {
|
|
23703
23818
|
var _a;
|
|
23704
|
-
// Parse agent source to get
|
|
23819
|
+
// Parse agent source to get the effective profile description
|
|
23705
23820
|
const { agentName, personaDescription } = parseAgentSource(agentSource);
|
|
23706
|
-
// Use agent name as fallback if no
|
|
23821
|
+
// Use agent name as fallback if no profile description is available
|
|
23707
23822
|
const description = personaDescription || agentName || 'AI Agent';
|
|
23708
23823
|
try {
|
|
23709
23824
|
// Use preparePersona directly
|
|
@@ -27474,7 +27589,7 @@ class OpenAiVectorStoreHandler extends OpenAiExecutionTools {
|
|
|
27474
27589
|
/**
|
|
27475
27590
|
* Constant for default agent kit model name.
|
|
27476
27591
|
*/
|
|
27477
|
-
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-
|
|
27592
|
+
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-mini';
|
|
27478
27593
|
/**
|
|
27479
27594
|
* Creates one structured log entry for streamed tool-call updates.
|
|
27480
27595
|
*
|
|
@@ -29540,6 +29655,7 @@ class AgentLlmExecutionTools {
|
|
|
29540
29655
|
* @param agentSource The agent source string that defines the agent's behavior
|
|
29541
29656
|
*/
|
|
29542
29657
|
constructor(options) {
|
|
29658
|
+
var _a;
|
|
29543
29659
|
this.options = options;
|
|
29544
29660
|
/**
|
|
29545
29661
|
* Cached model requirements to avoid re-parsing the agent source
|
|
@@ -29549,6 +29665,7 @@ class AgentLlmExecutionTools {
|
|
|
29549
29665
|
* Cached parsed agent information
|
|
29550
29666
|
*/
|
|
29551
29667
|
this._cachedAgentInfo = null;
|
|
29668
|
+
this.precomputedModelRequirements = (_a = options.precomputedModelRequirements) !== null && _a !== void 0 ? _a : null;
|
|
29552
29669
|
}
|
|
29553
29670
|
/**
|
|
29554
29671
|
* Updates the agent source and clears the cache
|
|
@@ -29556,9 +29673,13 @@ class AgentLlmExecutionTools {
|
|
|
29556
29673
|
* @param agentSource The new agent source string
|
|
29557
29674
|
*/
|
|
29558
29675
|
updateAgentSource(agentSource) {
|
|
29676
|
+
if (this.options.agentSource === agentSource) {
|
|
29677
|
+
return;
|
|
29678
|
+
}
|
|
29559
29679
|
this.options.agentSource = agentSource;
|
|
29560
29680
|
this._cachedAgentInfo = null;
|
|
29561
29681
|
this._cachedModelRequirements = null;
|
|
29682
|
+
this.precomputedModelRequirements = null;
|
|
29562
29683
|
}
|
|
29563
29684
|
/**
|
|
29564
29685
|
* Get cached or parse agent information
|
|
@@ -29575,6 +29696,16 @@ class AgentLlmExecutionTools {
|
|
|
29575
29696
|
* Note: [🐤] This is names `getModelRequirements` *(not `getAgentModelRequirements`)* because in future these two will be united
|
|
29576
29697
|
*/
|
|
29577
29698
|
async getModelRequirements() {
|
|
29699
|
+
var _a, _b;
|
|
29700
|
+
if (this.precomputedModelRequirements !== null) {
|
|
29701
|
+
if (this.options.isVerbose) {
|
|
29702
|
+
console.info('[🤰]', 'Using precomputed agent model requirements', {
|
|
29703
|
+
agent: this.title,
|
|
29704
|
+
toolCount: (_b = (_a = this.precomputedModelRequirements.tools) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
|
|
29705
|
+
});
|
|
29706
|
+
}
|
|
29707
|
+
return this.precomputedModelRequirements;
|
|
29708
|
+
}
|
|
29578
29709
|
if (this._cachedModelRequirements === null) {
|
|
29579
29710
|
const preparationStartedAtMs = Date.now();
|
|
29580
29711
|
if (this.options.isVerbose) {
|
|
@@ -29684,6 +29815,7 @@ class AgentLlmExecutionTools {
|
|
|
29684
29815
|
* Resolves agent requirements, attachments, and runtime overrides into one forwarded chat prompt.
|
|
29685
29816
|
*/
|
|
29686
29817
|
async prepareChatPrompt(prompt) {
|
|
29818
|
+
var _a;
|
|
29687
29819
|
const chatPrompt = this.requireChatPrompt(prompt);
|
|
29688
29820
|
const { sanitizedRequirements, promptSuffix } = await this.getSanitizedAgentModelRequirements();
|
|
29689
29821
|
const attachments = normalizeChatAttachments(chatPrompt.attachments);
|
|
@@ -29701,7 +29833,16 @@ class AgentLlmExecutionTools {
|
|
|
29701
29833
|
mergedTools,
|
|
29702
29834
|
knowledgeSourcesForAgent,
|
|
29703
29835
|
});
|
|
29704
|
-
|
|
29836
|
+
if (this.options.isVerbose) {
|
|
29837
|
+
console.info('[🤰]', 'Prepared agent chat prompt', {
|
|
29838
|
+
agent: this.title,
|
|
29839
|
+
usedPrecomputedModelRequirements: this.precomputedModelRequirements !== null,
|
|
29840
|
+
toolNames: mergedTools.map((tool) => tool.name),
|
|
29841
|
+
knowledgeSourcesCount: (_a = knowledgeSourcesForAgent === null || knowledgeSourcesForAgent === void 0 ? void 0 : knowledgeSourcesForAgent.length) !== null && _a !== void 0 ? _a : 0,
|
|
29842
|
+
promptSuffixLength: promptSuffix.length,
|
|
29843
|
+
systemMessageLength: sanitizedRequirements.systemMessage.length,
|
|
29844
|
+
});
|
|
29845
|
+
}
|
|
29705
29846
|
return {
|
|
29706
29847
|
forwardedPrompt,
|
|
29707
29848
|
sanitizedRequirements,
|
|
@@ -29888,6 +30029,7 @@ class AgentLlmExecutionTools {
|
|
|
29888
30029
|
* Runs one prepared prompt through the deprecated OpenAI Assistant backend.
|
|
29889
30030
|
*/
|
|
29890
30031
|
async callOpenAiAssistantChatModelStream(options) {
|
|
30032
|
+
var _a, _b, _c, _d;
|
|
29891
30033
|
const assistant = await this.getOrPrepareOpenAiAssistant({
|
|
29892
30034
|
llmTools: options.llmTools,
|
|
29893
30035
|
originalPrompt: options.originalPrompt,
|
|
@@ -29895,7 +30037,14 @@ class AgentLlmExecutionTools {
|
|
|
29895
30037
|
onProgress: options.onProgress,
|
|
29896
30038
|
});
|
|
29897
30039
|
const promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools = createOpenAiAssistantPrompt(options.preparedChatPrompt.forwardedPrompt);
|
|
29898
|
-
|
|
30040
|
+
if (this.options.isVerbose) {
|
|
30041
|
+
console.info('[🤰]', 'Prepared OpenAI Assistant prompt', {
|
|
30042
|
+
agent: this.title,
|
|
30043
|
+
toolNames: (_b = (_a = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements.tools) === null || _a === void 0 ? void 0 : _a.map((tool) => tool.name)) !== null && _b !== void 0 ? _b : [],
|
|
30044
|
+
knowledgeSourcesCount: (_d = (_c = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements
|
|
30045
|
+
.knowledgeSources) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
|
|
30046
|
+
});
|
|
30047
|
+
}
|
|
29899
30048
|
return assistant.callChatModelStream(promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools, options.onProgress, options.streamOptions);
|
|
29900
30049
|
}
|
|
29901
30050
|
/**
|
|
@@ -30586,7 +30735,8 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
30586
30735
|
isVerbose: options.isVerbose,
|
|
30587
30736
|
llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
|
|
30588
30737
|
assistantPreparationMode: options.assistantPreparationMode,
|
|
30589
|
-
agentSource: agentSource.value,
|
|
30738
|
+
agentSource: agentSource.value,
|
|
30739
|
+
precomputedModelRequirements: options.precomputedModelRequirements,
|
|
30590
30740
|
});
|
|
30591
30741
|
this._agentName = undefined;
|
|
30592
30742
|
/**
|