@promptbook/vercel 0.100.0-2 → 0.100.0-21

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.
Files changed (49) hide show
  1. package/README.md +1 -0
  2. package/esm/index.es.js +1 -1
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/core.index.d.ts +24 -0
  5. package/esm/typings/src/_packages/types.index.d.ts +28 -0
  6. package/esm/typings/src/book-2.0/agent-source/parseAgentSource.d.ts +30 -0
  7. package/esm/typings/src/book-2.0/agent-source/parseAgentSource.test.d.ts +1 -0
  8. package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +26 -0
  9. package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +30 -0
  10. package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +31 -0
  11. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/FrontendRAGService.d.ts +48 -0
  12. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +43 -0
  13. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/RAGService.d.ts +54 -0
  14. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/processors/BaseKnowledgeProcessor.d.ts +45 -0
  15. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/processors/PdfProcessor.d.ts +31 -0
  16. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/processors/ProcessorFactory.d.ts +23 -0
  17. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/processors/TextProcessor.d.ts +18 -0
  18. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/types.d.ts +56 -0
  19. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/utils/ragHelper.d.ts +34 -0
  20. package/esm/typings/src/book-2.0/commitments/META_IMAGE/META_IMAGE.d.ts +36 -0
  21. package/esm/typings/src/book-2.0/commitments/META_LINK/META_LINK.d.ts +48 -0
  22. package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +31 -0
  23. package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +41 -0
  24. package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +38 -0
  25. package/esm/typings/src/book-2.0/commitments/RULE/RULE.d.ts +36 -0
  26. package/esm/typings/src/book-2.0/commitments/SAMPLE/SAMPLE.d.ts +36 -0
  27. package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +30 -0
  28. package/esm/typings/src/book-2.0/commitments/_base/BaseCommitmentDefinition.d.ts +42 -0
  29. package/esm/typings/src/book-2.0/commitments/_base/BookCommitment.d.ts +5 -0
  30. package/esm/typings/src/book-2.0/commitments/_base/CommitmentDefinition.d.ts +37 -0
  31. package/esm/typings/src/book-2.0/commitments/_base/NotYetImplementedCommitmentDefinition.d.ts +14 -0
  32. package/esm/typings/src/book-2.0/commitments/_base/createEmptyAgentModelRequirements.d.ts +19 -0
  33. package/esm/typings/src/book-2.0/commitments/_misc/AgentModelRequirements.d.ts +37 -0
  34. package/esm/typings/src/book-2.0/commitments/_misc/AgentSourceParseResult.d.ts +18 -0
  35. package/esm/typings/src/book-2.0/commitments/_misc/ParsedCommitment.d.ts +22 -0
  36. package/esm/typings/src/book-2.0/commitments/_misc/createAgentModelRequirements.d.ts +61 -0
  37. package/esm/typings/src/book-2.0/commitments/_misc/createAgentModelRequirementsWithCommitments.d.ts +35 -0
  38. package/esm/typings/src/book-2.0/commitments/_misc/createCommitmentRegex.d.ts +20 -0
  39. package/esm/typings/src/book-2.0/commitments/_misc/parseAgentSourceWithCommitments.d.ts +24 -0
  40. package/esm/typings/src/book-2.0/commitments/_misc/removeCommentsFromSystemMessage.d.ts +11 -0
  41. package/esm/typings/src/book-2.0/commitments/index.d.ts +56 -0
  42. package/esm/typings/src/book-2.0/utils/profileImageUtils.d.ts +39 -0
  43. package/esm/typings/src/pipeline/book-notation.d.ts +2 -1
  44. package/esm/typings/src/types/typeAliases.d.ts +6 -0
  45. package/esm/typings/src/version.d.ts +1 -1
  46. package/esm/typings/src/wizard/wizard.d.ts +14 -4
  47. package/package.json +2 -2
  48. package/umd/index.umd.js +1 -1
  49. package/umd/index.umd.js.map +1 -1
