@agentforge/core 0.16.87 → 0.16.88

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/dist/index.cjs CHANGED
@@ -5654,9 +5654,11 @@ function createAuditLogger(options) {
5654
5654
  return new AuditLogger(options);
5655
5655
  }
5656
5656
 
5657
- // src/prompt-loader/index.ts
5657
+ // src/prompt-loader/file-loader.ts
5658
5658
  var import_fs = require("fs");
5659
5659
  var import_path = require("path");
5660
+
5661
+ // src/prompt-loader/variables.ts
5660
5662
  var MAX_VARIABLE_LENGTH = 500;
5661
5663
  function createPromptVariableMap() {
5662
5664
  return /* @__PURE__ */ Object.create(null);
@@ -5668,9 +5670,7 @@ function isRenderTemplateOptions(value) {
5668
5670
  return isPromptVariableMap(value) && (Object.prototype.hasOwnProperty.call(value, "trustedVariables") || Object.prototype.hasOwnProperty.call(value, "untrustedVariables"));
5669
5671
  }
5670
5672
  function normalizeVariableMap(value) {
5671
- if (!isPromptVariableMap(value)) {
5672
- return createPromptVariableMap();
5673
- }
5673
+ if (!isPromptVariableMap(value)) return createPromptVariableMap();
5674
5674
  return Object.assign(createPromptVariableMap(), value);
5675
5675
  }
5676
5676
  function sanitizeVariableMap(variables) {
@@ -5681,11 +5681,7 @@ function sanitizeVariableMap(variables) {
5681
5681
  return sanitizedVariables;
5682
5682
  }
5683
5683
  function mergeVariableMaps(baseVariables, overrideVariables) {
5684
- return Object.assign(
5685
- createPromptVariableMap(),
5686
- baseVariables,
5687
- overrideVariables
5688
- );
5684
+ return Object.assign(createPromptVariableMap(), baseVariables, overrideVariables);
5689
5685
  }
5690
5686
  function sanitizeValue(value) {
5691
5687
  if (value === void 0 || value === null) return "";
@@ -5694,10 +5690,12 @@ function sanitizeValue(value) {
5694
5690
  sanitized = sanitized.replace(/[\r\n]+/g, " ");
5695
5691
  sanitized = sanitized.trim().replace(/\s+/g, " ");
5696
5692
  if (sanitized.length > MAX_VARIABLE_LENGTH) {
5697
- sanitized = sanitized.substring(0, MAX_VARIABLE_LENGTH) + "...";
5693
+ sanitized = `${sanitized.substring(0, MAX_VARIABLE_LENGTH)}...`;
5698
5694
  }
5699
5695
  return sanitized;
5700
5696
  }
5697
+
5698
+ // src/prompt-loader/renderer.ts
5701
5699
  function renderTemplate(template, options) {
5702
5700
  let rawVariables;
5703
5701
  let sanitizedVariables;
@@ -5713,17 +5711,18 @@ function renderTemplate(template, options) {
5713
5711
  rawVariables = normalizeVariableMap(options);
5714
5712
  sanitizedVariables = rawVariables;
5715
5713
  }
5716
- let result = template;
5717
- result = result.replace(/\{\{#if\s+(\w+)\}\}([\s\S]*?)\{\{\/if\}\}/g, (_, varName, content) => {
5718
- return rawVariables[varName] ? content : "";
5719
- });
5720
- result = result.replace(/\{\{(\w+)\}\}/g, (_, varName) => {
5721
- const value = sanitizedVariables[varName];
5722
- if (value === void 0 || value === null) return "";
5723
- return String(value);
5714
+ let result = template.replace(
5715
+ /\{\{#if\s+(\w+)\}\}([\s\S]*?)\{\{\/if\}\}/g,
5716
+ (_, variableName, content) => rawVariables[variableName] ? content : ""
5717
+ );
5718
+ result = result.replace(/\{\{(\w+)\}\}/g, (_, variableName) => {
5719
+ const value = sanitizedVariables[variableName];
5720
+ return value === void 0 || value === null ? "" : String(value);
5724
5721
  });
5725
5722
  return result;
5726
5723
  }
5724
+
5725
+ // src/prompt-loader/file-loader.ts
5727
5726
  function loadPrompt(promptName, options = {}, promptsDir) {
5728
5727
  const baseDir = promptsDir || (0, import_path.join)(process.cwd(), "prompts");
5729
5728
  const promptPath = (0, import_path.join)(baseDir, `${promptName}.md`);
package/dist/index.d.cts CHANGED
@@ -4505,115 +4505,36 @@ declare class AuditLogger {
4505
4505
  }
4506
4506
  declare function createAuditLogger(options?: AuditLoggerOptions): AuditLogger;
4507
4507
 
4508
- /**
4509
- * Prompt Template Loader
4510
- *
4511
- * Utility for loading and rendering prompt templates from .md files.
4512
- * Supports variable substitution and conditional blocks.
4513
- *
4514
- * SECURITY: This module includes protection against prompt injection attacks
4515
- * by sanitizing variable values before substitution.
4516
- */
4517
4508
  type PromptVariableValue = unknown;
4518
4509
  type PromptVariableMap = Record<string, PromptVariableValue>;
4519
- /**
4520
- * Options for rendering templates with security controls
4521
- */
4510
+ /** Options for rendering templates with trusted and untrusted variables. */
4522
4511
  interface RenderTemplateOptions {
4523
- /**
4524
- * Variables from trusted sources (config files, hardcoded values)
4525
- * These will NOT be sanitized
4526
- */
4512
+ /** Variables from trusted sources. These values are not sanitized. */
4527
4513
  trustedVariables?: PromptVariableMap;
4528
- /**
4529
- * Variables from untrusted sources (user input, API calls, databases)
4530
- * These WILL be sanitized to prevent prompt injection
4531
- */
4514
+ /** Variables from untrusted sources. These values are sanitized. */
4532
4515
  untrustedVariables?: PromptVariableMap;
4533
4516
  }
4517
+
4534
4518
  /**
4535
- * Sanitize a value to prevent prompt injection attacks
4536
- *
4537
- * Protections:
4538
- * - Removes markdown headers (prevents structure hijacking)
4539
- * - Removes newlines (prevents multi-line injection)
4540
- * - Limits length (prevents prompt bloat)
4541
- *
4542
- * @param value - The value to sanitize
4543
- * @returns Sanitized string safe for use in prompts
4519
+ * Load and render a Markdown prompt template from a custom directory or the
4520
+ * `prompts` directory beneath the current working directory.
4544
4521
  */
4545
- declare function sanitizeValue(value: unknown): string;
4522
+ declare function loadPrompt(promptName: string, options?: RenderTemplateOptions | PromptVariableMap, promptsDir?: string): string;
4523
+
4546
4524
  /**
4547
- * Render a template string with variable substitution
4548
- *
4549
- * Supports:
4550
- * - Simple variables: {{variableName}}
4551
- * - Conditional blocks: {{#if variableName}}...{{/if}}
4552
- *
4553
- * SECURITY: Distinguishes between trusted and untrusted variables.
4554
- * - Trusted variables (from config) are used as-is
4555
- * - Untrusted variables (from user input) are sanitized
4556
- * - Only own enumerable properties are considered from provided variable maps
4557
- * or backwards-compatible plain objects
4558
- *
4559
- * @param template - Template string with {{variable}} placeholders
4560
- * @param options - Variables and security options
4561
- * @returns Rendered template string
4562
- *
4563
- * @example
4564
- * ```typescript
4565
- * // Safe: Trusted variables from config
4566
- * const result = renderTemplate(template, {
4567
- * trustedVariables: {
4568
- * companyName: 'Acme Corp', // From config file
4569
- * premium: true
4570
- * }
4571
- * });
4572
- *
4573
- * // Safe: Untrusted variables are sanitized
4574
- * const result = renderTemplate(template, {
4575
- * untrustedVariables: {
4576
- * userName: req.body.name, // User input - will be sanitized
4577
- * }
4578
- * });
4579
- *
4580
- * // Mixed: Some trusted, some untrusted
4581
- * const result = renderTemplate(template, {
4582
- * trustedVariables: {
4583
- * companyName: 'Acme Corp', // From config
4584
- * },
4585
- * untrustedVariables: {
4586
- * userName: req.body.name, // User input
4587
- * }
4588
- * });
4589
- * ```
4525
+ * Render substitutions and conditional blocks with trusted/untrusted controls.
4526
+ * Trusted values are substituted unchanged, untrusted values are sanitized,
4527
+ * and conditional truthiness is evaluated against the original raw values.
4528
+ * Plain variable maps remain supported as trusted input for compatibility.
4590
4529
  */
4591
4530
  declare function renderTemplate(template: string, options: RenderTemplateOptions | PromptVariableMap): string;
4531
+
4592
4532
  /**
4593
- * Load and render a prompt template from a .md file
4533
+ * Sanitize an untrusted value before prompt substitution.
4594
4534
  *
4595
- * Looks for prompts in a `prompts/` directory relative to the caller's location.
4596
- *
4597
- * @param promptName - Name of the prompt file (without .md extension)
4598
- * @param options - Variables and security options
4599
- * @param promptsDir - Optional custom prompts directory path
4600
- * @returns Rendered prompt string
4601
- *
4602
- * @example
4603
- * ```typescript
4604
- * // Backwards compatible: all variables treated as trusted
4605
- * loadPrompt('system', { companyName: 'Acme' });
4606
- *
4607
- * // Explicit: separate trusted and untrusted
4608
- * loadPrompt('system', {
4609
- * trustedVariables: { companyName: 'Acme' },
4610
- * untrustedVariables: { userName: userInput }
4611
- * });
4612
- *
4613
- * // Custom prompts directory
4614
- * loadPrompt('system', { companyName: 'Acme' }, '/path/to/prompts');
4615
- * ```
4535
+ * Removes Markdown header markers and line breaks, collapses whitespace,
4536
+ * and limits output to 500 characters plus an ellipsis.
4616
4537
  */
4617
- declare function loadPrompt(promptName: string, options?: RenderTemplateOptions | PromptVariableMap, promptsDir?: string): string;
4538
+ declare function sanitizeValue(value: unknown): string;
4618
4539
 
4619
4540
  export { AgentError, type AgentResumedEventData, type AgentWaitingEventData, type AggregateNode, type Alert, type AlertChannel, AlertManager, type AlertManagerOptions, type AlertRule, type AlertSeverity, type AnyInterrupt, type ApprovalRequiredInterrupt, type AuditLogEntry, type AuditLogQuery, AuditLogger, type AuditLoggerOptions, type BackoffStrategy, type BatchOptions, BatchProcessor, type BatchProcessorOptions, type BatchStats, type CacheKeyGenerator, type CachingOptions, type CheckInterruptOptions, type CheckpointHistoryOptions, type CheckpointerOptions, type ChunkOptions, CircuitBreaker, type CircuitBreakerOptions, type CircuitBreakerStats, type CircuitState, type ComposeGraphsOptions, type ComposeOptions, type ComposeToolConfig, type ComposedTool, type ConcurrencyOptions, type ConditionalConfig, type ConditionalRouter, type ConditionalRouterConfig, ConnectionPool, type ConnectionPoolOptions, type ConversationConfig, type CustomAlertChannel, type CustomInterrupt, type DatabaseConfig, type DatabaseConnection, DatabasePool, type DatabasePoolOptions, type DatabaseQueryParams, type DatabaseQueryResult, type DevelopmentPresetOptions, type EmailAlertChannel, type ErrorContext, type ErrorHandlerOptions, type ErrorReporter, type ErrorReporterOptions, type EventHandler, type EvictionStrategy, type ExecutionMetrics, type GenericAlertChannel, type HealthCheck, type HealthCheckConfig, type HealthCheckResult, HealthChecker, type HealthCheckerOptions, type HealthReport, type HealthStatus, type HttpClient, type HttpConfig, HttpPool, type HttpPoolConfig, type HttpPoolOptions, type HttpResponse, type HumanInLoopEventData, type HumanInLoopEventType, type HumanRequest, type HumanRequestEventData, type HumanRequestInterrupt, type HumanRequestPriority, type HumanRequestStatus, type HumanResponseEventData, type InterruptData, type InterruptEventData, type InterruptType, type JsonObject, type JsonPrimitive, type JsonValue, type LangSmithConfig, type LogEntry, LogLevel, type Logger, type LoggerOptions, type LoggingOptions, ManagedTool, type ManagedToolConfig, type ManagedToolStats, MemoryManager, type MemoryManagerOptions, type MemoryStats, type MetricEntry, MetricType, type Metrics, type MetricsNodeOptions, type Middleware, MiddlewareChain, type MiddlewareContext, type MiddlewareFactory, type MiddlewareMetadata, type MiddlewareWithMetadata, MissingDescriptionError, type MockExecutionRuntimeOptions, type MockToolConfig, type MockToolResponse, type NodeFunction, type NodeFunctionWithContext, type ParallelNode, type ParallelWorkflowConfig, type ParallelWorkflowOptions, type PoolConfig, type PoolStats, type Priority$1 as Priority, type ProductionPresetOptions, type ProfileReport, type ProfileSample, type ProfileStats, Profiler, type ProfilerOptions, type Progress, type ProgressTracker, type ProgressTrackerOptions, type PromptOptions, type PromptVariableMap, type PromptVariableValue, type RateLimitOptions, type RateLimitStrategy, type ReducerFunction, RegistryEvent, type RenderTemplateOptions, type RequestConfig, type ResumeCommand, type ResumeEventData, type ResumeOptions, type RetryOptions, type RetryPolicy, type RouteCondition, type RouteMap, type RouteName, type SSEEvent, type SSEFormatter, type SSEFormatterOptions, type SequentialNode, type SequentialWorkflowOptions, type SimpleMiddleware, type SlackAlertChannel, type SqliteCheckpointerOptions, type StateChannelConfig, type SubgraphBuilder, type TestingPresetOptions, type ThreadConfig, type ThreadInfo, type ThreadStatus, type ThrottleOptions, TimeoutError, type TimeoutOptions, type Timer, type Tool, type BackoffStrategy$1 as ToolBackoffStrategy, ToolBuilder, ToolCategory, ToolCategorySchema, type ToolExample, ToolExampleSchema, type ToolExecution, type ToolExecutorConfig, type ToolHealthCheckResult, type ToolInvocation, type ToolMetadata, ToolMetadataSchema, ToolNameSchema, ToolRegistry, type ToolRelations, ToolRelationsSchema, type ToolSimulatorConfig, type TracingOptions, type ValidationErrorHandler, type ValidationMode, type ValidationOptions, type ValidatorFunction, type WebSocketBinaryData, type WebSocketCloseReason, type WebSocketCloseReasonFor, type WebSocketConnection, type WebSocketEvent, type WebSocketEventHandler, type WebSocketHandlerOptions, type WebSocketMessage, type WebSocketMessageFor, type WebSocketRawMessage, type WebSocketSendTarget, type WebhookAlertChannel, batch, broadcast, cache, chain, chunk, clearThread, collect, compose, composeGraphs, composeTool, composeWithOptions, conditional, configureLangSmith, createAlertManager, createApprovalRequiredInterrupt, createAuditLogger, createBatchProcessor, createBinaryRouter, createCircuitBreaker, createConditionalRouter, createConnectionPool, createConversationConfig, createCustomInterrupt, createDatabasePool, createErrorReporter, createHealthChecker, createHeartbeat, createHttpPool, createHumanRequestInterrupt, createLogger, createManagedTool, createMemoryCheckpointer, createMemoryManager, createMessage, createMetrics, createMiddlewareContext, createMockTool, createMultiRouter, createParallelWorkflow, createProfiler, createProgressTracker, createSSEFormatter, createSequentialWorkflow, createSharedCache, createSharedConcurrencyController, createSharedRateLimiter, createSqliteCheckpointer, createStateAnnotation, createSubgraph, createThreadConfig, createTool, createToolExecutor, createToolSimulator, createToolUnsafe, createWebSocketHandler, development, filter, formatAgentResumedEvent, formatAgentWaitingEvent, formatHumanRequestEvent, formatHumanResponseEvent, formatInterruptEvent, formatResumeEvent, generateThreadId, getCheckpointHistory, getLangSmithConfig, getLatestCheckpoint, getMissingDescriptions, getThreadStatus, getToolDescription, getToolJsonSchema, isApprovalRequiredInterrupt, isCustomInterrupt, isHumanRequestInterrupt, isMemoryCheckpointer, isTracingEnabled, loadPrompt, map, merge, mergeState, parallel, parseSSEEvent, presets, production, reduce, renderTemplate, retry, runMockExecution, safeValidateSchemaDescriptions, sanitizeValue, sendMessage, sequential, sequentialBuilder, take, testing, throttle, timeout, toLangChainTool, toLangChainTools, toolBuilder, validateSchemaDescriptions, validateState, validateTool, validateToolMetadata, validateToolName, withCache, withConcurrency, withErrorHandler, withLogging, withMetrics, withRateLimit, withRetry, withTimeout, withTracing, withValidation };
package/dist/index.d.ts CHANGED
@@ -4505,115 +4505,36 @@ declare class AuditLogger {
4505
4505
  }
4506
4506
  declare function createAuditLogger(options?: AuditLoggerOptions): AuditLogger;
4507
4507
 
4508
- /**
4509
- * Prompt Template Loader
4510
- *
4511
- * Utility for loading and rendering prompt templates from .md files.
4512
- * Supports variable substitution and conditional blocks.
4513
- *
4514
- * SECURITY: This module includes protection against prompt injection attacks
4515
- * by sanitizing variable values before substitution.
4516
- */
4517
4508
  type PromptVariableValue = unknown;
4518
4509
  type PromptVariableMap = Record<string, PromptVariableValue>;
4519
- /**
4520
- * Options for rendering templates with security controls
4521
- */
4510
+ /** Options for rendering templates with trusted and untrusted variables. */
4522
4511
  interface RenderTemplateOptions {
4523
- /**
4524
- * Variables from trusted sources (config files, hardcoded values)
4525
- * These will NOT be sanitized
4526
- */
4512
+ /** Variables from trusted sources. These values are not sanitized. */
4527
4513
  trustedVariables?: PromptVariableMap;
4528
- /**
4529
- * Variables from untrusted sources (user input, API calls, databases)
4530
- * These WILL be sanitized to prevent prompt injection
4531
- */
4514
+ /** Variables from untrusted sources. These values are sanitized. */
4532
4515
  untrustedVariables?: PromptVariableMap;
4533
4516
  }
4517
+
4534
4518
  /**
4535
- * Sanitize a value to prevent prompt injection attacks
4536
- *
4537
- * Protections:
4538
- * - Removes markdown headers (prevents structure hijacking)
4539
- * - Removes newlines (prevents multi-line injection)
4540
- * - Limits length (prevents prompt bloat)
4541
- *
4542
- * @param value - The value to sanitize
4543
- * @returns Sanitized string safe for use in prompts
4519
+ * Load and render a Markdown prompt template from a custom directory or the
4520
+ * `prompts` directory beneath the current working directory.
4544
4521
  */
4545
- declare function sanitizeValue(value: unknown): string;
4522
+ declare function loadPrompt(promptName: string, options?: RenderTemplateOptions | PromptVariableMap, promptsDir?: string): string;
4523
+
4546
4524
  /**
4547
- * Render a template string with variable substitution
4548
- *
4549
- * Supports:
4550
- * - Simple variables: {{variableName}}
4551
- * - Conditional blocks: {{#if variableName}}...{{/if}}
4552
- *
4553
- * SECURITY: Distinguishes between trusted and untrusted variables.
4554
- * - Trusted variables (from config) are used as-is
4555
- * - Untrusted variables (from user input) are sanitized
4556
- * - Only own enumerable properties are considered from provided variable maps
4557
- * or backwards-compatible plain objects
4558
- *
4559
- * @param template - Template string with {{variable}} placeholders
4560
- * @param options - Variables and security options
4561
- * @returns Rendered template string
4562
- *
4563
- * @example
4564
- * ```typescript
4565
- * // Safe: Trusted variables from config
4566
- * const result = renderTemplate(template, {
4567
- * trustedVariables: {
4568
- * companyName: 'Acme Corp', // From config file
4569
- * premium: true
4570
- * }
4571
- * });
4572
- *
4573
- * // Safe: Untrusted variables are sanitized
4574
- * const result = renderTemplate(template, {
4575
- * untrustedVariables: {
4576
- * userName: req.body.name, // User input - will be sanitized
4577
- * }
4578
- * });
4579
- *
4580
- * // Mixed: Some trusted, some untrusted
4581
- * const result = renderTemplate(template, {
4582
- * trustedVariables: {
4583
- * companyName: 'Acme Corp', // From config
4584
- * },
4585
- * untrustedVariables: {
4586
- * userName: req.body.name, // User input
4587
- * }
4588
- * });
4589
- * ```
4525
+ * Render substitutions and conditional blocks with trusted/untrusted controls.
4526
+ * Trusted values are substituted unchanged, untrusted values are sanitized,
4527
+ * and conditional truthiness is evaluated against the original raw values.
4528
+ * Plain variable maps remain supported as trusted input for compatibility.
4590
4529
  */
4591
4530
  declare function renderTemplate(template: string, options: RenderTemplateOptions | PromptVariableMap): string;
4531
+
4592
4532
  /**
4593
- * Load and render a prompt template from a .md file
4533
+ * Sanitize an untrusted value before prompt substitution.
4594
4534
  *
4595
- * Looks for prompts in a `prompts/` directory relative to the caller's location.
4596
- *
4597
- * @param promptName - Name of the prompt file (without .md extension)
4598
- * @param options - Variables and security options
4599
- * @param promptsDir - Optional custom prompts directory path
4600
- * @returns Rendered prompt string
4601
- *
4602
- * @example
4603
- * ```typescript
4604
- * // Backwards compatible: all variables treated as trusted
4605
- * loadPrompt('system', { companyName: 'Acme' });
4606
- *
4607
- * // Explicit: separate trusted and untrusted
4608
- * loadPrompt('system', {
4609
- * trustedVariables: { companyName: 'Acme' },
4610
- * untrustedVariables: { userName: userInput }
4611
- * });
4612
- *
4613
- * // Custom prompts directory
4614
- * loadPrompt('system', { companyName: 'Acme' }, '/path/to/prompts');
4615
- * ```
4535
+ * Removes Markdown header markers and line breaks, collapses whitespace,
4536
+ * and limits output to 500 characters plus an ellipsis.
4616
4537
  */
4617
- declare function loadPrompt(promptName: string, options?: RenderTemplateOptions | PromptVariableMap, promptsDir?: string): string;
4538
+ declare function sanitizeValue(value: unknown): string;
4618
4539
 
4619
4540
  export { AgentError, type AgentResumedEventData, type AgentWaitingEventData, type AggregateNode, type Alert, type AlertChannel, AlertManager, type AlertManagerOptions, type AlertRule, type AlertSeverity, type AnyInterrupt, type ApprovalRequiredInterrupt, type AuditLogEntry, type AuditLogQuery, AuditLogger, type AuditLoggerOptions, type BackoffStrategy, type BatchOptions, BatchProcessor, type BatchProcessorOptions, type BatchStats, type CacheKeyGenerator, type CachingOptions, type CheckInterruptOptions, type CheckpointHistoryOptions, type CheckpointerOptions, type ChunkOptions, CircuitBreaker, type CircuitBreakerOptions, type CircuitBreakerStats, type CircuitState, type ComposeGraphsOptions, type ComposeOptions, type ComposeToolConfig, type ComposedTool, type ConcurrencyOptions, type ConditionalConfig, type ConditionalRouter, type ConditionalRouterConfig, ConnectionPool, type ConnectionPoolOptions, type ConversationConfig, type CustomAlertChannel, type CustomInterrupt, type DatabaseConfig, type DatabaseConnection, DatabasePool, type DatabasePoolOptions, type DatabaseQueryParams, type DatabaseQueryResult, type DevelopmentPresetOptions, type EmailAlertChannel, type ErrorContext, type ErrorHandlerOptions, type ErrorReporter, type ErrorReporterOptions, type EventHandler, type EvictionStrategy, type ExecutionMetrics, type GenericAlertChannel, type HealthCheck, type HealthCheckConfig, type HealthCheckResult, HealthChecker, type HealthCheckerOptions, type HealthReport, type HealthStatus, type HttpClient, type HttpConfig, HttpPool, type HttpPoolConfig, type HttpPoolOptions, type HttpResponse, type HumanInLoopEventData, type HumanInLoopEventType, type HumanRequest, type HumanRequestEventData, type HumanRequestInterrupt, type HumanRequestPriority, type HumanRequestStatus, type HumanResponseEventData, type InterruptData, type InterruptEventData, type InterruptType, type JsonObject, type JsonPrimitive, type JsonValue, type LangSmithConfig, type LogEntry, LogLevel, type Logger, type LoggerOptions, type LoggingOptions, ManagedTool, type ManagedToolConfig, type ManagedToolStats, MemoryManager, type MemoryManagerOptions, type MemoryStats, type MetricEntry, MetricType, type Metrics, type MetricsNodeOptions, type Middleware, MiddlewareChain, type MiddlewareContext, type MiddlewareFactory, type MiddlewareMetadata, type MiddlewareWithMetadata, MissingDescriptionError, type MockExecutionRuntimeOptions, type MockToolConfig, type MockToolResponse, type NodeFunction, type NodeFunctionWithContext, type ParallelNode, type ParallelWorkflowConfig, type ParallelWorkflowOptions, type PoolConfig, type PoolStats, type Priority$1 as Priority, type ProductionPresetOptions, type ProfileReport, type ProfileSample, type ProfileStats, Profiler, type ProfilerOptions, type Progress, type ProgressTracker, type ProgressTrackerOptions, type PromptOptions, type PromptVariableMap, type PromptVariableValue, type RateLimitOptions, type RateLimitStrategy, type ReducerFunction, RegistryEvent, type RenderTemplateOptions, type RequestConfig, type ResumeCommand, type ResumeEventData, type ResumeOptions, type RetryOptions, type RetryPolicy, type RouteCondition, type RouteMap, type RouteName, type SSEEvent, type SSEFormatter, type SSEFormatterOptions, type SequentialNode, type SequentialWorkflowOptions, type SimpleMiddleware, type SlackAlertChannel, type SqliteCheckpointerOptions, type StateChannelConfig, type SubgraphBuilder, type TestingPresetOptions, type ThreadConfig, type ThreadInfo, type ThreadStatus, type ThrottleOptions, TimeoutError, type TimeoutOptions, type Timer, type Tool, type BackoffStrategy$1 as ToolBackoffStrategy, ToolBuilder, ToolCategory, ToolCategorySchema, type ToolExample, ToolExampleSchema, type ToolExecution, type ToolExecutorConfig, type ToolHealthCheckResult, type ToolInvocation, type ToolMetadata, ToolMetadataSchema, ToolNameSchema, ToolRegistry, type ToolRelations, ToolRelationsSchema, type ToolSimulatorConfig, type TracingOptions, type ValidationErrorHandler, type ValidationMode, type ValidationOptions, type ValidatorFunction, type WebSocketBinaryData, type WebSocketCloseReason, type WebSocketCloseReasonFor, type WebSocketConnection, type WebSocketEvent, type WebSocketEventHandler, type WebSocketHandlerOptions, type WebSocketMessage, type WebSocketMessageFor, type WebSocketRawMessage, type WebSocketSendTarget, type WebhookAlertChannel, batch, broadcast, cache, chain, chunk, clearThread, collect, compose, composeGraphs, composeTool, composeWithOptions, conditional, configureLangSmith, createAlertManager, createApprovalRequiredInterrupt, createAuditLogger, createBatchProcessor, createBinaryRouter, createCircuitBreaker, createConditionalRouter, createConnectionPool, createConversationConfig, createCustomInterrupt, createDatabasePool, createErrorReporter, createHealthChecker, createHeartbeat, createHttpPool, createHumanRequestInterrupt, createLogger, createManagedTool, createMemoryCheckpointer, createMemoryManager, createMessage, createMetrics, createMiddlewareContext, createMockTool, createMultiRouter, createParallelWorkflow, createProfiler, createProgressTracker, createSSEFormatter, createSequentialWorkflow, createSharedCache, createSharedConcurrencyController, createSharedRateLimiter, createSqliteCheckpointer, createStateAnnotation, createSubgraph, createThreadConfig, createTool, createToolExecutor, createToolSimulator, createToolUnsafe, createWebSocketHandler, development, filter, formatAgentResumedEvent, formatAgentWaitingEvent, formatHumanRequestEvent, formatHumanResponseEvent, formatInterruptEvent, formatResumeEvent, generateThreadId, getCheckpointHistory, getLangSmithConfig, getLatestCheckpoint, getMissingDescriptions, getThreadStatus, getToolDescription, getToolJsonSchema, isApprovalRequiredInterrupt, isCustomInterrupt, isHumanRequestInterrupt, isMemoryCheckpointer, isTracingEnabled, loadPrompt, map, merge, mergeState, parallel, parseSSEEvent, presets, production, reduce, renderTemplate, retry, runMockExecution, safeValidateSchemaDescriptions, sanitizeValue, sendMessage, sequential, sequentialBuilder, take, testing, throttle, timeout, toLangChainTool, toLangChainTools, toolBuilder, validateSchemaDescriptions, validateState, validateTool, validateToolMetadata, validateToolName, withCache, withConcurrency, withErrorHandler, withLogging, withMetrics, withRateLimit, withRetry, withTimeout, withTracing, withValidation };
package/dist/index.js CHANGED
@@ -5478,9 +5478,11 @@ function createAuditLogger(options) {
5478
5478
  return new AuditLogger(options);
5479
5479
  }
5480
5480
 
5481
- // src/prompt-loader/index.ts
5481
+ // src/prompt-loader/file-loader.ts
5482
5482
  import { readFileSync } from "fs";
5483
5483
  import { join } from "path";
5484
+
5485
+ // src/prompt-loader/variables.ts
5484
5486
  var MAX_VARIABLE_LENGTH = 500;
5485
5487
  function createPromptVariableMap() {
5486
5488
  return /* @__PURE__ */ Object.create(null);
@@ -5492,9 +5494,7 @@ function isRenderTemplateOptions(value) {
5492
5494
  return isPromptVariableMap(value) && (Object.prototype.hasOwnProperty.call(value, "trustedVariables") || Object.prototype.hasOwnProperty.call(value, "untrustedVariables"));
5493
5495
  }
5494
5496
  function normalizeVariableMap(value) {
5495
- if (!isPromptVariableMap(value)) {
5496
- return createPromptVariableMap();
5497
- }
5497
+ if (!isPromptVariableMap(value)) return createPromptVariableMap();
5498
5498
  return Object.assign(createPromptVariableMap(), value);
5499
5499
  }
5500
5500
  function sanitizeVariableMap(variables) {
@@ -5505,11 +5505,7 @@ function sanitizeVariableMap(variables) {
5505
5505
  return sanitizedVariables;
5506
5506
  }
5507
5507
  function mergeVariableMaps(baseVariables, overrideVariables) {
5508
- return Object.assign(
5509
- createPromptVariableMap(),
5510
- baseVariables,
5511
- overrideVariables
5512
- );
5508
+ return Object.assign(createPromptVariableMap(), baseVariables, overrideVariables);
5513
5509
  }
5514
5510
  function sanitizeValue(value) {
5515
5511
  if (value === void 0 || value === null) return "";
@@ -5518,10 +5514,12 @@ function sanitizeValue(value) {
5518
5514
  sanitized = sanitized.replace(/[\r\n]+/g, " ");
5519
5515
  sanitized = sanitized.trim().replace(/\s+/g, " ");
5520
5516
  if (sanitized.length > MAX_VARIABLE_LENGTH) {
5521
- sanitized = sanitized.substring(0, MAX_VARIABLE_LENGTH) + "...";
5517
+ sanitized = `${sanitized.substring(0, MAX_VARIABLE_LENGTH)}...`;
5522
5518
  }
5523
5519
  return sanitized;
5524
5520
  }
5521
+
5522
+ // src/prompt-loader/renderer.ts
5525
5523
  function renderTemplate(template, options) {
5526
5524
  let rawVariables;
5527
5525
  let sanitizedVariables;
@@ -5537,17 +5535,18 @@ function renderTemplate(template, options) {
5537
5535
  rawVariables = normalizeVariableMap(options);
5538
5536
  sanitizedVariables = rawVariables;
5539
5537
  }
5540
- let result = template;
5541
- result = result.replace(/\{\{#if\s+(\w+)\}\}([\s\S]*?)\{\{\/if\}\}/g, (_, varName, content) => {
5542
- return rawVariables[varName] ? content : "";
5543
- });
5544
- result = result.replace(/\{\{(\w+)\}\}/g, (_, varName) => {
5545
- const value = sanitizedVariables[varName];
5546
- if (value === void 0 || value === null) return "";
5547
- return String(value);
5538
+ let result = template.replace(
5539
+ /\{\{#if\s+(\w+)\}\}([\s\S]*?)\{\{\/if\}\}/g,
5540
+ (_, variableName, content) => rawVariables[variableName] ? content : ""
5541
+ );
5542
+ result = result.replace(/\{\{(\w+)\}\}/g, (_, variableName) => {
5543
+ const value = sanitizedVariables[variableName];
5544
+ return value === void 0 || value === null ? "" : String(value);
5548
5545
  });
5549
5546
  return result;
5550
5547
  }
5548
+
5549
+ // src/prompt-loader/file-loader.ts
5551
5550
  function loadPrompt(promptName, options = {}, promptsDir) {
5552
5551
  const baseDir = promptsDir || join(process.cwd(), "prompts");
5553
5552
  const promptPath = join(baseDir, `${promptName}.md`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentforge/core",
3
- "version": "0.16.87",
3
+ "version": "0.16.88",
4
4
  "description": "Production-ready TypeScript agent framework built on LangGraph with orchestration, middleware, and typed abstractions.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",