@agentforge/core 0.16.6 → 0.16.7
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 +39 -18
- package/dist/index.d.cts +10 -6
- package/dist/index.d.ts +10 -6
- package/dist/index.js +39 -18
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5585,6 +5585,35 @@ function createAuditLogger(options) {
|
|
|
5585
5585
|
var import_fs = require("fs");
|
|
5586
5586
|
var import_path = require("path");
|
|
5587
5587
|
var MAX_VARIABLE_LENGTH = 500;
|
|
5588
|
+
function createPromptVariableMap() {
|
|
5589
|
+
return /* @__PURE__ */ Object.create(null);
|
|
5590
|
+
}
|
|
5591
|
+
function isPromptVariableMap(value) {
|
|
5592
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5593
|
+
}
|
|
5594
|
+
function isRenderTemplateOptions(value) {
|
|
5595
|
+
return isPromptVariableMap(value) && (Object.prototype.hasOwnProperty.call(value, "trustedVariables") || Object.prototype.hasOwnProperty.call(value, "untrustedVariables"));
|
|
5596
|
+
}
|
|
5597
|
+
function normalizeVariableMap(value) {
|
|
5598
|
+
if (!isPromptVariableMap(value)) {
|
|
5599
|
+
return createPromptVariableMap();
|
|
5600
|
+
}
|
|
5601
|
+
return Object.assign(createPromptVariableMap(), value);
|
|
5602
|
+
}
|
|
5603
|
+
function sanitizeVariableMap(variables) {
|
|
5604
|
+
const sanitizedVariables = createPromptVariableMap();
|
|
5605
|
+
for (const [key, value] of Object.entries(variables)) {
|
|
5606
|
+
sanitizedVariables[key] = sanitizeValue(value);
|
|
5607
|
+
}
|
|
5608
|
+
return sanitizedVariables;
|
|
5609
|
+
}
|
|
5610
|
+
function mergeVariableMaps(baseVariables, overrideVariables) {
|
|
5611
|
+
return Object.assign(
|
|
5612
|
+
createPromptVariableMap(),
|
|
5613
|
+
baseVariables,
|
|
5614
|
+
overrideVariables
|
|
5615
|
+
);
|
|
5616
|
+
}
|
|
5588
5617
|
function sanitizeValue(value) {
|
|
5589
5618
|
if (value === void 0 || value === null) return "";
|
|
5590
5619
|
let sanitized = String(value);
|
|
@@ -5599,25 +5628,17 @@ function sanitizeValue(value) {
|
|
|
5599
5628
|
function renderTemplate(template, options) {
|
|
5600
5629
|
let rawVariables;
|
|
5601
5630
|
let sanitizedVariables;
|
|
5602
|
-
if (
|
|
5603
|
-
const
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
for (const [key, value] of Object.entries(opts.untrustedVariables)) {
|
|
5611
|
-
sanitizedUntrusted[key] = sanitizeValue(value);
|
|
5612
|
-
}
|
|
5613
|
-
}
|
|
5614
|
-
sanitizedVariables = {
|
|
5615
|
-
...opts.trustedVariables,
|
|
5616
|
-
...sanitizedUntrusted
|
|
5617
|
-
};
|
|
5631
|
+
if (isRenderTemplateOptions(options)) {
|
|
5632
|
+
const trustedVariables = normalizeVariableMap(options.trustedVariables);
|
|
5633
|
+
const untrustedVariables = normalizeVariableMap(options.untrustedVariables);
|
|
5634
|
+
rawVariables = mergeVariableMaps(trustedVariables, untrustedVariables);
|
|
5635
|
+
sanitizedVariables = mergeVariableMaps(
|
|
5636
|
+
trustedVariables,
|
|
5637
|
+
sanitizeVariableMap(untrustedVariables)
|
|
5638
|
+
);
|
|
5618
5639
|
} else {
|
|
5619
|
-
rawVariables = options;
|
|
5620
|
-
sanitizedVariables =
|
|
5640
|
+
rawVariables = normalizeVariableMap(options);
|
|
5641
|
+
sanitizedVariables = rawVariables;
|
|
5621
5642
|
}
|
|
5622
5643
|
let result = template;
|
|
5623
5644
|
result = result.replace(/\{\{#if\s+(\w+)\}\}([\s\S]*?)\{\{\/if\}\}/g, (_, varName, content) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -5495,6 +5495,8 @@ declare function createAuditLogger(options?: AuditLoggerOptions): AuditLogger;
|
|
|
5495
5495
|
* SECURITY: This module includes protection against prompt injection attacks
|
|
5496
5496
|
* by sanitizing variable values before substitution.
|
|
5497
5497
|
*/
|
|
5498
|
+
type PromptVariableValue = unknown;
|
|
5499
|
+
type PromptVariableMap = Record<string, PromptVariableValue>;
|
|
5498
5500
|
/**
|
|
5499
5501
|
* Options for rendering templates with security controls
|
|
5500
5502
|
*/
|
|
@@ -5503,12 +5505,12 @@ interface RenderTemplateOptions {
|
|
|
5503
5505
|
* Variables from trusted sources (config files, hardcoded values)
|
|
5504
5506
|
* These will NOT be sanitized
|
|
5505
5507
|
*/
|
|
5506
|
-
trustedVariables?:
|
|
5508
|
+
trustedVariables?: PromptVariableMap;
|
|
5507
5509
|
/**
|
|
5508
5510
|
* Variables from untrusted sources (user input, API calls, databases)
|
|
5509
5511
|
* These WILL be sanitized to prevent prompt injection
|
|
5510
5512
|
*/
|
|
5511
|
-
untrustedVariables?:
|
|
5513
|
+
untrustedVariables?: PromptVariableMap;
|
|
5512
5514
|
}
|
|
5513
5515
|
/**
|
|
5514
5516
|
* Sanitize a value to prevent prompt injection attacks
|
|
@@ -5521,7 +5523,7 @@ interface RenderTemplateOptions {
|
|
|
5521
5523
|
* @param value - The value to sanitize
|
|
5522
5524
|
* @returns Sanitized string safe for use in prompts
|
|
5523
5525
|
*/
|
|
5524
|
-
declare function sanitizeValue(value:
|
|
5526
|
+
declare function sanitizeValue(value: unknown): string;
|
|
5525
5527
|
/**
|
|
5526
5528
|
* Render a template string with variable substitution
|
|
5527
5529
|
*
|
|
@@ -5532,6 +5534,8 @@ declare function sanitizeValue(value: any): string;
|
|
|
5532
5534
|
* SECURITY: Distinguishes between trusted and untrusted variables.
|
|
5533
5535
|
* - Trusted variables (from config) are used as-is
|
|
5534
5536
|
* - Untrusted variables (from user input) are sanitized
|
|
5537
|
+
* - Only own enumerable properties are considered from provided variable maps
|
|
5538
|
+
* or backwards-compatible plain objects
|
|
5535
5539
|
*
|
|
5536
5540
|
* @param template - Template string with {{variable}} placeholders
|
|
5537
5541
|
* @param options - Variables and security options
|
|
@@ -5565,7 +5569,7 @@ declare function sanitizeValue(value: any): string;
|
|
|
5565
5569
|
* });
|
|
5566
5570
|
* ```
|
|
5567
5571
|
*/
|
|
5568
|
-
declare function renderTemplate(template: string, options: RenderTemplateOptions |
|
|
5572
|
+
declare function renderTemplate(template: string, options: RenderTemplateOptions | PromptVariableMap): string;
|
|
5569
5573
|
/**
|
|
5570
5574
|
* Load and render a prompt template from a .md file
|
|
5571
5575
|
*
|
|
@@ -5591,6 +5595,6 @@ declare function renderTemplate(template: string, options: RenderTemplateOptions
|
|
|
5591
5595
|
* loadPrompt('system', { companyName: 'Acme' }, '/path/to/prompts');
|
|
5592
5596
|
* ```
|
|
5593
5597
|
*/
|
|
5594
|
-
declare function loadPrompt(promptName: string, options?: RenderTemplateOptions |
|
|
5598
|
+
declare function loadPrompt(promptName: string, options?: RenderTemplateOptions | PromptVariableMap, promptsDir?: string): string;
|
|
5595
5599
|
|
|
5596
|
-
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 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 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 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 WebSocketHandlerOptions, type WebSocketMessage, 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, 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 };
|
|
5600
|
+
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 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 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 WebSocketHandlerOptions, type WebSocketMessage, 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, 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
|
@@ -5495,6 +5495,8 @@ declare function createAuditLogger(options?: AuditLoggerOptions): AuditLogger;
|
|
|
5495
5495
|
* SECURITY: This module includes protection against prompt injection attacks
|
|
5496
5496
|
* by sanitizing variable values before substitution.
|
|
5497
5497
|
*/
|
|
5498
|
+
type PromptVariableValue = unknown;
|
|
5499
|
+
type PromptVariableMap = Record<string, PromptVariableValue>;
|
|
5498
5500
|
/**
|
|
5499
5501
|
* Options for rendering templates with security controls
|
|
5500
5502
|
*/
|
|
@@ -5503,12 +5505,12 @@ interface RenderTemplateOptions {
|
|
|
5503
5505
|
* Variables from trusted sources (config files, hardcoded values)
|
|
5504
5506
|
* These will NOT be sanitized
|
|
5505
5507
|
*/
|
|
5506
|
-
trustedVariables?:
|
|
5508
|
+
trustedVariables?: PromptVariableMap;
|
|
5507
5509
|
/**
|
|
5508
5510
|
* Variables from untrusted sources (user input, API calls, databases)
|
|
5509
5511
|
* These WILL be sanitized to prevent prompt injection
|
|
5510
5512
|
*/
|
|
5511
|
-
untrustedVariables?:
|
|
5513
|
+
untrustedVariables?: PromptVariableMap;
|
|
5512
5514
|
}
|
|
5513
5515
|
/**
|
|
5514
5516
|
* Sanitize a value to prevent prompt injection attacks
|
|
@@ -5521,7 +5523,7 @@ interface RenderTemplateOptions {
|
|
|
5521
5523
|
* @param value - The value to sanitize
|
|
5522
5524
|
* @returns Sanitized string safe for use in prompts
|
|
5523
5525
|
*/
|
|
5524
|
-
declare function sanitizeValue(value:
|
|
5526
|
+
declare function sanitizeValue(value: unknown): string;
|
|
5525
5527
|
/**
|
|
5526
5528
|
* Render a template string with variable substitution
|
|
5527
5529
|
*
|
|
@@ -5532,6 +5534,8 @@ declare function sanitizeValue(value: any): string;
|
|
|
5532
5534
|
* SECURITY: Distinguishes between trusted and untrusted variables.
|
|
5533
5535
|
* - Trusted variables (from config) are used as-is
|
|
5534
5536
|
* - Untrusted variables (from user input) are sanitized
|
|
5537
|
+
* - Only own enumerable properties are considered from provided variable maps
|
|
5538
|
+
* or backwards-compatible plain objects
|
|
5535
5539
|
*
|
|
5536
5540
|
* @param template - Template string with {{variable}} placeholders
|
|
5537
5541
|
* @param options - Variables and security options
|
|
@@ -5565,7 +5569,7 @@ declare function sanitizeValue(value: any): string;
|
|
|
5565
5569
|
* });
|
|
5566
5570
|
* ```
|
|
5567
5571
|
*/
|
|
5568
|
-
declare function renderTemplate(template: string, options: RenderTemplateOptions |
|
|
5572
|
+
declare function renderTemplate(template: string, options: RenderTemplateOptions | PromptVariableMap): string;
|
|
5569
5573
|
/**
|
|
5570
5574
|
* Load and render a prompt template from a .md file
|
|
5571
5575
|
*
|
|
@@ -5591,6 +5595,6 @@ declare function renderTemplate(template: string, options: RenderTemplateOptions
|
|
|
5591
5595
|
* loadPrompt('system', { companyName: 'Acme' }, '/path/to/prompts');
|
|
5592
5596
|
* ```
|
|
5593
5597
|
*/
|
|
5594
|
-
declare function loadPrompt(promptName: string, options?: RenderTemplateOptions |
|
|
5598
|
+
declare function loadPrompt(promptName: string, options?: RenderTemplateOptions | PromptVariableMap, promptsDir?: string): string;
|
|
5595
5599
|
|
|
5596
|
-
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 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 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 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 WebSocketHandlerOptions, type WebSocketMessage, 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, 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 };
|
|
5600
|
+
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 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 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 WebSocketHandlerOptions, type WebSocketMessage, 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, 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
|
@@ -5410,6 +5410,35 @@ function createAuditLogger(options) {
|
|
|
5410
5410
|
import { readFileSync } from "fs";
|
|
5411
5411
|
import { join } from "path";
|
|
5412
5412
|
var MAX_VARIABLE_LENGTH = 500;
|
|
5413
|
+
function createPromptVariableMap() {
|
|
5414
|
+
return /* @__PURE__ */ Object.create(null);
|
|
5415
|
+
}
|
|
5416
|
+
function isPromptVariableMap(value) {
|
|
5417
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5418
|
+
}
|
|
5419
|
+
function isRenderTemplateOptions(value) {
|
|
5420
|
+
return isPromptVariableMap(value) && (Object.prototype.hasOwnProperty.call(value, "trustedVariables") || Object.prototype.hasOwnProperty.call(value, "untrustedVariables"));
|
|
5421
|
+
}
|
|
5422
|
+
function normalizeVariableMap(value) {
|
|
5423
|
+
if (!isPromptVariableMap(value)) {
|
|
5424
|
+
return createPromptVariableMap();
|
|
5425
|
+
}
|
|
5426
|
+
return Object.assign(createPromptVariableMap(), value);
|
|
5427
|
+
}
|
|
5428
|
+
function sanitizeVariableMap(variables) {
|
|
5429
|
+
const sanitizedVariables = createPromptVariableMap();
|
|
5430
|
+
for (const [key, value] of Object.entries(variables)) {
|
|
5431
|
+
sanitizedVariables[key] = sanitizeValue(value);
|
|
5432
|
+
}
|
|
5433
|
+
return sanitizedVariables;
|
|
5434
|
+
}
|
|
5435
|
+
function mergeVariableMaps(baseVariables, overrideVariables) {
|
|
5436
|
+
return Object.assign(
|
|
5437
|
+
createPromptVariableMap(),
|
|
5438
|
+
baseVariables,
|
|
5439
|
+
overrideVariables
|
|
5440
|
+
);
|
|
5441
|
+
}
|
|
5413
5442
|
function sanitizeValue(value) {
|
|
5414
5443
|
if (value === void 0 || value === null) return "";
|
|
5415
5444
|
let sanitized = String(value);
|
|
@@ -5424,25 +5453,17 @@ function sanitizeValue(value) {
|
|
|
5424
5453
|
function renderTemplate(template, options) {
|
|
5425
5454
|
let rawVariables;
|
|
5426
5455
|
let sanitizedVariables;
|
|
5427
|
-
if (
|
|
5428
|
-
const
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
for (const [key, value] of Object.entries(opts.untrustedVariables)) {
|
|
5436
|
-
sanitizedUntrusted[key] = sanitizeValue(value);
|
|
5437
|
-
}
|
|
5438
|
-
}
|
|
5439
|
-
sanitizedVariables = {
|
|
5440
|
-
...opts.trustedVariables,
|
|
5441
|
-
...sanitizedUntrusted
|
|
5442
|
-
};
|
|
5456
|
+
if (isRenderTemplateOptions(options)) {
|
|
5457
|
+
const trustedVariables = normalizeVariableMap(options.trustedVariables);
|
|
5458
|
+
const untrustedVariables = normalizeVariableMap(options.untrustedVariables);
|
|
5459
|
+
rawVariables = mergeVariableMaps(trustedVariables, untrustedVariables);
|
|
5460
|
+
sanitizedVariables = mergeVariableMaps(
|
|
5461
|
+
trustedVariables,
|
|
5462
|
+
sanitizeVariableMap(untrustedVariables)
|
|
5463
|
+
);
|
|
5443
5464
|
} else {
|
|
5444
|
-
rawVariables = options;
|
|
5445
|
-
sanitizedVariables =
|
|
5465
|
+
rawVariables = normalizeVariableMap(options);
|
|
5466
|
+
sanitizedVariables = rawVariables;
|
|
5446
5467
|
}
|
|
5447
5468
|
let result = template;
|
|
5448
5469
|
result = result.replace(/\{\{#if\s+(\w+)\}\}([\s\S]*?)\{\{\/if\}\}/g, (_, varName, content) => {
|
package/package.json
CHANGED