@promptbook/core 0.112.0-41 → 0.112.0-43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -3
- package/esm/index.es.js +174 -62
- package/esm/index.es.js.map +1 -1
- package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +1 -1
- package/esm/src/cli/cli-commands/coder/getTypescriptModule.d.ts +19 -0
- package/esm/src/cli/cli-commands/coder/getTypescriptModule.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/coder/mergeStringRecordJsonFile.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/coder/verify.test.d.ts +1 -0
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +2 -14
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.d.ts +40 -0
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.test.d.ts +1 -0
- package/esm/src/llm-providers/agent/Agent.test.d.ts +1 -0
- package/esm/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +4 -0
- package/esm/src/llm-providers/agent/AgentOptions.d.ts +8 -0
- package/esm/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +9 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +174 -62
- package/umd/index.umd.js.map +1 -1
- package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +1 -1
- package/umd/src/cli/cli-commands/coder/getTypescriptModule.d.ts +19 -0
- package/umd/src/cli/cli-commands/coder/getTypescriptModule.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/coder/mergeStringRecordJsonFile.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/coder/verify.test.d.ts +1 -0
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +2 -14
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.d.ts +40 -0
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.test.d.ts +1 -0
- package/umd/src/llm-providers/agent/Agent.test.d.ts +1 -0
- package/umd/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +4 -0
- package/umd/src/llm-providers/agent/AgentOptions.d.ts +8 -0
- package/umd/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +9 -0
- package/umd/src/version.d.ts +1 -1
|
@@ -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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,23 +4,11 @@ import type { string_book } from '../../../../book-2.0/agent-source/string_book'
|
|
|
4
4
|
import type { string_agent_name, string_agent_permanent_id } from '../../../../types/typeAliases';
|
|
5
5
|
import { AgentCollectionInSupabaseOptions } from './AgentCollectionInSupabaseOptions';
|
|
6
6
|
import type { AgentsDatabaseSchema } from './AgentsDatabaseSchema';
|
|
7
|
+
import { type CreateAgentPersistenceRecordsOptions } from './createAgentPersistenceRecords';
|
|
7
8
|
/**
|
|
8
9
|
* Options for creating a new agent entry.
|
|
9
10
|
*/
|
|
10
|
-
type CreateAgentOptions =
|
|
11
|
-
/**
|
|
12
|
-
* Visibility for the new agent.
|
|
13
|
-
*/
|
|
14
|
-
readonly visibility?: 'PRIVATE' | 'UNLISTED' | 'PUBLIC';
|
|
15
|
-
/**
|
|
16
|
-
* Folder identifier to assign the new agent to.
|
|
17
|
-
*/
|
|
18
|
-
readonly folderId?: number | null;
|
|
19
|
-
/**
|
|
20
|
-
* Sort order for the agent within its parent folder.
|
|
21
|
-
*/
|
|
22
|
-
readonly sortOrder?: number;
|
|
23
|
-
};
|
|
11
|
+
type CreateAgentOptions = CreateAgentPersistenceRecordsOptions;
|
|
24
12
|
/**
|
|
25
13
|
* Optional controls for persisting one source update.
|
|
26
14
|
*/
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AgentBasicInformation } from '../../../../book-2.0/agent-source/AgentBasicInformation';
|
|
2
|
+
import type { string_book } from '../../../../book-2.0/agent-source/string_book';
|
|
3
|
+
import type { CreateAgentInput } from '../../CreateAgentInput';
|
|
4
|
+
import type { AgentsDatabaseSchema } from './AgentsDatabaseSchema';
|
|
5
|
+
/**
|
|
6
|
+
* Optional persistence overrides for one new agent row.
|
|
7
|
+
*
|
|
8
|
+
* @private shared persistence helper for `AgentCollectionInSupabase`
|
|
9
|
+
*/
|
|
10
|
+
export type CreateAgentPersistenceRecordsOptions = Omit<CreateAgentInput, 'source'>;
|
|
11
|
+
/**
|
|
12
|
+
* Prepared insert rows and returned profile for one newly persisted agent.
|
|
13
|
+
*
|
|
14
|
+
* @private shared persistence helper for `AgentCollectionInSupabase`
|
|
15
|
+
*/
|
|
16
|
+
export type CreateAgentPersistenceRecordsResult = {
|
|
17
|
+
/**
|
|
18
|
+
* Parsed created agent profile including the resolved permanent id.
|
|
19
|
+
*/
|
|
20
|
+
readonly createdAgent: AgentBasicInformation & Required<Pick<AgentBasicInformation, 'permanentId'>>;
|
|
21
|
+
/**
|
|
22
|
+
* Insert row for the `Agent` table.
|
|
23
|
+
*/
|
|
24
|
+
readonly agentInsertRecord: AgentsDatabaseSchema['public']['Tables']['Agent']['Insert'];
|
|
25
|
+
/**
|
|
26
|
+
* Insert row for the `AgentHistory` table.
|
|
27
|
+
*/
|
|
28
|
+
readonly agentHistoryInsertRecord: AgentsDatabaseSchema['public']['Tables']['AgentHistory']['Insert'];
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Builds normalized insert rows for a newly created persisted agent.
|
|
32
|
+
*
|
|
33
|
+
* @param agentSource - Source content of the agent.
|
|
34
|
+
* @param options - Optional folder placement, ordering, and visibility overrides.
|
|
35
|
+
* @param createdAt - Shared creation timestamp used across all persisted rows.
|
|
36
|
+
* @returns Insert rows and the created agent profile.
|
|
37
|
+
*
|
|
38
|
+
* @private shared persistence helper for `AgentCollectionInSupabase`
|
|
39
|
+
*/
|
|
40
|
+
export declare function createAgentPersistenceRecords(agentSource: string_book, options?: CreateAgentPersistenceRecordsOptions, createdAt?: string): CreateAgentPersistenceRecordsResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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-42`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* @generated
|
|
28
28
|
* @see https://github.com/webgptorg/promptbook
|
|
29
29
|
*/
|
|
30
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-43';
|
|
31
31
|
/**
|
|
32
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -7867,7 +7867,7 @@
|
|
|
7867
7867
|
systemMessage: '',
|
|
7868
7868
|
promptSuffix: '',
|
|
7869
7869
|
// modelName: 'gpt-5',
|
|
7870
|
-
modelName: '
|
|
7870
|
+
modelName: 'gpt-5.4-mini',
|
|
7871
7871
|
temperature: 0.7,
|
|
7872
7872
|
topP: 0.9,
|
|
7873
7873
|
topK: 50,
|
|
@@ -15055,6 +15055,15 @@
|
|
|
15055
15055
|
* Map of team tool titles.
|
|
15056
15056
|
*/
|
|
15057
15057
|
const teamToolTitles = {};
|
|
15058
|
+
/**
|
|
15059
|
+
* Shared TEAM usage rules appended ahead of teammate listings.
|
|
15060
|
+
*
|
|
15061
|
+
* @private
|
|
15062
|
+
*/
|
|
15063
|
+
const TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES = [
|
|
15064
|
+
'- If a teammate is relevant to the request, consult that teammate using the matching tool.',
|
|
15065
|
+
'- Do not ask the user for information that a listed teammate can provide directly.',
|
|
15066
|
+
];
|
|
15058
15067
|
/**
|
|
15059
15068
|
* Constant for remote agents by Url.
|
|
15060
15069
|
*/
|
|
@@ -15144,12 +15153,9 @@
|
|
|
15144
15153
|
if (updatedTools.some((tool) => tool.name === entry.toolName)) {
|
|
15145
15154
|
continue;
|
|
15146
15155
|
}
|
|
15147
|
-
const toolDescription = entry.description
|
|
15148
|
-
? `Consult teammate ${entry.teammate.label}\n${entry.description}`
|
|
15149
|
-
: `Consult teammate ${entry.teammate.label}`;
|
|
15150
15156
|
updatedTools.push({
|
|
15151
15157
|
name: entry.toolName,
|
|
15152
|
-
description:
|
|
15158
|
+
description: buildTeamToolDescription(entry),
|
|
15153
15159
|
parameters: {
|
|
15154
15160
|
type: 'object',
|
|
15155
15161
|
properties: {
|
|
@@ -15218,22 +15224,72 @@
|
|
|
15218
15224
|
/**
|
|
15219
15225
|
* Builds the textual TEAM section body for the final system message.
|
|
15220
15226
|
*
|
|
15221
|
-
* Each teammate is listed with its tool name
|
|
15222
|
-
* Uses `spaceTrim` to ensure consistent whitespace and indentation.
|
|
15227
|
+
* Each teammate is listed with its tool name, TEAM instructions, and optional profile hints.
|
|
15223
15228
|
*/
|
|
15224
15229
|
function buildTeamSystemMessageBody(teamEntries) {
|
|
15225
|
-
const lines =
|
|
15226
|
-
|
|
15227
|
-
|
|
15228
|
-
|
|
15229
|
-
|
|
15230
|
-
|
|
15231
|
-
|
|
15232
|
-
|
|
15233
|
-
|
|
15234
|
-
});
|
|
15230
|
+
const lines = [
|
|
15231
|
+
...TEAM_SYSTEM_MESSAGE_GUIDANCE_LINES,
|
|
15232
|
+
'',
|
|
15233
|
+
...teamEntries.map((entry, index) => {
|
|
15234
|
+
const toolLine = `${index + 1}) ${entry.teammate.label} tool \`${entry.toolName}\``;
|
|
15235
|
+
const detailLines = collectTeamEntryDetails(entry).map(formatTeamEntryDetailLine);
|
|
15236
|
+
return [toolLine, ...detailLines].join('\n');
|
|
15237
|
+
}),
|
|
15238
|
+
];
|
|
15235
15239
|
return lines.join('\n');
|
|
15236
15240
|
}
|
|
15241
|
+
/**
|
|
15242
|
+
* Builds the model-visible description for one teammate tool.
|
|
15243
|
+
*
|
|
15244
|
+
* @private
|
|
15245
|
+
*/
|
|
15246
|
+
function buildTeamToolDescription(entry) {
|
|
15247
|
+
const detailLines = collectTeamEntryDetails(entry).map(({ label, content }) => `${label}: ${content}`);
|
|
15248
|
+
return [`Consult teammate ${entry.teammate.label}`, ...detailLines].join('\n');
|
|
15249
|
+
}
|
|
15250
|
+
/**
|
|
15251
|
+
* Collects structured teammate details that should stay visible to the model.
|
|
15252
|
+
*
|
|
15253
|
+
* @private
|
|
15254
|
+
*/
|
|
15255
|
+
function collectTeamEntryDetails(entry) {
|
|
15256
|
+
var _a;
|
|
15257
|
+
const details = [];
|
|
15258
|
+
const instructions = entry.teammate.instructions.trim();
|
|
15259
|
+
const description = ((_a = entry.description) === null || _a === void 0 ? void 0 : _a.trim()) || '';
|
|
15260
|
+
if (instructions) {
|
|
15261
|
+
details.push({
|
|
15262
|
+
label: 'TEAM instructions',
|
|
15263
|
+
content: instructions,
|
|
15264
|
+
});
|
|
15265
|
+
}
|
|
15266
|
+
if (description) {
|
|
15267
|
+
details.push({
|
|
15268
|
+
label: 'Profile',
|
|
15269
|
+
content: description,
|
|
15270
|
+
});
|
|
15271
|
+
}
|
|
15272
|
+
return details;
|
|
15273
|
+
}
|
|
15274
|
+
/**
|
|
15275
|
+
* Formats one teammate detail line for the TEAM system-message section.
|
|
15276
|
+
*
|
|
15277
|
+
* @private
|
|
15278
|
+
*/
|
|
15279
|
+
function formatTeamEntryDetailLine(detail) {
|
|
15280
|
+
return indentMultilineText(`${detail.label}: ${detail.content}`, ' ');
|
|
15281
|
+
}
|
|
15282
|
+
/**
|
|
15283
|
+
* Indents all lines of one potentially multi-line text block.
|
|
15284
|
+
*
|
|
15285
|
+
* @private
|
|
15286
|
+
*/
|
|
15287
|
+
function indentMultilineText(text, prefix) {
|
|
15288
|
+
return text
|
|
15289
|
+
.split('\n')
|
|
15290
|
+
.map((line) => `${prefix}${line}`)
|
|
15291
|
+
.join('\n');
|
|
15292
|
+
}
|
|
15237
15293
|
/**
|
|
15238
15294
|
* Registers tool function and title for a teammate tool.
|
|
15239
15295
|
*/
|
|
@@ -23456,6 +23512,60 @@
|
|
|
23456
23512
|
return strippedLines.join('\n');
|
|
23457
23513
|
}
|
|
23458
23514
|
|
|
23515
|
+
/**
|
|
23516
|
+
* Builds normalized insert rows for a newly created persisted agent.
|
|
23517
|
+
*
|
|
23518
|
+
* @param agentSource - Source content of the agent.
|
|
23519
|
+
* @param options - Optional folder placement, ordering, and visibility overrides.
|
|
23520
|
+
* @param createdAt - Shared creation timestamp used across all persisted rows.
|
|
23521
|
+
* @returns Insert rows and the created agent profile.
|
|
23522
|
+
*
|
|
23523
|
+
* @private shared persistence helper for `AgentCollectionInSupabase`
|
|
23524
|
+
*/
|
|
23525
|
+
function createAgentPersistenceRecords(agentSource, options = {}, createdAt = new Date().toISOString()) {
|
|
23526
|
+
const preparedAgentSource = prepareAgentSourceForPersistence(agentSource);
|
|
23527
|
+
const { agentProfile, agentSource: normalizedAgentSource } = preparedAgentSource;
|
|
23528
|
+
const permanentId = preparedAgentSource.permanentId || $randomBase58(14);
|
|
23529
|
+
const { agentName, agentHash } = agentProfile;
|
|
23530
|
+
const agentInsertRecord = {
|
|
23531
|
+
agentName,
|
|
23532
|
+
agentHash,
|
|
23533
|
+
permanentId,
|
|
23534
|
+
agentProfile,
|
|
23535
|
+
createdAt,
|
|
23536
|
+
updatedAt: null,
|
|
23537
|
+
promptbookEngineVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
23538
|
+
usage: ZERO_USAGE,
|
|
23539
|
+
agentSource: normalizedAgentSource,
|
|
23540
|
+
};
|
|
23541
|
+
if (options.folderId !== undefined) {
|
|
23542
|
+
agentInsertRecord.folderId = options.folderId;
|
|
23543
|
+
}
|
|
23544
|
+
if (options.sortOrder !== undefined) {
|
|
23545
|
+
agentInsertRecord.sortOrder = options.sortOrder;
|
|
23546
|
+
}
|
|
23547
|
+
if (options.visibility !== undefined) {
|
|
23548
|
+
agentInsertRecord.visibility = options.visibility;
|
|
23549
|
+
}
|
|
23550
|
+
return {
|
|
23551
|
+
createdAgent: {
|
|
23552
|
+
...agentProfile,
|
|
23553
|
+
permanentId,
|
|
23554
|
+
},
|
|
23555
|
+
agentInsertRecord,
|
|
23556
|
+
agentHistoryInsertRecord: {
|
|
23557
|
+
createdAt,
|
|
23558
|
+
agentName,
|
|
23559
|
+
permanentId,
|
|
23560
|
+
agentHash,
|
|
23561
|
+
previousAgentHash: null,
|
|
23562
|
+
agentSource: normalizedAgentSource,
|
|
23563
|
+
promptbookEngineVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
23564
|
+
versionName: null,
|
|
23565
|
+
},
|
|
23566
|
+
};
|
|
23567
|
+
}
|
|
23568
|
+
|
|
23459
23569
|
/**
|
|
23460
23570
|
* Normalizes optional history version name before persistence.
|
|
23461
23571
|
*
|
|
@@ -23579,52 +23689,18 @@
|
|
|
23579
23689
|
* @param options - Optional folder placement and ordering data.
|
|
23580
23690
|
*/
|
|
23581
23691
|
async createAgent(agentSource, options = {}) {
|
|
23582
|
-
const
|
|
23583
|
-
const {
|
|
23584
|
-
|
|
23585
|
-
const { agentName, agentHash } = agentProfile;
|
|
23586
|
-
if (!permanentId) {
|
|
23587
|
-
permanentId = $randomBase58(14);
|
|
23588
|
-
}
|
|
23589
|
-
const insertPayload = {
|
|
23590
|
-
agentName,
|
|
23591
|
-
agentHash,
|
|
23592
|
-
permanentId,
|
|
23593
|
-
agentProfile,
|
|
23594
|
-
createdAt: new Date().toISOString(),
|
|
23595
|
-
updatedAt: null,
|
|
23596
|
-
promptbookEngineVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
23597
|
-
usage: ZERO_USAGE,
|
|
23598
|
-
agentSource: normalizedAgentSource,
|
|
23599
|
-
};
|
|
23600
|
-
if (options.folderId !== undefined) {
|
|
23601
|
-
insertPayload.folderId = options.folderId;
|
|
23602
|
-
}
|
|
23603
|
-
if (options.sortOrder !== undefined) {
|
|
23604
|
-
insertPayload.sortOrder = options.sortOrder;
|
|
23605
|
-
}
|
|
23606
|
-
if (options.visibility !== undefined) {
|
|
23607
|
-
insertPayload.visibility = options.visibility;
|
|
23608
|
-
}
|
|
23609
|
-
const insertAgentResult = await this.supabaseClient.from(this.getTableName('Agent')).insert(insertPayload);
|
|
23692
|
+
const createdAt = new Date().toISOString();
|
|
23693
|
+
const { createdAgent, agentInsertRecord, agentHistoryInsertRecord } = createAgentPersistenceRecords(agentSource, options, createdAt);
|
|
23694
|
+
const insertAgentResult = await this.supabaseClient.from(this.getTableName('Agent')).insert(agentInsertRecord);
|
|
23610
23695
|
if (insertAgentResult.error) {
|
|
23611
23696
|
throw new DatabaseError(spaceTrim((block) => `
|
|
23612
|
-
Error creating agent "${
|
|
23697
|
+
Error creating agent "${createdAgent.agentName}" in Supabase:
|
|
23613
23698
|
|
|
23614
23699
|
${block(insertAgentResult.error.message)}
|
|
23615
23700
|
`));
|
|
23616
23701
|
}
|
|
23617
|
-
await this.insertAgentHistoryRow(
|
|
23618
|
-
|
|
23619
|
-
agentName,
|
|
23620
|
-
permanentId,
|
|
23621
|
-
agentHash,
|
|
23622
|
-
previousAgentHash: null,
|
|
23623
|
-
agentSource: normalizedAgentSource,
|
|
23624
|
-
promptbookEngineVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
23625
|
-
versionName: null,
|
|
23626
|
-
});
|
|
23627
|
-
return { ...agentProfile, permanentId };
|
|
23702
|
+
await this.insertAgentHistoryRow(agentHistoryInsertRecord);
|
|
23703
|
+
return createdAgent;
|
|
23628
23704
|
}
|
|
23629
23705
|
/**
|
|
23630
23706
|
* Updates an existing agent in the collection
|
|
@@ -32680,7 +32756,7 @@
|
|
|
32680
32756
|
/**
|
|
32681
32757
|
* Constant for default agent kit model name.
|
|
32682
32758
|
*/
|
|
32683
|
-
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-
|
|
32759
|
+
const DEFAULT_AGENT_KIT_MODEL_NAME = 'gpt-5.4-mini';
|
|
32684
32760
|
/**
|
|
32685
32761
|
* Creates one structured log entry for streamed tool-call updates.
|
|
32686
32762
|
*
|
|
@@ -34746,6 +34822,7 @@
|
|
|
34746
34822
|
* @param agentSource The agent source string that defines the agent's behavior
|
|
34747
34823
|
*/
|
|
34748
34824
|
constructor(options) {
|
|
34825
|
+
var _a;
|
|
34749
34826
|
this.options = options;
|
|
34750
34827
|
/**
|
|
34751
34828
|
* Cached model requirements to avoid re-parsing the agent source
|
|
@@ -34755,6 +34832,7 @@
|
|
|
34755
34832
|
* Cached parsed agent information
|
|
34756
34833
|
*/
|
|
34757
34834
|
this._cachedAgentInfo = null;
|
|
34835
|
+
this.precomputedModelRequirements = (_a = options.precomputedModelRequirements) !== null && _a !== void 0 ? _a : null;
|
|
34758
34836
|
}
|
|
34759
34837
|
/**
|
|
34760
34838
|
* Updates the agent source and clears the cache
|
|
@@ -34762,9 +34840,13 @@
|
|
|
34762
34840
|
* @param agentSource The new agent source string
|
|
34763
34841
|
*/
|
|
34764
34842
|
updateAgentSource(agentSource) {
|
|
34843
|
+
if (this.options.agentSource === agentSource) {
|
|
34844
|
+
return;
|
|
34845
|
+
}
|
|
34765
34846
|
this.options.agentSource = agentSource;
|
|
34766
34847
|
this._cachedAgentInfo = null;
|
|
34767
34848
|
this._cachedModelRequirements = null;
|
|
34849
|
+
this.precomputedModelRequirements = null;
|
|
34768
34850
|
}
|
|
34769
34851
|
/**
|
|
34770
34852
|
* Get cached or parse agent information
|
|
@@ -34781,6 +34863,16 @@
|
|
|
34781
34863
|
* Note: [🐤] This is names `getModelRequirements` *(not `getAgentModelRequirements`)* because in future these two will be united
|
|
34782
34864
|
*/
|
|
34783
34865
|
async getModelRequirements() {
|
|
34866
|
+
var _a, _b;
|
|
34867
|
+
if (this.precomputedModelRequirements !== null) {
|
|
34868
|
+
if (this.options.isVerbose) {
|
|
34869
|
+
console.info('[🤰]', 'Using precomputed agent model requirements', {
|
|
34870
|
+
agent: this.title,
|
|
34871
|
+
toolCount: (_b = (_a = this.precomputedModelRequirements.tools) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
|
|
34872
|
+
});
|
|
34873
|
+
}
|
|
34874
|
+
return this.precomputedModelRequirements;
|
|
34875
|
+
}
|
|
34784
34876
|
if (this._cachedModelRequirements === null) {
|
|
34785
34877
|
const preparationStartedAtMs = Date.now();
|
|
34786
34878
|
if (this.options.isVerbose) {
|
|
@@ -34890,6 +34982,7 @@
|
|
|
34890
34982
|
* Resolves agent requirements, attachments, and runtime overrides into one forwarded chat prompt.
|
|
34891
34983
|
*/
|
|
34892
34984
|
async prepareChatPrompt(prompt) {
|
|
34985
|
+
var _a;
|
|
34893
34986
|
const chatPrompt = this.requireChatPrompt(prompt);
|
|
34894
34987
|
const { sanitizedRequirements, promptSuffix } = await this.getSanitizedAgentModelRequirements();
|
|
34895
34988
|
const attachments = normalizeChatAttachments(chatPrompt.attachments);
|
|
@@ -34907,7 +35000,16 @@
|
|
|
34907
35000
|
mergedTools,
|
|
34908
35001
|
knowledgeSourcesForAgent,
|
|
34909
35002
|
});
|
|
34910
|
-
|
|
35003
|
+
if (this.options.isVerbose) {
|
|
35004
|
+
console.info('[🤰]', 'Prepared agent chat prompt', {
|
|
35005
|
+
agent: this.title,
|
|
35006
|
+
usedPrecomputedModelRequirements: this.precomputedModelRequirements !== null,
|
|
35007
|
+
toolNames: mergedTools.map((tool) => tool.name),
|
|
35008
|
+
knowledgeSourcesCount: (_a = knowledgeSourcesForAgent === null || knowledgeSourcesForAgent === void 0 ? void 0 : knowledgeSourcesForAgent.length) !== null && _a !== void 0 ? _a : 0,
|
|
35009
|
+
promptSuffixLength: promptSuffix.length,
|
|
35010
|
+
systemMessageLength: sanitizedRequirements.systemMessage.length,
|
|
35011
|
+
});
|
|
35012
|
+
}
|
|
34911
35013
|
return {
|
|
34912
35014
|
forwardedPrompt,
|
|
34913
35015
|
sanitizedRequirements,
|
|
@@ -35094,6 +35196,7 @@
|
|
|
35094
35196
|
* Runs one prepared prompt through the deprecated OpenAI Assistant backend.
|
|
35095
35197
|
*/
|
|
35096
35198
|
async callOpenAiAssistantChatModelStream(options) {
|
|
35199
|
+
var _a, _b, _c, _d;
|
|
35097
35200
|
const assistant = await this.getOrPrepareOpenAiAssistant({
|
|
35098
35201
|
llmTools: options.llmTools,
|
|
35099
35202
|
originalPrompt: options.originalPrompt,
|
|
@@ -35101,7 +35204,14 @@
|
|
|
35101
35204
|
onProgress: options.onProgress,
|
|
35102
35205
|
});
|
|
35103
35206
|
const promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools = createOpenAiAssistantPrompt(options.preparedChatPrompt.forwardedPrompt);
|
|
35104
|
-
|
|
35207
|
+
if (this.options.isVerbose) {
|
|
35208
|
+
console.info('[🤰]', 'Prepared OpenAI Assistant prompt', {
|
|
35209
|
+
agent: this.title,
|
|
35210
|
+
toolNames: (_b = (_a = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements.tools) === null || _a === void 0 ? void 0 : _a.map((tool) => tool.name)) !== null && _b !== void 0 ? _b : [],
|
|
35211
|
+
knowledgeSourcesCount: (_d = (_c = promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools.modelRequirements
|
|
35212
|
+
.knowledgeSources) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0,
|
|
35213
|
+
});
|
|
35214
|
+
}
|
|
35105
35215
|
return assistant.callChatModelStream(promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools, options.onProgress, options.streamOptions);
|
|
35106
35216
|
}
|
|
35107
35217
|
/**
|
|
@@ -35792,7 +35902,8 @@
|
|
|
35792
35902
|
isVerbose: options.isVerbose,
|
|
35793
35903
|
llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
|
|
35794
35904
|
assistantPreparationMode: options.assistantPreparationMode,
|
|
35795
|
-
agentSource: agentSource.value,
|
|
35905
|
+
agentSource: agentSource.value,
|
|
35906
|
+
precomputedModelRequirements: options.precomputedModelRequirements,
|
|
35796
35907
|
});
|
|
35797
35908
|
this._agentName = undefined;
|
|
35798
35909
|
/**
|
|
@@ -38410,6 +38521,7 @@
|
|
|
38410
38521
|
|
|
38411
38522
|
PERSONA ${block(personaDescription)}
|
|
38412
38523
|
${block(initialRules.map((rule) => `RULE ${rule}`).join('\n'))}
|
|
38524
|
+
CLOSED
|
|
38413
38525
|
`));
|
|
38414
38526
|
// Note: `META COLOR ${color || PROMPTBOOK_COLOR.toHex()}` was removed for now
|
|
38415
38527
|
// Note: `META FONT Playfair Display, sans-serif` was removed for now
|