@@ -0,0 +1,56 @@
1
+ import type { string_url } from '../../../types/typeAliases';
2
+ /**
3
+ * Supported knowledge source formats
4
+ */
5
+ export type KnowledgeSourceFormat = 'pdf' | 'text' | 'markdown' | 'html';
6
+ /**
7
+ * Knowledge source metadata
8
+ */
9
+ export interface KnowledgeSourceMetadata {
10
+ readonly url: string_url;
11
+ readonly format: KnowledgeSourceFormat;
12
+ readonly title?: string;
13
+ readonly lastFetched?: Date;
14
+ readonly contentHash?: string;
15
+ }
16
+ /**
17
+ * Processed knowledge chunk for RAG
18
+ */
19
+ export interface KnowledgeChunk {
20
+ readonly id: string;
21
+ readonly sourceUrl: string_url;
22
+ readonly content: string;
23
+ readonly metadata: {
24
+ readonly pageNumber?: number;
25
+ readonly section?: string;
26
+ readonly chunkIndex: number;
27
+ readonly totalChunks: number;
28
+ };
29
+ }
30
+ /**
31
+ * Knowledge base containing all processed knowledge sources
32
+ */
33
+ export interface KnowledgeBase {
34
+ readonly sources: KnowledgeSourceMetadata[];
35
+ readonly chunks: KnowledgeChunk[];
36
+ readonly lastUpdated: Date;
37
+ }
38
+ /**
39
+ * RAG retrieval result
40
+ */
41
+ export interface RetrievalResult {
42
+ readonly chunk: KnowledgeChunk;
43
+ readonly relevanceScore: number;
44
+ }
45
+ /**
46
+ * Configuration for RAG processing
47
+ */
48
+ export interface RAGConfig {
49
+ readonly maxChunkSize: number;
50
+ readonly chunkOverlap: number;
51
+ readonly maxRetrievedChunks: number;
52
+ readonly minRelevanceScore: number;
53
+ }
54
+ /**
55
+ * [💞] Ignore a discrepancy between file name and entity name
56
+ */
@@ -0,0 +1,34 @@
1
+ import type { AgentModelRequirements } from '../../_misc/AgentModelRequirements';
2
+ import { FrontendRAGService } from '../FrontendRAGService';
3
+ /**
4
+ * Helper utilities for RAG processing in chat systems
5
+ *
6
+ * @private
7
+ */
8
+ export declare class RAGHelper {
9
+ /**
10
+ * Initialize knowledge sources from agent requirements
11
+ * This should be called when starting a chat session
12
+ */
13
+ static initializeKnowledgeSources(requirements: AgentModelRequirements): Promise<FrontendRAGService | null>;
14
+ /**
15
+ * Get relevant context for a user query
16
+ * This should be called before sending the query to the AI model
17
+ */
18
+ static getRelevantContext(ragService: FrontendRAGService | null, userQuery: string): Promise<string>;
19
+ /**
20
+ * Update system message with relevant context for a query
21
+ */
22
+ static updateSystemMessageWithContext(requirements: AgentModelRequirements, ragService: FrontendRAGService | null, userQuery: string): Promise<AgentModelRequirements>;
23
+ /**
24
+ * Get statistics about the knowledge base
25
+ */
26
+ static getKnowledgeStats(ragService: FrontendRAGService | null): {
27
+ sources: number;
28
+ chunks: number;
29
+ isInitialized: boolean;
30
+ } | null;
31
+ }
32
+ /**
33
+ * Note: [💞] Ignore a discrepancy between file name and entity name
34
+ */
@@ -0,0 +1,36 @@
1
+ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
2
+ import type { AgentModelRequirements } from '../_misc/AgentModelRequirements';
3
+ /**
4
+ * META IMAGE commitment definition
5
+ *
6
+ * The META IMAGE commitment sets the agent's avatar/profile image URL.
7
+ * This commitment is special because it doesn't affect the system message,
8
+ * but is handled separately in the parsing logic.
9
+ *
10
+ * Example usage in agent source:
11
+ *
12
+ * ```book
13
+ * META IMAGE https://example.com/avatar.jpg
14
+ * META IMAGE /assets/agent-avatar.png
15
+ * ```
16
+ *
17
+ * @private [🪔] Maybe export the commitments through some package
18
+ */
19
+ export declare class MetaImageCommitmentDefinition extends BaseCommitmentDefinition<'META IMAGE'> {
20
+ constructor();
21
+ applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
22
+ /**
23
+ * Extracts the profile image URL from the content
24
+ * This is used by the parsing logic
25
+ */
26
+ extractProfileImageUrl(content: string): string | null;
27
+ }
28
+ /**
29
+ * Singleton instance of the META IMAGE commitment definition
30
+ *
31
+ * @private [🪔] Maybe export the commitments through some package
32
+ */
33
+ export declare const MetaImageCommitment: MetaImageCommitmentDefinition;
34
+ /**
35
+ * Note: [💞] Ignore a discrepancy between file name and entity name
36
+ */
@@ -0,0 +1,48 @@
1
+ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
2
+ import type { AgentModelRequirements } from '../_misc/AgentModelRequirements';
3
+ /**
4
+ * META LINK commitment definition
5
+ *
6
+ * The `META LINK` commitment represents the link to the person from whom the agent is created.
7
+ * This commitment is special because it doesn't affect the system message,
8
+ * but is handled separately in the parsing logic for profile display.
9
+ *
10
+ * Example usage in agent source:
11
+ *
12
+ * ```
13
+ * META LINK https://twitter.com/username
14
+ * META LINK https://linkedin.com/in/profile
15
+ * META LINK https://github.com/username
16
+ * ```
17
+ *
18
+ * Multiple `META LINK` commitments can be used when there are multiple sources:
19
+ *
20
+ * ```book
21
+ * META LINK https://twitter.com/username
22
+ * META LINK https://linkedin.com/in/profile
23
+ * ```
24
+ *
25
+ * @private [🪔] Maybe export the commitments through some package
26
+ */
27
+ export declare class MetaLinkCommitmentDefinition extends BaseCommitmentDefinition<'META LINK'> {
28
+ constructor();
29
+ applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
30
+ /**
31
+ * Extracts the profile link URL from the content
32
+ * This is used by the parsing logic
33
+ */
34
+ extractProfileLinkUrl(content: string): string | null;
35
+ /**
36
+ * Validates if the provided content is a valid URL
37
+ */
38
+ isValidUrl(content: string): boolean;
39
+ }
40
+ /**
41
+ * Singleton instance of the META LINK commitment definition
42
+ *
43
+ * @private [🪔] Maybe export the commitments through some package
44
+ */
45
+ export declare const MetaLinkCommitment: MetaLinkCommitmentDefinition;
46
+ /**
47
+ * Note: [💞] Ignore a discrepancy between file name and entity name
48
+ */
@@ -0,0 +1,31 @@
1
+ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
2
+ import type { AgentModelRequirements } from '../_misc/AgentModelRequirements';
3
+ /**
4
+ * MODEL commitment definition
5
+ *
6
+ * The MODEL commitment specifies which AI model to use and can also set
7
+ * model-specific parameters like temperature, topP, and topK.
8
+ *
9
+ * Example usage in agent source:
10
+ *
11
+ * ```book
12
+ * MODEL gpt-4
13
+ * MODEL claude-3-opus temperature=0.3
14
+ * MODEL gpt-3.5-turbo temperature=0.8 topP=0.9
15
+ * ```
16
+ *
17
+ * @private [🪔] Maybe export the commitments through some package
18
+ */
19
+ export declare class ModelCommitmentDefinition extends BaseCommitmentDefinition<'MODEL'> {
20
+ constructor();
21
+ applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
22
+ }
23
+ /**
24
+ * Singleton instance of the MODEL commitment definition
25
+ *
26
+ * @private [🪔] Maybe export the commitments through some package
27
+ */
28
+ export declare const ModelCommitment: ModelCommitmentDefinition;
29
+ /**
30
+ * Note: [💞] Ignore a discrepancy between file name and entity name
31
+ */
@@ -0,0 +1,41 @@
1
+ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
2
+ import type { AgentModelRequirements } from '../_misc/AgentModelRequirements';
3
+ /**
4
+ * NOTE commitment definition
5
+ *
6
+ * The NOTE commitment is used to add comments to the agent source without making any changes
7
+ * to the system message or agent model requirements. It serves as a documentation mechanism
8
+ * for developers to add explanatory comments, reminders, or annotations directly in the agent source.
9
+ *
10
+ * Key features:
11
+ * - Makes no changes to the system message
12
+ * - Makes no changes to agent model requirements
13
+ * - Content is preserved in metadata.NOTE for debugging and inspection
14
+ * - Multiple NOTE commitments are aggregated together
15
+ * - Comments (# NOTE) are removed from the final system message
16
+ *
17
+ * Example usage in agent source:
18
+ *
19
+ * ```book
20
+ * NOTE This agent was designed for customer support scenarios
21
+ * NOTE Remember to update the knowledge base monthly
22
+ * NOTE Performance optimized for quick response times
23
+ * ```
24
+ *
25
+ * The above notes will be stored in metadata but won't affect the agent's behavior.
26
+ *
27
+ * @private [🪔] Maybe export the commitments through some package
28
+ */
29
+ export declare class NoteCommitmentDefinition extends BaseCommitmentDefinition<'NOTE'> {
30
+ constructor();
31
+ applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
32
+ }
33
+ /**
34
+ * Singleton instance of the NOTE commitment definition
35
+ *
36
+ * @private [🪔] Maybe export the commitments through some package
37
+ */
38
+ export declare const NoteCommitment: NoteCommitmentDefinition;
39
+ /**
40
+ * [💞] Ignore a discrepancy between file name and entity name
41
+ */
@@ -0,0 +1,38 @@
1
+ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
2
+ import type { AgentModelRequirements } from '../_misc/AgentModelRequirements';
3
+ /**
4
+ * PERSONA commitment definition
5
+ *
6
+ * The PERSONA commitment modifies the agent's personality and character in the system message.
7
+ * It defines who the agent is, their background, expertise, and personality traits.
8
+ *
9
+ * Key features:
10
+ * - Multiple PERSONA commitments are automatically merged into one
11
+ * - Content is placed at the beginning of the system message
12
+ * - Original content with comments is preserved in metadata.PERSONA
13
+ * - Comments (# PERSONA) are removed from the final system message
14
+ *
15
+ * Example usage in agent source:
16
+ *
17
+ * ```book
18
+ * PERSONA You are a helpful programming assistant with expertise in TypeScript and React
19
+ * PERSONA You have deep knowledge of modern web development practices
20
+ * ```
21
+ *
22
+ * The above will be merged into a single persona section at the beginning of the system message.
23
+ *
24
+ * @private [🪔] Maybe export the commitments through some package
25
+ */
26
+ export declare class PersonaCommitmentDefinition extends BaseCommitmentDefinition<'PERSONA'> {
27
+ constructor();
28
+ applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
29
+ }
30
+ /**
31
+ * Singleton instance of the PERSONA commitment definition
32
+ *
33
+ * @private [🪔] Maybe export the commitments through some package
34
+ */
35
+ export declare const PersonaCommitment: PersonaCommitmentDefinition;
36
+ /**
37
+ * Note: [💞] Ignore a discrepancy between file name and entity name
38
+ */
@@ -0,0 +1,36 @@
1
+ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
2
+ import type { AgentModelRequirements } from '../_misc/AgentModelRequirements';
3
+ /**
4
+ * RULE commitment definition
5
+ *
6
+ * The RULE/RULES commitment adds behavioral constraints and guidelines that the agent must follow.
7
+ * These are specific instructions about what the agent should or shouldn't do.
8
+ *
9
+ * Example usage in agent source:
10
+ *
11
+ * ```book
12
+ * RULE Always ask for clarification if the user's request is ambiguous
13
+ * RULES Never provide medical advice, always refer to healthcare professionals
14
+ * ```
15
+ *
16
+ * @private [🪔] Maybe export the commitments through some package
17
+ */
18
+ export declare class RuleCommitmentDefinition extends BaseCommitmentDefinition<'RULE' | 'RULES'> {
19
+ constructor(type?: 'RULE' | 'RULES');
20
+ applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
21
+ }
22
+ /**
23
+ * Singleton instances of the RULE commitment definitions
24
+ *
25
+ * @private [🪔] Maybe export the commitments through some package
26
+ */
27
+ export declare const RuleCommitment: RuleCommitmentDefinition;
28
+ /**
29
+ * Singleton instances of the RULE commitment definitions
30
+ *
31
+ * @private [🪔] Maybe export the commitments through some package
32
+ */
33
+ export declare const RulesCommitment: RuleCommitmentDefinition;
34
+ /**
35
+ * Note: [💞] Ignore a discrepancy between file name and entity name
36
+ */
@@ -0,0 +1,36 @@
1
+ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
2
+ import type { AgentModelRequirements } from '../_misc/AgentModelRequirements';
3
+ /**
4
+ * SAMPLE commitment definition
5
+ *
6
+ * The SAMPLE/EXAMPLE commitment provides examples of how the agent should respond
7
+ * or behave in certain situations. These examples help guide the agent's responses.
8
+ *
9
+ * Example usage in agent source:
10
+ *
11
+ * ```book
12
+ * SAMPLE When asked about pricing, respond: "Our basic plan starts at $10/month..."
13
+ * EXAMPLE For code questions, always include working code snippets
14
+ * ```
15
+ *
16
+ * @private [🪔] Maybe export the commitments through some package
17
+ */
18
+ export declare class SampleCommitmentDefinition extends BaseCommitmentDefinition<'SAMPLE' | 'EXAMPLE'> {
19
+ constructor(type?: 'SAMPLE' | 'EXAMPLE');
20
+ applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
21
+ }
22
+ /**
23
+ * Singleton instances of the SAMPLE commitment definitions
24
+ *
25
+ * @private [🪔] Maybe export the commitments through some package
26
+ */
27
+ export declare const SampleCommitment: SampleCommitmentDefinition;
28
+ /**
29
+ * Singleton instances of the SAMPLE commitment definitions
30
+ *
31
+ * @private [🪔] Maybe export the commitments through some package
32
+ */
33
+ export declare const ExampleCommitment: SampleCommitmentDefinition;
34
+ /**
35
+ * Note: [💞] Ignore a discrepancy between file name and entity name
36
+ */
@@ -0,0 +1,30 @@
1
+ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
2
+ import type { AgentModelRequirements } from '../_misc/AgentModelRequirements';
3
+ /**
4
+ * STYLE commitment definition
5
+ *
6
+ * The STYLE commitment defines how the agent should format and present its responses.
7
+ * This includes tone, writing style, formatting preferences, and communication patterns.
8
+ *
9
+ * Example usage in agent source:
10
+ *
11
+ * ```book
12
+ * STYLE Write in a professional but friendly tone, use bullet points for lists
13
+ * STYLE Always provide code examples when explaining programming concepts
14
+ * ```
15
+ *
16
+ * @private [🪔] Maybe export the commitments through some package
17
+ */
18
+ export declare class StyleCommitmentDefinition extends BaseCommitmentDefinition<'STYLE'> {
19
+ constructor();
20
+ applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
21
+ }
22
+ /**
23
+ * Singleton instance of the STYLE commitment definition
24
+ *
25
+ * @private [🪔] Maybe export the commitments through some package
26
+ */
27
+ export declare const StyleCommitment: StyleCommitmentDefinition;
28
+ /**
29
+ * [💞] Ignore a discrepancy between file name and entity name
30
+ */
@@ -0,0 +1,42 @@
1
+ import type { AgentModelRequirements } from '../_misc/AgentModelRequirements';
2
+ import type { CommitmentDefinition } from './CommitmentDefinition';
3
+ /**
4
+ * Base implementation of CommitmentDefinition that provides common functionality
5
+ * Most commitments can extend this class and only override the applyToAgentModelRequirements method
6
+ *
7
+ * @private
8
+ */
9
+ export declare abstract class BaseCommitmentDefinition<TBookCommitment extends string> implements CommitmentDefinition {
10
+ readonly type: TBookCommitment;
11
+ constructor(type: TBookCommitment);
12
+ /**
13
+ * Creates a regex pattern to match this commitment in agent source
14
+ * Uses the existing createCommitmentRegex function as internal helper
15
+ */
16
+ createRegex(): RegExp;
17
+ /**
18
+ * Creates a regex pattern to match just the commitment type
19
+ * Uses the existing createCommitmentTypeRegex function as internal helper
20
+ */
21
+ createTypeRegex(): RegExp;
22
+ /**
23
+ * Applies this commitment's logic to the agent model requirements
24
+ * This method must be implemented by each specific commitment
25
+ */
26
+ abstract applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
27
+ /**
28
+ * Helper method to create a new requirements object with updated system message
29
+ * This is commonly used by many commitments
30
+ */
31
+ protected updateSystemMessage(requirements: AgentModelRequirements, messageUpdate: string | ((currentMessage: string) => string)): AgentModelRequirements;
32
+ /**
33
+ * Helper method to append content to the system message
34
+ */
35
+ protected appendToSystemMessage(requirements: AgentModelRequirements, content: string, separator?: string): AgentModelRequirements;
36
+ /**
37
+ * Helper method to add a comment section to the system message
38
+ * Comments are lines starting with # that will be removed from the final system message
39
+ * but can be useful for organizing and structuring the message during processing
40
+ */
41
+ protected addCommentSection(requirements: AgentModelRequirements, commentTitle: string, content: string, position?: 'beginning' | 'end'): AgentModelRequirements;
42
+ }
@@ -0,0 +1,5 @@
1
+ import { COMMITMENT_REGISTRY } from '../index';
2
+ /**
3
+ * All available book commitment types
4
+ */
5
+ export type BookCommitment = typeof COMMITMENT_REGISTRY[number]['type'];
@@ -0,0 +1,37 @@
1
+ import type { AgentModelRequirements } from '../_misc/AgentModelRequirements';
2
+ /**
3
+ * Definition of a commitment that can be applied to agent model requirements
4
+ *
5
+ * Each commitment is self-contained and manages its own logic for:
6
+ * - Creating regex patterns for parsing
7
+ * - Applying its effects to agent model requirements
8
+ */
9
+ export interface CommitmentDefinition {
10
+ /**
11
+ * The type/name of this commitment (e.g., 'PERSONA', 'KNOWLEDGE', etc.)
12
+ */
13
+ readonly type: string;
14
+ /**
15
+ * Creates a regex pattern to match this commitment in agent source
16
+ * This regex should capture the commitment content in a 'contents' named group
17
+ *
18
+ * @returns RegExp that matches the full commitment line
19
+ */
20
+ createRegex(): RegExp;
21
+ /**
22
+ * Creates a regex pattern to match just the commitment type
23
+ * This is useful for checking if a line contains this commitment type
24
+ *
25
+ * @returns RegExp that matches just the commitment type
26
+ */
27
+ createTypeRegex(): RegExp;
28
+ /**
29
+ * Applies this commitment's logic to the agent model requirements
30
+ * This method should be pure and return a new requirements object
31
+ *
32
+ * @param requirements Current agent model requirements
33
+ * @param content The content part of the commitment (after the type)
34
+ * @returns Updated agent model requirements
35
+ */
36
+ applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
37
+ }
@@ -0,0 +1,14 @@
1
+ import type { AgentModelRequirements } from '../_misc/AgentModelRequirements';
2
+ import { BaseCommitmentDefinition } from './BaseCommitmentDefinition';
3
+ /**
4
+ * Placeholder commitment definition for commitments that are not yet implemented
5
+ *
6
+ * This commitment simply adds its content 1:1 into the system message,
7
+ * preserving the original behavior until proper implementation is added.
8
+ *
9
+ * @public exported from `@promptbook/core`
10
+ */
11
+ export declare class NotYetImplementedCommitmentDefinition<TBookCommitment extends string> extends BaseCommitmentDefinition<TBookCommitment> {
12
+ constructor(type: TBookCommitment);
13
+ applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
14
+ }
@@ -0,0 +1,19 @@
1
+ import type { AgentModelRequirements } from '../_misc/AgentModelRequirements';
2
+ /**
3
+ * Creates an empty/basic agent model requirements object
4
+ * This serves as the starting point for the reduce-like pattern
5
+ * where each commitment applies its changes to build the final requirements
6
+ *
7
+ * @public exported from `@promptbook/core`
8
+ */
9
+ export declare function createEmptyAgentModelRequirements(): AgentModelRequirements;
10
+ /**
11
+ * Creates a basic agent model requirements with just the agent name
12
+ * This is used when we have an agent name but no commitments
13
+ *
14
+ * @public exported from `@promptbook/core`
15
+ */
16
+ export declare function createBasicAgentModelRequirements(agentName: string | null): AgentModelRequirements;
17
+ /**
18
+ * TODO: !!!! Deduplicate model requirements
19
+ */
@@ -0,0 +1,37 @@
1
+ import { TODO_any } from "../../../_packages/types.index";
2
+ /**
3
+ * Model requirements for an agent
4
+ *
5
+ * This is like "compiled" version of agent source
6
+ */
7
+ export interface AgentModelRequirements {
8
+ /**
9
+ * The system message that defines the agent's behavior and personality
10
+ */
11
+ readonly systemMessage: string;
12
+ /**
13
+ * The model name to use for this agent
14
+ */
15
+ readonly modelName: string;
16
+ /**
17
+ * Optional list of MCP servers that the agent can connect to
18
+ */
19
+ readonly mcpServers?: string[];
20
+ /**
21
+ * Temperature for the agent's responses, controlling randomness
22
+ */
23
+ readonly temperature?: number;
24
+ /**
25
+ * Top-p sampling value for the agent's responses
26
+ */
27
+ readonly topP?: number;
28
+ /**
29
+ * Top-k sampling value for the agent's responses
30
+ */
31
+ readonly topK?: number;
32
+ /**
33
+ * Arbitrary metadata storage for commitments
34
+ * Each commitment can store its own data here
35
+ */
36
+ readonly metadata?: Record<string, TODO_any>;
37
+ }
@@ -0,0 +1,18 @@
1
+ import type { ParsedCommitment } from './ParsedCommitment';
2
+ /**
3
+ * Result of parsing agent source for commitments
4
+ */
5
+ export interface AgentSourceParseResult {
6
+ /**
7
+ * The agent name (first line)
8
+ */
9
+ agentName: string | null;
10
+ /**
11
+ * All parsed commitments
12
+ */
13
+ commitments: ParsedCommitment[];
14
+ /**
15
+ * Lines that are not commitments (for system message)
16
+ */
17
+ nonCommitmentLines: string[];
18
+ }
@@ -0,0 +1,22 @@
1
+ import type { BookCommitment } from '../_base/BookCommitment';
2
+ /**
3
+ * Parsed commitment line from agent source
4
+ */
5
+ export interface ParsedCommitment {
6
+ /**
7
+ * The commitment type (e.g., 'PERSONA', 'KNOWLEDGE')
8
+ */
9
+ type: BookCommitment;
10
+ /**
11
+ * The content part of the commitment
12
+ */
13
+ content: string;
14
+ /**
15
+ * The original line from the agent source
16
+ */
17
+ originalLine: string;
18
+ /**
19
+ * Line number in the agent source (1-based)
20
+ */
21
+ lineNumber: number;
22
+ }
@@ -0,0 +1,61 @@
1
+ import type { string_book } from '../../agent-source/string_book';
2
+ import type { AgentModelRequirements } from './AgentModelRequirements';
3
+ /**
4
+ * Creates model requirements for an agent based on its source
5
+ * Results are cached to improve performance for repeated calls with the same agentSource and modelName
6
+ *
7
+ * There are 2 similar functions:
8
+ * - `parseAgentSource` which is a lightweight parser for agent source, it parses basic information and its purpose is to be quick and synchronous. The commitments there are hardcoded.
9
+ * - `createAgentModelRequirements` which is an asynchronous function that creates model requirements it applies each commitment one by one and works asynchronously.
10
+ *
11
+ * @public exported from `@promptbook/core`
12
+ */
13
+ export declare function createAgentModelRequirements(agentSource: string_book, modelName?: string): Promise<AgentModelRequirements>;
14
+ /**
15
+ * Clears the cache for createAgentModelRequirements
16
+ * Useful when agent sources are updated and cached results should be invalidated
17
+ *
18
+ * @private
19
+ */
20
+ export declare function clearAgentModelRequirementsCache(): void;
21
+ /**
22
+ * Removes cache entries for a specific agent source (all model variants)
23
+ * @param agentSource The agent source to remove from cache
24
+ * @private
25
+ */
26
+ export declare function invalidateAgentModelRequirementsCache(agentSource: string_book): void;
27
+ /**
28
+ * Gets the current cache size (for debugging/monitoring)
29
+ *
30
+ * @private
31
+ */
32
+ export declare function getAgentModelRequirementsCacheSize(): number;
33
+ /**
34
+ * Extracts MCP servers from agent source
35
+ *
36
+ * @param agentSource The agent source string that may contain MCP lines
37
+ * @returns Array of MCP server identifiers
38
+ *
39
+ * @private TODO: [🧠] Maybe should be public
40
+ */
41
+ export declare function extractMcpServers(agentSource: string_book): string[];
42
+ /**
43
+ * Creates a system message for an agent based on its source
44
+ * @deprecated Use createAgentModelRequirements instead
45
+ * @private
46
+ */
47
+ export declare function createAgentSystemMessage(agentSource: string_book): Promise<string>;
48
+ /**
49
+ * Extracts the agent name from the first line of the agent source
50
+ * @deprecated Use parseAgentSource instead
51
+ * @private
52
+ */
53
+ export declare function extractAgentName(agentSource: string_book): string;
54
+ /**
55
+ * Extracts the profile image URL from agent source or returns gravatar fallback
56
+ * @param agentSource The agent source string that may contain META IMAGE line
57
+ * @returns Profile image URL (from source or gravatar fallback)
58
+ * @deprecated Use parseAgentSource instead
59
+ * @private
60
+ */
61
+ export declare function extractAgentProfileImage(agentSource: string_book): string;