praisonai 1.7.0 → 1.7.1
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/agent/simple.js +19 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +61 -1
- package/dist/parity/index.d.ts +1104 -0
- package/dist/parity/index.js +1366 -0
- package/package.json +1 -1
package/dist/agent/simple.js
CHANGED
|
@@ -116,6 +116,23 @@ class Agent {
|
|
|
116
116
|
this.addAutoGeneratedToolDefinition(randomName, tool);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
+
else if (tool && typeof tool === 'object' && typeof tool.execute === 'function' && tool.name) {
|
|
120
|
+
// If it's a FunctionTool instance (has execute method and name)
|
|
121
|
+
const funcName = tool.name;
|
|
122
|
+
// Register the execute function with args as object (not spread)
|
|
123
|
+
this.registerToolFunction(funcName, async (args) => {
|
|
124
|
+
return tool.execute(args);
|
|
125
|
+
});
|
|
126
|
+
// Add the tool definition from FunctionTool
|
|
127
|
+
processedTools.push(tool.toOpenAITool ? tool.toOpenAITool() : {
|
|
128
|
+
type: 'function',
|
|
129
|
+
function: {
|
|
130
|
+
name: tool.name,
|
|
131
|
+
description: tool.description || `Function ${tool.name}`,
|
|
132
|
+
parameters: tool.parameters || { type: 'object', properties: {} },
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
119
136
|
else {
|
|
120
137
|
// If it's already a tool definition, add it as is
|
|
121
138
|
processedTools.push(tool);
|
|
@@ -295,8 +312,8 @@ class Agent {
|
|
|
295
312
|
if (!this.toolFunctions[name]) {
|
|
296
313
|
throw new Error(`Function ${name} not registered`);
|
|
297
314
|
}
|
|
298
|
-
// Call the function
|
|
299
|
-
const result = await this.toolFunctions[name](
|
|
315
|
+
// Call the function - pass args as object (for FunctionTool) or spread (for legacy functions)
|
|
316
|
+
const result = await this.toolFunctions[name](args);
|
|
300
317
|
// Add result to messages
|
|
301
318
|
results.push({
|
|
302
319
|
role: 'tool',
|
package/dist/index.d.ts
CHANGED
|
@@ -115,3 +115,4 @@ export { type ConditionProtocol, type RoutingConditionProtocol, DictCondition, E
|
|
|
115
115
|
export { type BotConfig, type BotUser, type BotChannel, type BotMessage, type BotProtocol, type GatewayConfig, type GatewayEvent, type GatewayMessage, type GatewayProtocol, type GatewayClientProtocol, type GatewaySessionProtocol, type ProviderStatus, type FailoverConfig, type AuthProfile, type ResourceLimits, type SandboxResult, type SandboxProtocol, type ReflectionOutput, type AutoRagConfig, SandboxStatus, AutonomyLevel, RagRetrievalPolicy, FailoverManager, } from './gateway';
|
|
116
116
|
export { type TaskConfig as AgentTaskConfig, type TaskOutput, type Task as AgentTask, BaseTask, createTaskOutput, } from './task';
|
|
117
117
|
export { A2ATaskState, A2ARole, type A2ATextPart, type A2AFilePart, type A2ADataPart, type A2APart, type A2AMessage, type A2ATaskStatus, type A2ATask, type A2AArtifact, type A2AAgentSkill, type A2AAgentCapabilities, type A2AAgentCard, type A2ASendMessageRequest, A2A, AGUI, RetrievalPolicy as AutoRetrievalPolicy, type AutoRagAgentConfig, DEFAULT_AUTO_KEYWORDS, AutoRagAgent, type ToolDefinition, Tools, config, memory, obs, workflows, type GuardrailPolicy, resolveGuardrailPolicies, GUARDRAIL_POLICY_PRESETS, type AgentManager, } from './protocols';
|
|
118
|
+
export { type AudioConfig, type CodeConfig, type OCRConfig, type VisionConfig, type VideoConfig, type RealtimeConfig, CodeAgent, OCRAgent, VisionAgent, VideoAgent, RealtimeAgent, EmbeddingAgent, type MCPCall, type WebSearchCall, type FileSearchCall, type CodeExecutionStep, type DeepResearchResponse, type Provider, createContextAgent as create_context_agent, handoffFilters as handoff_filters, promptWithHandoffInstructions as prompt_with_handoff_instructions, Chunking, If, when, Knowledge, Parallel, Route, Session, ContextManager, MCP, type ManagerConfig, type OptimizerStrategy, type ContextPack, type GuardrailResult, type ContextConfig, enableTelemetry as enable_telemetry, disableTelemetry as disable_telemetry, getTelemetry as get_telemetry, enablePerformanceMode as enable_performance_mode, disablePerformanceMode as disable_performance_mode, cleanupTelemetryResources as cleanup_telemetry_resources, register_display_callback, sync_display_callbacks, async_display_callbacks, display_error, display_generating, display_instruction, display_interaction, display_self_reflection, display_tool_call, error_logs, get_plugin_manager, get_default_plugin_dirs, ensure_plugin_dir, get_plugin_template, load_plugin, parse_plugin_header, parse_plugin_header_from_file, discover_plugins, discover_and_load_plugins, evaluate_condition, get_dimensions, track_workflow, resolve_guardrail_policies, trace_context, } from './parity';
|
package/dist/index.js
CHANGED
|
@@ -65,7 +65,8 @@ exports.isUrl = exports.uint8ArrayToBase64 = exports.base64ToUint8Array = export
|
|
|
65
65
|
exports.configureTelemetry = exports.autoEnableDevTools = exports.createDevToolsMiddleware = exports.getDevToolsUrl = exports.getDevToolsState = exports.isDevToolsEnabled = exports.disableDevTools = exports.enableDevTools = exports.TRANSCRIPTION_MODELS = exports.SPEECH_MODELS = exports.transcribe = exports.generateSpeech = exports.createDangerousPatternChecker = exports.isDangerous = exports.DANGEROUS_PATTERNS = exports.ToolApprovalTimeoutError = exports.ToolApprovalDeniedError = exports.withApproval = exports.setApprovalManager = exports.getApprovalManager = exports.ApprovalManager = exports.pipeUIMessageStreamToResponse = exports.toUIMessageStreamResponse = exports.createApprovalResponse = exports.getToolsNeedingApproval = exports.hasPendingApprovals = exports.createSystemMessage = exports.createTextMessage = exports.safeValidateUIMessages = exports.validateUIMessages = exports.convertToUIMessages = exports.convertToModelMessages = exports.stopWhen = exports.stopWhenNoToolCalls = exports.stopAfterSteps = exports.AgentLoop = exports.createAgentLoop = exports.createPagesHandler = exports.createRouteHandler = exports.createNestHandler = exports.createFastifyHandler = exports.createHonoHandler = exports.createExpressHandler = exports.createHttpHandler = exports.mcpToolsToAITools = exports.closeAllMCPClients = exports.closeMCPClient = exports.getMCPClient = exports.createMCP = exports.isDataUrl = void 0;
|
|
66
66
|
exports.displayInstruction = exports.displayGenerating = exports.displayError = exports.clearDisplayCallbacks = exports.asyncDisplayCallbacks = exports.syncDisplayCallbacks = exports.registerDisplay = exports.isPluginEnabled = exports.listPlugins = exports.disablePlugins = exports.enablePlugins = exports.parsePluginHeaderFromFile = exports.parsePluginHeader = exports.getPluginTemplate = exports.discoverAndLoadPlugins = exports.loadPlugin = exports.discoverPlugins = exports.ensurePluginDir = exports.getDefaultPluginDirs = exports.getPluginManager = exports.PluginParseError = exports.PluginManager = exports.FunctionPlugin = exports.Plugin = exports.PluginType = exports.PluginHook = exports.createCLIApprovalPrompt = exports.createComputerUseAgent = exports.ComputerUseClient = exports.createComputerUse = exports.createPostgresTool = exports.NLPostgresClient = exports.createNLPostgres = exports.parseSlackMessage = exports.verifySlackSignature = exports.SlackBot = exports.createSlackBot = exports.createTelemetrySettings = exports.clearEvents = exports.getEvents = exports.recordEvent = exports.createTelemetryMiddleware = exports.withSpan = exports.createAISpan = exports.getTracer = exports.initOpenTelemetry = exports.isTelemetryEnabled = exports.disableAITelemetry = exports.enableAITelemetry = exports.getTelemetrySettings = void 0;
|
|
67
67
|
exports.AutoRagAgent = exports.DEFAULT_AUTO_KEYWORDS = exports.AutoRetrievalPolicy = exports.AGUI = exports.A2A = exports.A2ARole = exports.A2ATaskState = exports.createTaskOutput = exports.BaseTask = exports.FailoverManager = exports.RagRetrievalPolicy = exports.AutonomyLevel = exports.SandboxStatus = exports.notCondition = exports.orConditions = exports.andConditions = exports.createCondition = exports.evaluateCondition = exports.FunctionCondition = exports.ExpressionCondition = exports.DictCondition = exports.trackWorkflow = exports.traceContext = exports.createContextEvent = exports.ContextTraceEmitter = exports.ContextNoOpSink = exports.ContextListSink = exports.ContextTraceSink = exports.TraceSink = exports.MessageType = exports.EventType = exports.ContextEventType = exports.normalizeEmbedding = exports.euclideanDistance = exports.cosineSimilarity = exports.setEmbeddingConfig = exports.getDimensions = exports.aembeddings = exports.aembedding = exports.aembed = exports.embeddings = exports.embedding = exports.embed = exports.DisplayFlow = exports.clearErrorLogs = exports.logError = exports.errorLogs = exports.displayToolCall = exports.displaySelfReflection = exports.displayInteraction = void 0;
|
|
68
|
-
exports.GUARDRAIL_POLICY_PRESETS = exports.resolveGuardrailPolicies = exports.workflows = exports.obs = exports.memory = exports.config = exports.Tools = void 0;
|
|
68
|
+
exports.discover_and_load_plugins = exports.discover_plugins = exports.parse_plugin_header_from_file = exports.parse_plugin_header = exports.load_plugin = exports.get_plugin_template = exports.ensure_plugin_dir = exports.get_default_plugin_dirs = exports.get_plugin_manager = exports.error_logs = exports.display_tool_call = exports.display_self_reflection = exports.display_interaction = exports.display_instruction = exports.display_generating = exports.display_error = exports.async_display_callbacks = exports.sync_display_callbacks = exports.register_display_callback = exports.cleanup_telemetry_resources = exports.disable_performance_mode = exports.enable_performance_mode = exports.get_telemetry = exports.disable_telemetry = exports.enable_telemetry = exports.MCP = exports.ContextManager = exports.Session = exports.Route = exports.Parallel = exports.Knowledge = exports.when = exports.If = exports.Chunking = exports.prompt_with_handoff_instructions = exports.handoff_filters = exports.create_context_agent = exports.EmbeddingAgent = exports.RealtimeAgent = exports.VideoAgent = exports.VisionAgent = exports.OCRAgent = exports.CodeAgent = exports.GUARDRAIL_POLICY_PRESETS = exports.resolveGuardrailPolicies = exports.workflows = exports.obs = exports.memory = exports.config = exports.Tools = void 0;
|
|
69
|
+
exports.trace_context = exports.resolve_guardrail_policies = exports.track_workflow = exports.get_dimensions = exports.evaluate_condition = void 0;
|
|
69
70
|
// ============================================================================
|
|
70
71
|
// CORE API - The main classes users should use
|
|
71
72
|
// ============================================================================
|
|
@@ -958,3 +959,62 @@ Object.defineProperty(exports, "obs", { enumerable: true, get: function () { ret
|
|
|
958
959
|
Object.defineProperty(exports, "workflows", { enumerable: true, get: function () { return protocols_1.workflows; } });
|
|
959
960
|
Object.defineProperty(exports, "resolveGuardrailPolicies", { enumerable: true, get: function () { return protocols_1.resolveGuardrailPolicies; } });
|
|
960
961
|
Object.defineProperty(exports, "GUARDRAIL_POLICY_PRESETS", { enumerable: true, get: function () { return protocols_1.GUARDRAIL_POLICY_PRESETS; } });
|
|
962
|
+
// Export Parity Module (All remaining P0-P3 gaps for full Python SDK parity)
|
|
963
|
+
// Only export items that don't conflict with existing exports from other modules
|
|
964
|
+
var parity_1 = require("./parity");
|
|
965
|
+
// P0: Specialized Agents (new)
|
|
966
|
+
Object.defineProperty(exports, "CodeAgent", { enumerable: true, get: function () { return parity_1.CodeAgent; } });
|
|
967
|
+
Object.defineProperty(exports, "OCRAgent", { enumerable: true, get: function () { return parity_1.OCRAgent; } });
|
|
968
|
+
Object.defineProperty(exports, "VisionAgent", { enumerable: true, get: function () { return parity_1.VisionAgent; } });
|
|
969
|
+
Object.defineProperty(exports, "VideoAgent", { enumerable: true, get: function () { return parity_1.VideoAgent; } });
|
|
970
|
+
Object.defineProperty(exports, "RealtimeAgent", { enumerable: true, get: function () { return parity_1.RealtimeAgent; } });
|
|
971
|
+
Object.defineProperty(exports, "EmbeddingAgent", { enumerable: true, get: function () { return parity_1.EmbeddingAgent; } });
|
|
972
|
+
// P0: Handoff Functions (new)
|
|
973
|
+
Object.defineProperty(exports, "create_context_agent", { enumerable: true, get: function () { return parity_1.createContextAgent; } });
|
|
974
|
+
Object.defineProperty(exports, "handoff_filters", { enumerable: true, get: function () { return parity_1.handoffFilters; } });
|
|
975
|
+
Object.defineProperty(exports, "prompt_with_handoff_instructions", { enumerable: true, get: function () { return parity_1.promptWithHandoffInstructions; } });
|
|
976
|
+
// P1: Workflow Patterns (new)
|
|
977
|
+
Object.defineProperty(exports, "Chunking", { enumerable: true, get: function () { return parity_1.Chunking; } });
|
|
978
|
+
Object.defineProperty(exports, "If", { enumerable: true, get: function () { return parity_1.If; } });
|
|
979
|
+
Object.defineProperty(exports, "when", { enumerable: true, get: function () { return parity_1.when; } });
|
|
980
|
+
Object.defineProperty(exports, "Knowledge", { enumerable: true, get: function () { return parity_1.Knowledge; } });
|
|
981
|
+
Object.defineProperty(exports, "Parallel", { enumerable: true, get: function () { return parity_1.Parallel; } });
|
|
982
|
+
Object.defineProperty(exports, "Route", { enumerable: true, get: function () { return parity_1.Route; } });
|
|
983
|
+
Object.defineProperty(exports, "Session", { enumerable: true, get: function () { return parity_1.Session; } });
|
|
984
|
+
// P2: Context Types (new - only items not already exported)
|
|
985
|
+
Object.defineProperty(exports, "ContextManager", { enumerable: true, get: function () { return parity_1.ContextManager; } });
|
|
986
|
+
Object.defineProperty(exports, "MCP", { enumerable: true, get: function () { return parity_1.MCP; } });
|
|
987
|
+
// P2: Telemetry Functions (new)
|
|
988
|
+
Object.defineProperty(exports, "enable_telemetry", { enumerable: true, get: function () { return parity_1.enableTelemetry; } });
|
|
989
|
+
Object.defineProperty(exports, "disable_telemetry", { enumerable: true, get: function () { return parity_1.disableTelemetry; } });
|
|
990
|
+
Object.defineProperty(exports, "get_telemetry", { enumerable: true, get: function () { return parity_1.getTelemetry; } });
|
|
991
|
+
Object.defineProperty(exports, "enable_performance_mode", { enumerable: true, get: function () { return parity_1.enablePerformanceMode; } });
|
|
992
|
+
Object.defineProperty(exports, "disable_performance_mode", { enumerable: true, get: function () { return parity_1.disablePerformanceMode; } });
|
|
993
|
+
Object.defineProperty(exports, "cleanup_telemetry_resources", { enumerable: true, get: function () { return parity_1.cleanupTelemetryResources; } });
|
|
994
|
+
// P3: Display callbacks (snake_case for Python parity)
|
|
995
|
+
Object.defineProperty(exports, "register_display_callback", { enumerable: true, get: function () { return parity_1.register_display_callback; } });
|
|
996
|
+
Object.defineProperty(exports, "sync_display_callbacks", { enumerable: true, get: function () { return parity_1.sync_display_callbacks; } });
|
|
997
|
+
Object.defineProperty(exports, "async_display_callbacks", { enumerable: true, get: function () { return parity_1.async_display_callbacks; } });
|
|
998
|
+
Object.defineProperty(exports, "display_error", { enumerable: true, get: function () { return parity_1.display_error; } });
|
|
999
|
+
Object.defineProperty(exports, "display_generating", { enumerable: true, get: function () { return parity_1.display_generating; } });
|
|
1000
|
+
Object.defineProperty(exports, "display_instruction", { enumerable: true, get: function () { return parity_1.display_instruction; } });
|
|
1001
|
+
Object.defineProperty(exports, "display_interaction", { enumerable: true, get: function () { return parity_1.display_interaction; } });
|
|
1002
|
+
Object.defineProperty(exports, "display_self_reflection", { enumerable: true, get: function () { return parity_1.display_self_reflection; } });
|
|
1003
|
+
Object.defineProperty(exports, "display_tool_call", { enumerable: true, get: function () { return parity_1.display_tool_call; } });
|
|
1004
|
+
Object.defineProperty(exports, "error_logs", { enumerable: true, get: function () { return parity_1.error_logs; } });
|
|
1005
|
+
// P3: Plugin functions
|
|
1006
|
+
Object.defineProperty(exports, "get_plugin_manager", { enumerable: true, get: function () { return parity_1.get_plugin_manager; } });
|
|
1007
|
+
Object.defineProperty(exports, "get_default_plugin_dirs", { enumerable: true, get: function () { return parity_1.get_default_plugin_dirs; } });
|
|
1008
|
+
Object.defineProperty(exports, "ensure_plugin_dir", { enumerable: true, get: function () { return parity_1.ensure_plugin_dir; } });
|
|
1009
|
+
Object.defineProperty(exports, "get_plugin_template", { enumerable: true, get: function () { return parity_1.get_plugin_template; } });
|
|
1010
|
+
Object.defineProperty(exports, "load_plugin", { enumerable: true, get: function () { return parity_1.load_plugin; } });
|
|
1011
|
+
Object.defineProperty(exports, "parse_plugin_header", { enumerable: true, get: function () { return parity_1.parse_plugin_header; } });
|
|
1012
|
+
Object.defineProperty(exports, "parse_plugin_header_from_file", { enumerable: true, get: function () { return parity_1.parse_plugin_header_from_file; } });
|
|
1013
|
+
Object.defineProperty(exports, "discover_plugins", { enumerable: true, get: function () { return parity_1.discover_plugins; } });
|
|
1014
|
+
Object.defineProperty(exports, "discover_and_load_plugins", { enumerable: true, get: function () { return parity_1.discover_and_load_plugins; } });
|
|
1015
|
+
// P3: Trace & condition functions
|
|
1016
|
+
Object.defineProperty(exports, "evaluate_condition", { enumerable: true, get: function () { return parity_1.evaluate_condition; } });
|
|
1017
|
+
Object.defineProperty(exports, "get_dimensions", { enumerable: true, get: function () { return parity_1.get_dimensions; } });
|
|
1018
|
+
Object.defineProperty(exports, "track_workflow", { enumerable: true, get: function () { return parity_1.track_workflow; } });
|
|
1019
|
+
Object.defineProperty(exports, "resolve_guardrail_policies", { enumerable: true, get: function () { return parity_1.resolve_guardrail_policies; } });
|
|
1020
|
+
Object.defineProperty(exports, "trace_context", { enumerable: true, get: function () { return parity_1.trace_context; } });
|