@promptbook/node 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
|
@@ -66,7 +66,8 @@ export type AgentBasicInformation = {
|
|
|
66
66
|
permanentId?: string_agent_permanent_id;
|
|
67
67
|
/**
|
|
68
68
|
* Optional description of the agent
|
|
69
|
-
* This is the
|
|
69
|
+
* This is derived from the last `GOAL` / `GOALS` commitment,
|
|
70
|
+
* falling back to deprecated `PERSONA` / `PERSONAE` for backward compatibility.
|
|
70
71
|
*/
|
|
71
72
|
personaDescription: string | null;
|
|
72
73
|
/**
|
|
@@ -9,7 +9,8 @@ export type TeammateProfile = {
|
|
|
9
9
|
*/
|
|
10
10
|
readonly agentName: string;
|
|
11
11
|
/**
|
|
12
|
-
* Short
|
|
12
|
+
* Short profile text for what the agent does, from the last GOAL commitment
|
|
13
|
+
* or deprecated PERSONA fallback.
|
|
13
14
|
*/
|
|
14
15
|
readonly personaDescription: string | null;
|
|
15
16
|
};
|
|
@@ -745,7 +745,7 @@ export type ChatProps = {
|
|
|
745
745
|
* - `BUBBLE_MODE`: keeps the default bubble appearance for all messages.
|
|
746
746
|
* - `ARTICLE_MODE`: keeps user bubbles while rendering assistant replies as borderless article blocks.
|
|
747
747
|
*
|
|
748
|
-
* @default '
|
|
748
|
+
* @default 'ARTICLE_MODE'
|
|
749
749
|
*/
|
|
750
750
|
readonly CHAT_VISUAL_MODE?: ChatVisualMode;
|
|
751
751
|
/**
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Possible runtime shapes returned when importing the `typescript` package.
|
|
3
|
+
*/
|
|
4
|
+
type ImportedTypescriptModule = typeof import('typescript') | {
|
|
5
|
+
default: typeof import('typescript');
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Loads the TypeScript runtime used for parsing JSONC-style project files.
|
|
9
|
+
*
|
|
10
|
+
* @private internal utility of `coder init`
|
|
11
|
+
*/
|
|
12
|
+
export declare function getTypescriptModule(): Promise<typeof import('typescript')>;
|
|
13
|
+
/**
|
|
14
|
+
* Normalizes CommonJS-via-`default` and direct namespace imports of TypeScript.
|
|
15
|
+
*
|
|
16
|
+
* @private internal utility of `getTypescriptModule`
|
|
17
|
+
*/
|
|
18
|
+
export declare function normalizeImportedTypescriptModule(importedTypescriptModule: ImportedTypescriptModule): typeof import('typescript');
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -29,6 +29,13 @@ export declare class PersonaCommitmentDefinition extends BaseCommitmentDefinitio
|
|
|
29
29
|
* Short one-line description of PERSONA.
|
|
30
30
|
*/
|
|
31
31
|
get description(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Optional UI/docs-only deprecation metadata.
|
|
34
|
+
*/
|
|
35
|
+
get deprecation(): {
|
|
36
|
+
readonly message: "Use `GOAL` for agent profile text and inheritance-safe rewrites.";
|
|
37
|
+
readonly replacedBy: readonly ["GOAL"];
|
|
38
|
+
};
|
|
32
39
|
/**
|
|
33
40
|
* Icon for this commitment.
|
|
34
41
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -44,6 +44,10 @@ export declare class AgentLlmExecutionTools implements LlmExecutionTools {
|
|
|
44
44
|
* Cached parsed agent information
|
|
45
45
|
*/
|
|
46
46
|
private _cachedAgentInfo;
|
|
47
|
+
/**
|
|
48
|
+
* Optional server-precomputed model requirements reused until the source changes.
|
|
49
|
+
*/
|
|
50
|
+
private precomputedModelRequirements;
|
|
47
51
|
/**
|
|
48
52
|
* Creates new AgentLlmExecutionTools
|
|
49
53
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { string_book } from '../../book-2.0/agent-source/string_book';
|
|
2
|
+
import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
|
|
2
3
|
import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
|
|
3
4
|
import type { ExecutionTools } from '../../execution/ExecutionTools';
|
|
4
5
|
import type { Updatable } from '../../types/Updatable';
|
|
@@ -27,6 +28,13 @@ export type AgentOptions = CommonToolsOptions & {
|
|
|
27
28
|
* The source of the agent
|
|
28
29
|
*/
|
|
29
30
|
agentSource: Updatable<string_book>;
|
|
31
|
+
/**
|
|
32
|
+
* Optional precomputed model requirements reused until `agentSource` changes.
|
|
33
|
+
*
|
|
34
|
+
* This keeps the actual runtime prompt aligned with server-prepared requirements
|
|
35
|
+
* such as compact-reference-resolved `TEAM` tools.
|
|
36
|
+
*/
|
|
37
|
+
precomputedModelRequirements?: AgentModelRequirements;
|
|
30
38
|
/**
|
|
31
39
|
* Teacher agent for self-learning
|
|
32
40
|
*
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { string_book } from '../../book-2.0/agent-source/string_book';
|
|
2
|
+
import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
|
|
2
3
|
import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
|
|
3
4
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
4
5
|
import type { OpenAiAgentKitExecutionTools } from '../openai/OpenAiAgentKitExecutionTools';
|
|
@@ -25,4 +26,12 @@ export type CreateAgentLlmExecutionToolsOptions = CommonToolsOptions & {
|
|
|
25
26
|
* The agent source string that defines the agent's behavior
|
|
26
27
|
*/
|
|
27
28
|
agentSource: string_book;
|
|
29
|
+
/**
|
|
30
|
+
* Optional precomputed model requirements reused until `agentSource` changes.
|
|
31
|
+
*
|
|
32
|
+
* This is useful for runtimes such as Agents Server that already resolved compact
|
|
33
|
+
* references (for example in `TEAM`) and need the executed prompt to stay aligned
|
|
34
|
+
* with the server-prepared tool list.
|
|
35
|
+
*/
|
|
36
|
+
precomputedModelRequirements?: AgentModelRequirements;
|
|
28
37
|
};
|
package/esm/src/version.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.112.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.112.0-43`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/node",
|
|
3
|
-
"version": "0.112.0-
|
|
3
|
+
"version": "0.112.0-44",
|
|
4
4
|
"description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"module": "./esm/index.es.js",
|
|
97
97
|
"typings": "./esm/typings/src/_packages/node.index.d.ts",
|
|
98
98
|
"peerDependencies": {
|
|
99
|
-
"@promptbook/core": "0.112.0-
|
|
99
|
+
"@promptbook/core": "0.112.0-44"
|
|
100
100
|
},
|
|
101
101
|
"dependencies": {
|
|
102
102
|
"@mozilla/readability": "0.6.0",
|
package/umd/index.umd.js
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
* @generated
|
|
49
49
|
* @see https://github.com/webgptorg/promptbook
|
|
50
50
|
*/
|
|
51
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
51
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-44';
|
|
52
52
|
/**
|
|
53
53
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
54
54
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -15355,7 +15355,7 @@
|
|
|
15355
15355
|
* Short one-line description of GOAL.
|
|
15356
15356
|
*/
|
|
15357
15357
|
get description() {
|
|
15358
|
-
return 'Define
|
|
15358
|
+
return 'Define the effective agent **goal**; when multiple goals exist, only the last one stays effective.';
|
|
15359
15359
|
}
|
|
15360
15360
|
/**
|
|
15361
15361
|
* Icon for this commitment.
|
|
@@ -15370,12 +15370,14 @@
|
|
|
15370
15370
|
return _spaceTrim.spaceTrim(`
|
|
15371
15371
|
# ${this.type}
|
|
15372
15372
|
|
|
15373
|
-
Defines the main goal which should be achieved by the AI assistant.
|
|
15373
|
+
Defines the main goal which should be achieved by the AI assistant.
|
|
15374
|
+
There can be multiple goals in source, but after inheritance/source rewriting only the last \`GOAL\` /\`GOALS\` remains effective.
|
|
15374
15375
|
|
|
15375
15376
|
## Key aspects
|
|
15376
15377
|
|
|
15377
15378
|
- Both terms work identically and can be used interchangeably.
|
|
15378
|
-
- Later goals
|
|
15379
|
+
- Later goals overwrite earlier goals.
|
|
15380
|
+
- The public agent profile text is derived from the last goal.
|
|
15379
15381
|
- Goals provide clear direction and purpose for the agent's responses.
|
|
15380
15382
|
- Goals influence decision-making and response prioritization.
|
|
15381
15383
|
|
|
@@ -15388,9 +15390,7 @@
|
|
|
15388
15390
|
\`\`\`book
|
|
15389
15391
|
Customer Support Agent
|
|
15390
15392
|
|
|
15391
|
-
PERSONA You are a helpful customer support representative
|
|
15392
15393
|
GOAL Resolve customer issues quickly and efficiently
|
|
15393
|
-
GOAL Maintain high customer satisfaction scores
|
|
15394
15394
|
GOAL Always follow company policies and procedures
|
|
15395
15395
|
RULE Be polite and professional at all times
|
|
15396
15396
|
\`\`\`
|
|
@@ -15398,9 +15398,7 @@
|
|
|
15398
15398
|
\`\`\`book
|
|
15399
15399
|
Educational Assistant
|
|
15400
15400
|
|
|
15401
|
-
PERSONA You are an educational assistant specializing in mathematics
|
|
15402
15401
|
GOAL Help students understand mathematical concepts clearly
|
|
15403
|
-
GOAL Encourage critical thinking and problem-solving skills
|
|
15404
15402
|
GOAL Ensure all explanations are age-appropriate and accessible
|
|
15405
15403
|
STYLE Use simple language and provide step-by-step explanations
|
|
15406
15404
|
\`\`\`
|
|
@@ -15408,9 +15406,7 @@
|
|
|
15408
15406
|
\`\`\`book
|
|
15409
15407
|
Safety-First Assistant
|
|
15410
15408
|
|
|
15411
|
-
PERSONA You are a general-purpose AI assistant
|
|
15412
15409
|
GOAL Be helpful and informative in all interactions
|
|
15413
|
-
GOAL Provide accurate and reliable information
|
|
15414
15410
|
GOAL Always prioritize user safety and ethical guidelines
|
|
15415
15411
|
RULE Never provide harmful or dangerous advice
|
|
15416
15412
|
\`\`\`
|
|
@@ -18269,7 +18265,16 @@
|
|
|
18269
18265
|
* Short one-line description of PERSONA.
|
|
18270
18266
|
*/
|
|
18271
18267
|
get description() {
|
|
18272
|
-
return '
|
|
18268
|
+
return 'Deprecated legacy profile commitment. Prefer `GOAL` for agent profile text and inheritance-safe rewrites.';
|
|
18269
|
+
}
|
|
18270
|
+
/**
|
|
18271
|
+
* Optional UI/docs-only deprecation metadata.
|
|
18272
|
+
*/
|
|
18273
|
+
get deprecation() {
|
|
18274
|
+
return {
|
|
18275
|
+
message: 'Use `GOAL` for agent profile text and inheritance-safe rewrites.',
|
|
18276
|
+
replacedBy: ['GOAL'],
|
|
18277
|
+
};
|
|
18273
18278
|
}
|
|
18274
18279
|
/**
|
|
18275
18280
|
* Icon for this commitment.
|
|
@@ -18284,16 +18289,24 @@
|
|
|
18284
18289
|
return _spaceTrim.spaceTrim(`
|
|
18285
18290
|
# ${this.type}
|
|
18286
18291
|
|
|
18287
|
-
|
|
18292
|
+
Deprecated legacy commitment that defines who the agent is, their background, expertise, and personality traits.
|
|
18288
18293
|
|
|
18289
|
-
##
|
|
18294
|
+
## Migration
|
|
18290
18295
|
|
|
18291
|
-
-
|
|
18292
|
-
-
|
|
18293
|
-
-
|
|
18294
|
-
-
|
|
18296
|
+
- Existing \`${this.type}\` books still parse and compile.
|
|
18297
|
+
- New books should prefer \`GOAL\`.
|
|
18298
|
+
- Agent profile rendering now prefers the last \`GOAL\` and only falls back to \`${this.type}\` when no goal exists.
|
|
18299
|
+
- Runtime compilation keeps the legacy multi-\`PERSONA\` merge behavior for backward compatibility.
|
|
18295
18300
|
|
|
18296
|
-
##
|
|
18301
|
+
## Preferred replacement
|
|
18302
|
+
|
|
18303
|
+
\`\`\`book
|
|
18304
|
+
Programming Assistant
|
|
18305
|
+
|
|
18306
|
+
GOAL Help the user solve programming problems with practical TypeScript and React guidance.
|
|
18307
|
+
\`\`\`
|
|
18308
|
+
|
|
18309
|
+
## Legacy compatibility example
|
|
18297
18310
|
|
|
18298
18311
|
\`\`\`book
|
|
18299
18312
|
Programming Assistant
|
|
@@ -19001,6 +19014,15 @@
|
|
|
19001
19014
|
* Map of team tool titles.
|
|
19002
19015
|
*/
|
|
19003
19016
|
const teamToolTitles = {};
|
|
19017
|
+
/**
|
|
19018
|
+
* Shared TEAM usage rules appended ahead of teammate listings.
|
|
19019
|
+
*
|
|
19020
|
+
* @private
|
|
19021
|
+
*/
|
|
19022
|
+
const TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES = [
|
|
19023
|
+
'- If a teammate is relevant to the request, consult that teammate using the matching tool.',
|
|
19024
|
+
'- Do not ask the user for information that a listed teammate can provide directly.',
|
|
19025
|
+
];
|
|
19004
19026
|
/**
|
|
19005
19027
|
* Constant for remote agents by Url.
|
|
19006
19028
|
*/
|
|
@@ -19049,7 +19071,7 @@
|
|
|
19049
19071
|
\`\`\`book
|
|
19050
19072
|
Legal Assistant
|
|
19051
19073
|
|
|
19052
|
-
|
|
19074
|
+
GOAL Get expert software-development advice from the teammate when legal discussion needs technical context.
|
|
19053
19075
|
TEAM You can talk with http://localhost:4440/agents/GMw67JN8TXxN7y to discuss the legal aspects.
|
|
19054
19076
|
\`\`\`
|
|
19055
19077
|
`);
|
|
@@ -19090,12 +19112,9 @@
|
|
|
19090
19112
|
if (updatedTools.some((tool) => tool.name === entry.toolName)) {
|
|
19091
19113
|
continue;
|
|
19092
19114
|
}
|
|
19093
|
-
const toolDescription = entry.description
|
|
19094
|
-
? `Consult teammate ${entry.teammate.label}\n${entry.description}`
|
|
19095
|
-
: `Consult teammate ${entry.teammate.label}`;
|
|
19096
19115
|
updatedTools.push({
|
|
19097
19116
|
name: entry.toolName,
|
|
19098
|
-
description:
|
|
19117
|
+
description: buildTeamToolDescription(entry),
|
|
19099
19118
|
parameters: {
|
|
19100
19119
|
type: 'object',
|
|
19101
19120
|
properties: {
|
|
@@ -19164,22 +19183,72 @@
|
|
|
19164
19183
|
/**
|
|
19165
19184
|
* Builds the textual TEAM section body for the final system message.
|
|
19166
19185
|
*
|
|
19167
|
-
* Each teammate is listed with its tool name
|
|
19168
|
-
* Uses `spaceTrim` to ensure consistent whitespace and indentation.
|
|
19186
|
+
* Each teammate is listed with its tool name, TEAM instructions, and optional profile hints.
|
|
19169
19187
|
*/
|
|
19170
19188
|
function buildTeamSystemMessageBody(teamEntries) {
|
|
19171
|
-
const lines =
|
|
19172
|
-
|
|
19173
|
-
|
|
19174
|
-
|
|
19175
|
-
|
|
19176
|
-
|
|
19177
|
-
|
|
19178
|
-
|
|
19179
|
-
|
|
19180
|
-
});
|
|
19189
|
+
const lines = [
|
|
19190
|
+
...TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES,
|
|
19191
|
+
'',
|
|
19192
|
+
...teamEntries.map((entry, index) => {
|
|
19193
|
+
const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
|
|
19194
|
+
const detailLines = collectTeamEntryDetails(entry).map(formatTeamEntryDetailLine);
|
|
19195
|
+
return [toolLine, ...detailLines].join('\n');
|
|
19196
|
+
}),
|
|
19197
|
+
];
|
|
19181
19198
|
return lines.join('\n');
|
|
19182
19199
|
}
|
|
19200
|
+
/**
|
|
19201
|
+
* Builds the model-visible description for one teammate tool.
|
|
19202
|
+
*
|
|
19203
|
+
* @private
|
|
19204
|
+
*/
|
|
19205
|
+
function buildTeamToolDescription(entry) {
|
|
19206
|
+
const detailLines = collectTeamEntryDetails(entry).map(({ label, content }) => `${label}: ${content}`);
|
|
19207
|
+
return [`Consult teammate ${entry.teammate.label}`, ...detailLines].join('\n');
|
|
19208
|
+
}
|
|
19209
|
+
/**
|
|
19210
|
+
* Collects structured teammate details that should stay visible to the model.
|
|
19211
|
+
*
|
|
19212
|
+
* @private
|
|
19213
|
+
*/
|
|
19214
|
+
function collectTeamEntryDetails(entry) {
|
|
19215
|
+
var _a;
|
|
19216
|
+
const details = [];
|
|
19217
|
+
const instructions = entry.teammate.instructions.trim();
|
|
19218
|
+
const description = ((_a = entry.description) === null || _a === void 0 ? void 0 : _a.trim()) || '';
|
|
19219
|
+
if (instructions) {
|
|
19220
|
+
details.push({
|
|
19221
|
+
label: 'TEAM instructions',
|
|
19222
|
+
content: instructions,
|
|
19223
|
+
});
|
|
19224
|
+
}
|
|
19225
|
+
if (description) {
|
|
19226
|
+
details.push({
|
|
19227
|
+
label: 'Profile',
|
|
19228
|
+
content: description,
|
|
19229
|
+
});
|
|
19230
|
+
}
|
|
19231
|
+
return details;
|
|
19232
|
+
}
|
|
19233
|
+
/**
|
|
19234
|
+
* Formats one teammate detail line for the TEAM system-message section.
|
|
19235
|
+
*
|
|
19236
|
+
* @private
|
|
19237
|
+
*/
|
|
19238
|
+
function formatTeamEntryDetailLine(detail) {
|
|
19239
|
+
return indentMultilineText(`${detail.label}: ${detail.content}`, ' ');
|
|
19240
|
+
}
|
|
19241
|
+
/**
|
|
19242
|
+
* Indents all lines of one potentially multi-line text block.
|
|
19243
|
+
*
|
|
19244
|
+
* @private
|
|
19245
|
+
*/
|
|
19246
|
+
function indentMultilineText(text, prefix) {
|
|
19247
|
+
return text
|
|
19248
|
+
.split('\n')
|
|
19249
|
+
.map((line) => `${prefix}${line}`)
|
|
19250
|
+
.join('\n');
|
|
19251
|
+
}
|
|
19183
19252
|
/**
|
|
19184
19253
|
* Registers tool function and title for a teammate tool.
|
|
19185
19254
|
*/
|
|
@@ -28029,7 +28098,7 @@
|
|
|
28029
28098
|
function parseAgentSource(agentSource) {
|
|
28030
28099
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
28031
28100
|
const resolvedAgentName = parseResult.agentName || createDefaultAgentName(agentSource);
|
|
28032
|
-
const personaDescription =
|
|
28101
|
+
const personaDescription = extractAgentProfileText(parseResult.commitments);
|
|
28033
28102
|
const initialMessage = extractInitialMessage(parseResult.commitments);
|
|
28034
28103
|
const parsedProfile = extractParsedAgentProfile(parseResult.commitments);
|
|
28035
28104
|
ensureMetaFullname(parsedProfile.meta, resolvedAgentName);
|
|
@@ -28133,25 +28202,33 @@
|
|
|
28133
28202
|
*/
|
|
28134
28203
|
const LOCAL_AGENT_REFERENCE_PREFIXES = ['./', '../', '/'];
|
|
28135
28204
|
/**
|
|
28136
|
-
*
|
|
28205
|
+
* Resolves the public agent profile text from the last GOAL/GOALS commitment,
|
|
28206
|
+
* falling back to the deprecated PERSONA/PERSONAE commitments when no goal exists.
|
|
28137
28207
|
*
|
|
28138
28208
|
* @private internal utility of `parseAgentSource`
|
|
28139
28209
|
*/
|
|
28140
|
-
function
|
|
28141
|
-
let
|
|
28210
|
+
function extractAgentProfileText(commitments) {
|
|
28211
|
+
let goalDescription = '';
|
|
28212
|
+
let hasGoalDescription = false;
|
|
28213
|
+
let personaDescription = '';
|
|
28214
|
+
let hasPersonaDescription = false;
|
|
28142
28215
|
for (const commitment of commitments) {
|
|
28143
|
-
if (commitment.type
|
|
28144
|
-
|
|
28216
|
+
if (commitment.type === 'GOAL' || commitment.type === 'GOALS') {
|
|
28217
|
+
goalDescription = commitment.content;
|
|
28218
|
+
hasGoalDescription = true;
|
|
28145
28219
|
}
|
|
28146
|
-
if (
|
|
28147
|
-
personaDescription =
|
|
28220
|
+
if (commitment.type === 'PERSONA' || commitment.type === 'PERSONAE') {
|
|
28221
|
+
personaDescription = commitment.content;
|
|
28222
|
+
hasPersonaDescription = true;
|
|
28148
28223
|
}
|
|
28149
|
-
else {
|
|
28150
|
-
personaDescription += `\n\n${personaDescription}`;
|
|
28151
|
-
}
|
|
28152
|
-
personaDescription += commitment.content;
|
|
28153
28224
|
}
|
|
28154
|
-
|
|
28225
|
+
if (hasGoalDescription) {
|
|
28226
|
+
return goalDescription;
|
|
28227
|
+
}
|
|
28228
|
+
if (hasPersonaDescription) {
|
|
28229
|
+
return personaDescription;
|
|
28230
|
+
}
|
|
28231
|
+
return null;
|
|
28155
28232
|
}
|
|
28156
28233
|
/**
|
|
28157
28234
|
* Resolves the last INITIAL MESSAGE commitment, which is the public initial-message value.
|
|
@@ -28672,7 +28749,7 @@
|
|
|
28672
28749
|
systemMessage: '',
|
|
28673
28750
|
promptSuffix: '',
|
|
28674
28751
|
// modelName: 'gpt-5',
|
|
28675
|
-
modelName: '
|
|
28752
|
+
modelName: 'gpt-5.4-mini',
|
|
28676
28753
|
temperature: 0.7,
|
|
28677
28754
|
topP: 0.9,
|
|
28678
28755
|
topK: 50,
|
|
@@ -28833,6 +28910,15 @@
|
|
|
28833
28910
|
* @private internal constant of `createAgentModelRequirementsWithCommitments`
|
|
28834
28911
|
*/
|
|
28835
28912
|
const DELETE_COMMITMENT_TYPES = new Set(['DELETE', 'CANCEL', 'DISCARD', 'REMOVE']);
|
|
28913
|
+
/**
|
|
28914
|
+
* Commitments whose earlier occurrences are overwritten by the last occurrence in source order.
|
|
28915
|
+
*
|
|
28916
|
+
* @private internal constant of `createAgentModelRequirementsWithCommitments`
|
|
28917
|
+
*/
|
|
28918
|
+
const OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE = new Map([
|
|
28919
|
+
['GOAL', 'GOAL'],
|
|
28920
|
+
['GOALS', 'GOAL'],
|
|
28921
|
+
]);
|
|
28836
28922
|
/**
|
|
28837
28923
|
* Regex pattern matching markdown horizontal lines that should not be copied into the final system message.
|
|
28838
28924
|
*
|
|
@@ -28883,7 +28969,7 @@
|
|
|
28883
28969
|
*/
|
|
28884
28970
|
async function createAgentModelRequirementsWithCommitments(agentSource, modelName, options) {
|
|
28885
28971
|
const parseResult = parseAgentSourceWithCommitments(agentSource);
|
|
28886
|
-
const filteredCommitments = filterDeletedCommitments(parseResult.commitments);
|
|
28972
|
+
const filteredCommitments = filterOverwrittenCommitments(filterDeletedCommitments(parseResult.commitments));
|
|
28887
28973
|
let requirements = createInitialAgentModelRequirements(parseResult.agentName, modelName);
|
|
28888
28974
|
requirements = await applyCommitmentsToRequirements(requirements, filteredCommitments, options);
|
|
28889
28975
|
requirements = aggregateUseCommitmentSystemMessages(requirements, filteredCommitments);
|
|
@@ -28894,6 +28980,35 @@
|
|
|
28894
28980
|
requirements = await applyPendingInlineKnowledgeSources(requirements, options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader);
|
|
28895
28981
|
return finalizeRequirements(requirements);
|
|
28896
28982
|
}
|
|
28983
|
+
/**
|
|
28984
|
+
* Removes earlier commitments that are overwritten by later commitments of the same semantic group.
|
|
28985
|
+
*
|
|
28986
|
+
* This currently keeps only the last `GOAL` / `GOALS` commitment so inheritance rewrites
|
|
28987
|
+
* and multi-goal sources expose one effective goal to the runtime.
|
|
28988
|
+
*
|
|
28989
|
+
* @param commitments - Parsed commitments after DELETE-like filtering.
|
|
28990
|
+
* @returns Commitments with overwritten entries removed while preserving source order.
|
|
28991
|
+
*
|
|
28992
|
+
* @private internal utility of `createAgentModelRequirementsWithCommitments`
|
|
28993
|
+
*/
|
|
28994
|
+
function filterOverwrittenCommitments(commitments) {
|
|
28995
|
+
const seenOverwriteGroups = new Set();
|
|
28996
|
+
const keptCommitments = [];
|
|
28997
|
+
for (let index = commitments.length - 1; index >= 0; index--) {
|
|
28998
|
+
const commitment = commitments[index];
|
|
28999
|
+
const overwriteGroup = OVERWRITTEN_COMMITMENT_GROUP_BY_TYPE.get(commitment.type);
|
|
29000
|
+
if (!overwriteGroup) {
|
|
29001
|
+
keptCommitments.push(commitment);
|
|
29002
|
+
continue;
|
|
29003
|
+
}
|
|
29004
|
+
if (seenOverwriteGroups.has(overwriteGroup)) {
|
|
29005
|
+
continue;
|
|
29006
|
+
}
|
|
29007
|
+
seenOverwriteGroups.add(overwriteGroup);
|
|
29008
|
+
keptCommitments.push(commitment);
|
|
29009
|
+
}
|
|
29010
|
+
return keptCommitments.reverse();
|
|
29011
|
+
}
|
|
28897
29012
|
/**
|
|
28898
29013
|
* Creates the initial requirements object with the parsed agent name stored in metadata and an optional model override.
|
|
28899
29014
|
*
|
|
@@ -29485,7 +29600,7 @@
|
|
|
29485
29600
|
* Selects the best model using the preparePersona function
|
|
29486
29601
|
* This directly uses preparePersona to ensure DRY principle
|
|
29487
29602
|
*
|
|
29488
|
-
* @param agentSource The agent source to derive
|
|
29603
|
+
* @param agentSource The agent source to derive effective profile text from
|
|
29489
29604
|
* @param llmTools LLM tools for preparing persona
|
|
29490
29605
|
* @returns The name of the best selected model
|
|
29491
29606
|
*
|
|
@@ -29493,9 +29608,9 @@
|
|
|
29493
29608
|
*/
|
|
29494
29609
|
async function selectBestModelUsingPersona(agentSource, llmTools) {
|
|
29495
29610
|
var _a;
|
|
29496
|
-
// Parse agent source to get
|
|
29611
|
+
// Parse agent source to get the effective profile description
|
|
29497
29612
|
const { agentName, personaDescription } = parseAgentSource(agentSource);
|
|
29498
|
-
// Use agent name as fallback if no
|
|
29613
|
+
// Use agent name as fallback if no profile description is available
|
|
29499
29614
|
const description = personaDescription || agentName || 'AI Agent';
|
|
29500
29615
|
try {
|
|
29501
29616
|
// Use preparePersona directly
|
|
@@ -33266,7 +33381,7 @@
|
|
|
33266
33381
|
/**
|
|
33267
33382
|
* Constant for default agent kit model name.
|
|
33268
33383
|
*/
|
|
33269
|
-
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-
|
|
33384
|
+
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-mini';
|
|
33270
33385
|
/**
|
|
33271
33386
|
* Creates one structured log entry for streamed tool-call updates.
|
|
33272
33387
|
*
|
|
@@ -35332,6 +35447,7 @@
|
|
|
35332
35447
|
* @param agentSource The agent source string that defines the agent's behavior
|
|
35333
35448
|
*/
|
|
35334
35449
|
constructor(options) {
|
|
35450
|
+
var _a;
|
|
35335
35451
|
this.options = options;
|
|
35336
35452
|
/**
|
|
35337
35453
|
* Cached model requirements to avoid re-parsing the agent source
|
|
@@ -35341,6 +35457,7 @@
|
|
|
35341
35457
|
* Cached parsed agent information
|
|
35342
35458
|
*/
|
|
35343
35459
|
this._cachedAgentInfo = null;
|
|
35460
|
+
this.precomputedModelRequirements = (_a = options.precomputedModelRequirements) !== null && _a !== void 0 ? _a : null;
|
|
35344
35461
|
}
|
|
35345
35462
|
/**
|
|
35346
35463
|
* Updates the agent source and clears the cache
|
|
@@ -35348,9 +35465,13 @@
|
|
|
35348
35465
|
* @param agentSource The new agent source string
|
|
35349
35466
|
*/
|
|
35350
35467
|
updateAgentSource(agentSource) {
|
|
35468
|
+
if (this.options.agentSource === agentSource) {
|
|
35469
|
+
return;
|
|
35470
|
+
}
|
|
35351
35471
|
this.options.agentSource = agentSource;
|
|
35352
35472
|
this._cachedAgentInfo = null;
|
|
35353
35473
|
this._cachedModelRequirements = null;
|
|
35474
|
+
this.precomputedModelRequirements = null;
|
|
35354
35475
|
}
|
|
35355
35476
|
/**
|
|
35356
35477
|
* Get cached or parse agent information
|
|
@@ -35367,6 +35488,16 @@
|
|
|
35367
35488
|
* Note: [🐤] This is names `getModelRequirements` *(not `getAgentModelRequirements`)* because in future these two will be united
|
|
35368
35489
|
*/
|
|
35369
35490
|
async getModelRequirements() {
|
|
35491
|
+
var _a, _b;
|
|
35492
|
+
if (this.precomputedModelRequirements !== null) {
|
|
35493
|
+
if (this.options.isVerbose) {
|
|
35494
|
+
console.info('[🤰]', 'Using precomputed agent model requirements', {
|
|
35495
|
+
agent: this.title,
|
|
35496
|
+
toolCount: (_b = (_a = this.precomputedModelRequirements.tools) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
|
|
35497
|
+
});
|
|
35498
|
+
}
|
|
35499
|
+
return this.precomputedModelRequirements;
|
|
35500
|
+
}
|
|
35370
35501
|
if (this._cachedModelRequirements === null) {
|
|
35371
35502
|
const preparationStartedAtMs = Date.now();
|
|
35372
35503
|
if (this.options.isVerbose) {
|
|
@@ -35476,6 +35607,7 @@
|
|
|
35476
35607
|
* Resolves agent requirements, attachments, and runtime overrides into one forwarded chat prompt.
|
|
35477
35608
|
*/
|
|
35478
35609
|
async prepareChatPrompt(prompt) {
|
|
35610
|
+
var _a;
|
|
35479
35611
|
const chatPrompt = this.requireChatPrompt(prompt);
|
|
35480
35612
|
const { sanitizedRequirements, promptSuffix } = await this.getSanitizedAgentModelRequirements();
|
|
35481
35613
|
const attachments = normalizeChatAttachments(chatPrompt.attachments);
|
|
@@ -35493,7 +35625,16 @@
|
|
|
35493
35625
|
mergedTools,
|
|
35494
35626
|
knowledgeSourcesForAgent,
|
|
35495
35627
|
});
|
|
35496
|
-
|
|
35628
|
+
if (this.options.isVerbose) {
|
|
35629
|
+
console.info('[🤰]', 'Prepared agent chat prompt', {
|
|
35630
|
+
agent: this.title,
|
|
35631
|
+
usedPrecomputedModelRequirements: this.precomputedModelRequirements !== null,
|
|
35632
|
+
toolNames: mergedTools.map((tool) => tool.name),
|
|
35633
|
+
knowledgeSourcesCount: (_a = knowledgeSourcesForAgent === null || knowledgeSourcesForAgent === void 0 ? void 0 : knowledgeSourcesForAgent.length) !== null && _a !== void 0 ? _a : 0,
|
|
35634
|
+
promptSuffixLength: promptSuffix.length,
|
|
35635
|
+
systemMessageLength: sanitizedRequirements.systemMessage.length,
|
|
35636
|
+
});
|
|
35637
|
+
}
|
|
35497
35638
|
return {
|
|
35498
35639
|
forwardedPrompt,
|
|
35499
35640
|
sanitizedRequirements,
|
|
@@ -35680,6 +35821,7 @@
|
|
|
35680
35821
|
* Runs one prepared prompt through the deprecated OpenAI Assistant backend.
|
|
35681
35822
|
*/
|
|
35682
35823
|
async callOpenAiAssistantChatModelStream(options) {
|
|
35824
|
+
var _a, _b, _c, _d;
|
|
35683
35825
|
const assistant = await this.getOrPrepareOpenAiAssistant({
|
|
35684
35826
|
llmTools: options.llmTools,
|
|
35685
35827
|
originalPrompt: options.originalPrompt,
|
|
@@ -35687,7 +35829,14 @@
|
|
|
35687
35829
|
onProgress: options.onProgress,
|
|
35688
35830
|
});
|
|
35689
35831
|
const promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools = createOpenAiAssistantPrompt(options.preparedChatPrompt.forwardedPrompt);
|
|
35690
|
-
|
|
35832
|
+
if (this.options.isVerbose) {
|
|
35833
|
+
console.info('[🤰]', 'Prepared OpenAI Assistant prompt', {
|
|
35834
|
+
agent: this.title,
|
|
35835
|
+
toolNames: (_b = (_a = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements.tools) === null || _a === void 0 ? void 0 : _a.map((tool) => tool.name)) !== null && _b !== void 0 ? _b : [],
|
|
35836
|
+
knowledgeSourcesCount: (_d = (_c = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements
|
|
35837
|
+
.knowledgeSources) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
|
|
35838
|
+
});
|
|
35839
|
+
}
|
|
35691
35840
|
return assistant.callChatModelStream(promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools, options.onProgress, options.streamOptions);
|
|
35692
35841
|
}
|
|
35693
35842
|
/**
|
|
@@ -36378,7 +36527,8 @@
|
|
|
36378
36527
|
isVerbose: options.isVerbose,
|
|
36379
36528
|
llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
|
|
36380
36529
|
assistantPreparationMode: options.assistantPreparationMode,
|
|
36381
|
-
agentSource: agentSource.value,
|
|
36530
|
+
agentSource: agentSource.value,
|
|
36531
|
+
precomputedModelRequirements: options.precomputedModelRequirements,
|
|
36382
36532
|
});
|
|
36383
36533
|
this._agentName = undefined;
|
|
36384
36534
|
/**
|