@defai.digital/ax-cli 3.6.1 → 3.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/README.md +129 -16
- package/config-defaults/settings.yaml +24 -0
- package/dist/agent/llm-agent.d.ts +48 -3
- package/dist/agent/llm-agent.js +145 -40
- package/dist/agent/llm-agent.js.map +1 -1
- package/dist/agent/subagent.d.ts +6 -0
- package/dist/agent/subagent.js +41 -24
- package/dist/agent/subagent.js.map +1 -1
- package/dist/constants.d.ts +13 -0
- package/dist/constants.js +28 -0
- package/dist/constants.js.map +1 -1
- package/dist/index.js +0 -0
- package/dist/mcp/client.js +2 -2
- package/dist/mcp/client.js.map +1 -1
- package/dist/schemas/settings-schemas.d.ts +17 -0
- package/dist/schemas/settings-schemas.js +15 -0
- package/dist/schemas/settings-schemas.js.map +1 -1
- package/dist/sdk/errors.d.ts +93 -0
- package/dist/sdk/errors.js +124 -0
- package/dist/sdk/errors.js.map +1 -0
- package/dist/sdk/index.d.ts +116 -46
- package/dist/sdk/index.js +178 -57
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/progress-reporter.d.ts +111 -0
- package/dist/sdk/progress-reporter.js +178 -0
- package/dist/sdk/progress-reporter.js.map +1 -0
- package/dist/sdk/testing.d.ts +184 -0
- package/dist/sdk/testing.js +291 -0
- package/dist/sdk/testing.js.map +1 -0
- package/dist/sdk/tool-registry.d.ts +163 -0
- package/dist/sdk/tool-registry.js +218 -0
- package/dist/sdk/tool-registry.js.map +1 -0
- package/dist/sdk/unified-logger.d.ts +163 -0
- package/dist/sdk/unified-logger.js +274 -0
- package/dist/sdk/unified-logger.js.map +1 -0
- package/dist/sdk/version.d.ts +59 -0
- package/dist/sdk/version.js +64 -0
- package/dist/sdk/version.js.map +1 -0
- package/dist/tools/bash.d.ts +4 -0
- package/dist/tools/bash.js +22 -2
- package/dist/tools/bash.js.map +1 -1
- package/dist/ui/components/chat-history.d.ts +2 -0
- package/dist/ui/components/chat-history.js +32 -81
- package/dist/ui/components/chat-history.js.map +1 -1
- package/dist/ui/components/chat-interface.js +3 -3
- package/dist/ui/components/chat-interface.js.map +1 -1
- package/dist/ui/components/status-bar.d.ts +2 -0
- package/dist/ui/components/status-bar.js +33 -9
- package/dist/ui/components/status-bar.js.map +1 -1
- package/dist/ui/components/tool-group-display.d.ts +15 -0
- package/dist/ui/components/tool-group-display.js +91 -0
- package/dist/ui/components/tool-group-display.js.map +1 -0
- package/dist/ui/hooks/use-enhanced-input.js +43 -6
- package/dist/ui/hooks/use-enhanced-input.js.map +1 -1
- package/dist/ui/hooks/use-input-handler.d.ts +2 -0
- package/dist/ui/hooks/use-input-handler.js +13 -7
- package/dist/ui/hooks/use-input-handler.js.map +1 -1
- package/dist/ui/utils/change-summarizer.d.ts +20 -0
- package/dist/ui/utils/change-summarizer.js +193 -0
- package/dist/ui/utils/change-summarizer.js.map +1 -0
- package/dist/ui/utils/tool-grouper.d.ts +62 -0
- package/dist/ui/utils/tool-grouper.js +224 -0
- package/dist/ui/utils/tool-grouper.js.map +1 -0
- package/dist/utils/config-loader.d.ts +4 -0
- package/dist/utils/config-loader.js.map +1 -1
- package/dist/utils/paste-utils.js +45 -19
- package/dist/utils/paste-utils.js.map +1 -1
- package/dist/utils/token-counter.d.ts +12 -0
- package/dist/utils/token-counter.js +32 -4
- package/dist/utils/token-counter.js.map +1 -1
- package/package.json +2 -2
- package/packages/schemas/package.json +1 -1
- package/.ax-cli/CUSTOM.md +0 -269
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-11e9e0ba-c39d-4fd2-aa77-bc818811c921.json +0 -69
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-2b260b98-b418-4c7c-9694-e2b94967e662.json +0 -24
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-2dd84869-e62d-46c8-9885-7e45f37f36e2.json +0 -69
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-484dc350-353f-4808-9ed1-ebb3cefdab37.json +0 -24
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-74a18b87-6172-4215-962b-44bb9f46a662.json +0 -69
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-7e03601e-e8ab-4cd7-9841-a74b66adf78f.json +0 -69
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-7f9c6562-771f-4fd0-adcf-9e7e9ac34ae8.json +0 -44
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-870a5fb9-6e82-4ff2-8ec8-af4c251cc514.json +0 -44
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-93946601-0e83-456c-ba47-def9713124dd.json +0 -24
- package/.ax-cli/checkpoints/2025-11-20/checkpoint-e1ebe666-4c3a-4367-ba5c-27fe512a9c70.json +0 -24
- package/.ax-cli/checkpoints/2025-11-21/checkpoint-15743e7d-430c-4d76-b6fc-955d7a5c250c.json +0 -44
- package/.ax-cli/checkpoints/2025-11-21/checkpoint-25cf7679-0b3f-4988-83d7-704548fbba91.json +0 -69
- package/.ax-cli/checkpoints/2025-11-21/checkpoint-54aedbac-6db0-464e-8ebb-dbb3979e6dca.json +0 -24
- package/.ax-cli/checkpoints/2025-11-21/checkpoint-7658aed8-fe5d-4222-903f-1a7c63717ea7.json +0 -24
- package/.ax-cli/checkpoints/2025-11-21/checkpoint-c9c13497-40dc-4294-a327-6a5fc854eaa1.json +0 -69
- package/.ax-cli/checkpoints/metadata.json +0 -62
- package/.ax-cli/index.json +0 -44
- package/.ax-cli/memory.json +0 -62
- package/.ax-cli/settings.json +0 -1
- package/ax.config.json +0 -333
- package/dist/agent/chat-history-manager.d.ts +0 -56
- package/dist/agent/chat-history-manager.js +0 -150
- package/dist/agent/chat-history-manager.js.map +0 -1
- package/dist/agent/tool-manager.d.ts +0 -39
- package/dist/agent/tool-manager.js +0 -76
- package/dist/agent/tool-manager.js.map +0 -1
- package/dist/hooks/use-chat-reducer.d.ts +0 -61
- package/dist/hooks/use-chat-reducer.js +0 -118
- package/dist/hooks/use-chat-reducer.js.map +0 -1
- package/dist/hooks/use-enhanced-input.d.ts +0 -40
- package/dist/hooks/use-enhanced-input.js +0 -249
- package/dist/hooks/use-enhanced-input.js.map +0 -1
- package/dist/hooks/use-input-handler.d.ts +0 -46
- package/dist/hooks/use-input-handler.js +0 -1430
- package/dist/hooks/use-input-handler.js.map +0 -1
- package/dist/hooks/use-input-history.d.ts +0 -9
- package/dist/hooks/use-input-history.js +0 -112
- package/dist/hooks/use-input-history.js.map +0 -1
- package/dist/index.js.bak +0 -664
- package/dist/tools/web-search/engines/brave.d.ts +0 -16
- package/dist/tools/web-search/engines/brave.js +0 -99
- package/dist/tools/web-search/engines/brave.js.map +0 -1
- package/dist/tools/web-search/engines/tavily.d.ts +0 -17
- package/dist/tools/web-search/engines/tavily.js +0 -73
- package/dist/tools/web-search/engines/tavily.js.map +0 -1
- package/dist/utils/paste-collapse.d.ts +0 -46
- package/dist/utils/paste-collapse.js +0 -77
- package/dist/utils/paste-collapse.js.map +0 -1
- package/packages/schemas/dist/index.d.ts +0 -14
- package/packages/schemas/dist/index.d.ts.map +0 -1
- package/packages/schemas/dist/index.js +0 -19
- package/packages/schemas/dist/index.js.map +0 -1
- package/packages/schemas/dist/public/core/brand-types.d.ts +0 -308
- package/packages/schemas/dist/public/core/brand-types.d.ts.map +0 -1
- package/packages/schemas/dist/public/core/brand-types.js +0 -243
- package/packages/schemas/dist/public/core/brand-types.js.map +0 -1
- package/packages/schemas/dist/public/core/enums.d.ts +0 -227
- package/packages/schemas/dist/public/core/enums.d.ts.map +0 -1
- package/packages/schemas/dist/public/core/enums.js +0 -222
- package/packages/schemas/dist/public/core/enums.js.map +0 -1
- package/packages/schemas/dist/public/core/id-types.d.ts +0 -286
- package/packages/schemas/dist/public/core/id-types.d.ts.map +0 -1
- package/packages/schemas/dist/public/core/id-types.js +0 -136
- package/packages/schemas/dist/public/core/id-types.js.map +0 -1
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Tool Registry - Unified tool discovery for AX <-> ax-cli integration
|
|
3
|
+
*
|
|
4
|
+
* Allows AutomatosX agents to register custom tools that become available to ax-cli,
|
|
5
|
+
* and vice versa. Enables seamless tool sharing across both systems.
|
|
6
|
+
*/
|
|
7
|
+
import type { LLMTool } from '../llm/client.js';
|
|
8
|
+
/**
|
|
9
|
+
* Tool execution context
|
|
10
|
+
*/
|
|
11
|
+
export interface ToolExecutionContext {
|
|
12
|
+
/** Source system that's executing the tool */
|
|
13
|
+
source: 'ax-cli' | 'automatosx';
|
|
14
|
+
/** Agent ID executing the tool */
|
|
15
|
+
agentId?: string;
|
|
16
|
+
/** Additional context data */
|
|
17
|
+
metadata?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Tool executor function
|
|
21
|
+
*/
|
|
22
|
+
export type ToolExecutor = (args: Record<string, unknown>, context: ToolExecutionContext) => Promise<{
|
|
23
|
+
success: boolean;
|
|
24
|
+
output?: string;
|
|
25
|
+
error?: string;
|
|
26
|
+
data?: unknown;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* Registered tool with execution handler
|
|
30
|
+
*/
|
|
31
|
+
export interface RegisteredTool {
|
|
32
|
+
/** Tool definition (OpenAI format) */
|
|
33
|
+
definition: LLMTool;
|
|
34
|
+
/** Execution handler */
|
|
35
|
+
executor: ToolExecutor;
|
|
36
|
+
/** Source system that registered this tool */
|
|
37
|
+
registeredBy: 'ax-cli' | 'automatosx';
|
|
38
|
+
/** Registration timestamp */
|
|
39
|
+
registeredAt: number;
|
|
40
|
+
/** Optional tags for categorization */
|
|
41
|
+
tags?: string[];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Tool registration options
|
|
45
|
+
*/
|
|
46
|
+
export interface ToolRegistrationOptions {
|
|
47
|
+
/** Tags for categorization */
|
|
48
|
+
tags?: string[];
|
|
49
|
+
/** Whether to allow overwriting existing tool */
|
|
50
|
+
allowOverwrite?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Shared Tool Registry - Centralized tool management
|
|
54
|
+
*/
|
|
55
|
+
export declare class ToolRegistry {
|
|
56
|
+
private static instance;
|
|
57
|
+
private tools;
|
|
58
|
+
private toolsBySource;
|
|
59
|
+
private constructor();
|
|
60
|
+
/**
|
|
61
|
+
* Get the singleton instance
|
|
62
|
+
*/
|
|
63
|
+
static getInstance(): ToolRegistry;
|
|
64
|
+
/**
|
|
65
|
+
* Reset the singleton (for testing)
|
|
66
|
+
*/
|
|
67
|
+
static reset(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Register a tool
|
|
70
|
+
*/
|
|
71
|
+
registerTool(source: 'ax-cli' | 'automatosx', definition: LLMTool, executor: ToolExecutor, options?: ToolRegistrationOptions): void;
|
|
72
|
+
/**
|
|
73
|
+
* Unregister a tool
|
|
74
|
+
*/
|
|
75
|
+
unregisterTool(toolName: string): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Get a registered tool
|
|
78
|
+
*/
|
|
79
|
+
getTool(toolName: string): RegisteredTool | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Check if a tool is registered
|
|
82
|
+
*/
|
|
83
|
+
hasTool(toolName: string): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Get all tool definitions (OpenAI format)
|
|
86
|
+
*/
|
|
87
|
+
getAllToolDefinitions(): LLMTool[];
|
|
88
|
+
/**
|
|
89
|
+
* Get tool definitions from specific source
|
|
90
|
+
*/
|
|
91
|
+
getToolDefinitionsBySource(source: 'ax-cli' | 'automatosx'): LLMTool[];
|
|
92
|
+
/**
|
|
93
|
+
* Get tool definitions by tag
|
|
94
|
+
*/
|
|
95
|
+
getToolDefinitionsByTag(tag: string): LLMTool[];
|
|
96
|
+
/**
|
|
97
|
+
* Execute a tool
|
|
98
|
+
*/
|
|
99
|
+
executeTool(toolName: string, args: Record<string, unknown>, context: ToolExecutionContext): Promise<{
|
|
100
|
+
success: boolean;
|
|
101
|
+
output?: string;
|
|
102
|
+
error?: string;
|
|
103
|
+
data?: unknown;
|
|
104
|
+
}>;
|
|
105
|
+
/**
|
|
106
|
+
* Get all registered tool names
|
|
107
|
+
*/
|
|
108
|
+
getToolNames(): string[];
|
|
109
|
+
/**
|
|
110
|
+
* Get tool names by source
|
|
111
|
+
*/
|
|
112
|
+
getToolNamesBySource(source: 'ax-cli' | 'automatosx'): string[];
|
|
113
|
+
/**
|
|
114
|
+
* Clear all tools (optionally filter by source)
|
|
115
|
+
*/
|
|
116
|
+
clear(source?: 'ax-cli' | 'automatosx'): void;
|
|
117
|
+
/**
|
|
118
|
+
* Get registry statistics
|
|
119
|
+
*/
|
|
120
|
+
getStats(): {
|
|
121
|
+
total: number;
|
|
122
|
+
bySource: Record<string, number>;
|
|
123
|
+
byTag: Record<string, number>;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Export registry as JSON (excluding executors)
|
|
127
|
+
*/
|
|
128
|
+
exportDefinitions(): {
|
|
129
|
+
tools: Array<{
|
|
130
|
+
name: string;
|
|
131
|
+
definition: LLMTool;
|
|
132
|
+
registeredBy: string;
|
|
133
|
+
registeredAt: number;
|
|
134
|
+
tags?: string[];
|
|
135
|
+
}>;
|
|
136
|
+
stats: {
|
|
137
|
+
total: number;
|
|
138
|
+
bySource: Record<string, number>;
|
|
139
|
+
byTag: Record<string, number>;
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get the global tool registry instance
|
|
145
|
+
*/
|
|
146
|
+
export declare function getToolRegistry(): ToolRegistry;
|
|
147
|
+
/**
|
|
148
|
+
* Helper: Register multiple tools at once
|
|
149
|
+
*/
|
|
150
|
+
export declare function registerTools(source: 'ax-cli' | 'automatosx', tools: Array<{
|
|
151
|
+
definition: LLMTool;
|
|
152
|
+
executor: ToolExecutor;
|
|
153
|
+
options?: ToolRegistrationOptions;
|
|
154
|
+
}>): void;
|
|
155
|
+
/**
|
|
156
|
+
* Helper: Create a simple tool executor from a function
|
|
157
|
+
*/
|
|
158
|
+
export declare function createToolExecutor<T extends Record<string, unknown>>(handler: (args: T) => Promise<{
|
|
159
|
+
success: boolean;
|
|
160
|
+
output?: string;
|
|
161
|
+
error?: string;
|
|
162
|
+
data?: unknown;
|
|
163
|
+
}>): ToolExecutor;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Tool Registry - Unified tool discovery for AX <-> ax-cli integration
|
|
3
|
+
*
|
|
4
|
+
* Allows AutomatosX agents to register custom tools that become available to ax-cli,
|
|
5
|
+
* and vice versa. Enables seamless tool sharing across both systems.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Shared Tool Registry - Centralized tool management
|
|
9
|
+
*/
|
|
10
|
+
export class ToolRegistry {
|
|
11
|
+
static instance = null;
|
|
12
|
+
tools = new Map();
|
|
13
|
+
toolsBySource = new Map(); // source -> tool names
|
|
14
|
+
constructor() {
|
|
15
|
+
// Initialize source maps
|
|
16
|
+
this.toolsBySource.set('ax-cli', new Set());
|
|
17
|
+
this.toolsBySource.set('automatosx', new Set());
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get the singleton instance
|
|
21
|
+
*/
|
|
22
|
+
static getInstance() {
|
|
23
|
+
if (!ToolRegistry.instance) {
|
|
24
|
+
ToolRegistry.instance = new ToolRegistry();
|
|
25
|
+
}
|
|
26
|
+
return ToolRegistry.instance;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Reset the singleton (for testing)
|
|
30
|
+
*/
|
|
31
|
+
static reset() {
|
|
32
|
+
if (ToolRegistry.instance) {
|
|
33
|
+
ToolRegistry.instance.clear();
|
|
34
|
+
ToolRegistry.instance = null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Register a tool
|
|
39
|
+
*/
|
|
40
|
+
registerTool(source, definition, executor, options = {}) {
|
|
41
|
+
const toolName = definition.function.name;
|
|
42
|
+
// Check if tool already exists
|
|
43
|
+
if (this.tools.has(toolName) && !options.allowOverwrite) {
|
|
44
|
+
throw new Error(`Tool '${toolName}' is already registered. Use allowOverwrite: true to replace it.`);
|
|
45
|
+
}
|
|
46
|
+
const registeredTool = {
|
|
47
|
+
definition,
|
|
48
|
+
executor,
|
|
49
|
+
registeredBy: source,
|
|
50
|
+
registeredAt: Date.now(),
|
|
51
|
+
tags: options.tags,
|
|
52
|
+
};
|
|
53
|
+
this.tools.set(toolName, registeredTool);
|
|
54
|
+
this.toolsBySource.get(source).add(toolName);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Unregister a tool
|
|
58
|
+
*/
|
|
59
|
+
unregisterTool(toolName) {
|
|
60
|
+
const tool = this.tools.get(toolName);
|
|
61
|
+
if (!tool) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
this.tools.delete(toolName);
|
|
65
|
+
this.toolsBySource.get(tool.registeredBy).delete(toolName);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get a registered tool
|
|
70
|
+
*/
|
|
71
|
+
getTool(toolName) {
|
|
72
|
+
return this.tools.get(toolName);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Check if a tool is registered
|
|
76
|
+
*/
|
|
77
|
+
hasTool(toolName) {
|
|
78
|
+
return this.tools.has(toolName);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get all tool definitions (OpenAI format)
|
|
82
|
+
*/
|
|
83
|
+
getAllToolDefinitions() {
|
|
84
|
+
return Array.from(this.tools.values()).map(tool => tool.definition);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get tool definitions from specific source
|
|
88
|
+
*/
|
|
89
|
+
getToolDefinitionsBySource(source) {
|
|
90
|
+
const toolNames = this.toolsBySource.get(source) || new Set();
|
|
91
|
+
return Array.from(toolNames)
|
|
92
|
+
.map(name => this.tools.get(name))
|
|
93
|
+
.filter((tool) => tool !== undefined)
|
|
94
|
+
.map(tool => tool.definition);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get tool definitions by tag
|
|
98
|
+
*/
|
|
99
|
+
getToolDefinitionsByTag(tag) {
|
|
100
|
+
return Array.from(this.tools.values())
|
|
101
|
+
.filter(tool => tool.tags?.includes(tag))
|
|
102
|
+
.map(tool => tool.definition);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Execute a tool
|
|
106
|
+
*/
|
|
107
|
+
async executeTool(toolName, args, context) {
|
|
108
|
+
const tool = this.tools.get(toolName);
|
|
109
|
+
if (!tool) {
|
|
110
|
+
return {
|
|
111
|
+
success: false,
|
|
112
|
+
error: `Tool '${toolName}' not found in registry`,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
const result = await tool.executor(args, context);
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
return {
|
|
121
|
+
success: false,
|
|
122
|
+
error: error instanceof Error ? error.message : 'Unknown execution error',
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Get all registered tool names
|
|
128
|
+
*/
|
|
129
|
+
getToolNames() {
|
|
130
|
+
return Array.from(this.tools.keys());
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get tool names by source
|
|
134
|
+
*/
|
|
135
|
+
getToolNamesBySource(source) {
|
|
136
|
+
return Array.from(this.toolsBySource.get(source) || []);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Clear all tools (optionally filter by source)
|
|
140
|
+
*/
|
|
141
|
+
clear(source) {
|
|
142
|
+
if (source) {
|
|
143
|
+
// Clear only tools from specific source
|
|
144
|
+
const toolNames = Array.from(this.toolsBySource.get(source) || []);
|
|
145
|
+
for (const name of toolNames) {
|
|
146
|
+
this.tools.delete(name);
|
|
147
|
+
}
|
|
148
|
+
this.toolsBySource.get(source).clear();
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
// Clear all tools
|
|
152
|
+
this.tools.clear();
|
|
153
|
+
this.toolsBySource.get('ax-cli').clear();
|
|
154
|
+
this.toolsBySource.get('automatosx').clear();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Get registry statistics
|
|
159
|
+
*/
|
|
160
|
+
getStats() {
|
|
161
|
+
const byTag = {};
|
|
162
|
+
for (const tool of this.tools.values()) {
|
|
163
|
+
if (tool.tags) {
|
|
164
|
+
for (const tag of tool.tags) {
|
|
165
|
+
byTag[tag] = (byTag[tag] || 0) + 1;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
total: this.tools.size,
|
|
171
|
+
bySource: {
|
|
172
|
+
'ax-cli': this.toolsBySource.get('ax-cli').size,
|
|
173
|
+
'automatosx': this.toolsBySource.get('automatosx').size,
|
|
174
|
+
},
|
|
175
|
+
byTag,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Export registry as JSON (excluding executors)
|
|
180
|
+
*/
|
|
181
|
+
exportDefinitions() {
|
|
182
|
+
const tools = Array.from(this.tools.entries()).map(([name, tool]) => ({
|
|
183
|
+
name,
|
|
184
|
+
definition: tool.definition,
|
|
185
|
+
registeredBy: tool.registeredBy,
|
|
186
|
+
registeredAt: tool.registeredAt,
|
|
187
|
+
tags: tool.tags,
|
|
188
|
+
}));
|
|
189
|
+
return {
|
|
190
|
+
tools,
|
|
191
|
+
stats: this.getStats(),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Get the global tool registry instance
|
|
197
|
+
*/
|
|
198
|
+
export function getToolRegistry() {
|
|
199
|
+
return ToolRegistry.getInstance();
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Helper: Register multiple tools at once
|
|
203
|
+
*/
|
|
204
|
+
export function registerTools(source, tools) {
|
|
205
|
+
const registry = getToolRegistry();
|
|
206
|
+
for (const { definition, executor, options } of tools) {
|
|
207
|
+
registry.registerTool(source, definition, executor, options);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Helper: Create a simple tool executor from a function
|
|
212
|
+
*/
|
|
213
|
+
export function createToolExecutor(handler) {
|
|
214
|
+
return async (args, _context) => {
|
|
215
|
+
return handler(args);
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=tool-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-registry.js","sourceRoot":"","sources":["../../src/sdk/tool-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuDH;;GAEG;AACH,MAAM,OAAO,YAAY;IACf,MAAM,CAAC,QAAQ,GAAwB,IAAI,CAAC;IAE5C,KAAK,GAAgC,IAAI,GAAG,EAAE,CAAC;IAC/C,aAAa,GAA6B,IAAI,GAAG,EAAE,CAAC,CAAC,uBAAuB;IAEpF;QACE,yBAAyB;QACzB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;YAC3B,YAAY,CAAC,QAAQ,GAAG,IAAI,YAAY,EAAE,CAAC;QAC7C,CAAC;QACD,OAAO,YAAY,CAAC,QAAQ,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK;QACV,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC;YAC1B,YAAY,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;YAC9B,YAAY,CAAC,QAAQ,GAAG,IA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Q,EAAE;SACvB,CAAC;IACJ,CAAC;;AAGH;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,YAAY,CAAC,WAAW,EAAE,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAC3B,MAA+B,EAC/B,KAIE;IAEF,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,KAAK,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,KAAK,EAAE,CAAC;QACtD,QAAQ,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAoG;IAEpG,OAAO,KAAK,EAAE,IAA6B,EAAE,QAA8B,EAAE,EAAE;QAC7E,OAAO,OAAO,CAAC,IAAS,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Logger - Shared logging system for AX <-> ax-cli integration
|
|
3
|
+
*
|
|
4
|
+
* Provides centralized log aggregation across AutomatosX and ax-cli
|
|
5
|
+
* for easier debugging and monitoring.
|
|
6
|
+
*/
|
|
7
|
+
import { EventEmitter } from 'events';
|
|
8
|
+
/**
|
|
9
|
+
* Log levels (ordered by severity)
|
|
10
|
+
*/
|
|
11
|
+
export declare enum LogLevel {
|
|
12
|
+
DEBUG = 0,
|
|
13
|
+
INFO = 1,
|
|
14
|
+
WARN = 2,
|
|
15
|
+
ERROR = 3
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Log source identifiers
|
|
19
|
+
*/
|
|
20
|
+
export type LogSource = string;
|
|
21
|
+
/**
|
|
22
|
+
* Log entry structure
|
|
23
|
+
*/
|
|
24
|
+
export interface LogEntry {
|
|
25
|
+
/** Timestamp (milliseconds since epoch) */
|
|
26
|
+
timestamp: number;
|
|
27
|
+
/** Log level */
|
|
28
|
+
level: LogLevel;
|
|
29
|
+
/** Source of the log (agent ID, system name, etc.) */
|
|
30
|
+
source: LogSource;
|
|
31
|
+
/** Log message */
|
|
32
|
+
message: string;
|
|
33
|
+
/** Optional structured data */
|
|
34
|
+
data?: Record<string, unknown>;
|
|
35
|
+
/** Optional error object */
|
|
36
|
+
error?: {
|
|
37
|
+
message: string;
|
|
38
|
+
stack?: string;
|
|
39
|
+
name?: string;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Log filter options
|
|
44
|
+
*/
|
|
45
|
+
export interface LogFilter {
|
|
46
|
+
/** Minimum log level to include */
|
|
47
|
+
minLevel?: LogLevel;
|
|
48
|
+
/** Filter by source (exact match or regex) */
|
|
49
|
+
source?: string | RegExp;
|
|
50
|
+
/** Filter by time range */
|
|
51
|
+
since?: number;
|
|
52
|
+
until?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Unified Logger - Centralized logging for AX and ax-cli
|
|
56
|
+
*/
|
|
57
|
+
export declare class UnifiedLogger extends EventEmitter {
|
|
58
|
+
private static instance;
|
|
59
|
+
private logs;
|
|
60
|
+
private maxLogSize;
|
|
61
|
+
private minLevel;
|
|
62
|
+
private constructor();
|
|
63
|
+
/**
|
|
64
|
+
* Get the singleton instance
|
|
65
|
+
*/
|
|
66
|
+
static getInstance(): UnifiedLogger;
|
|
67
|
+
/**
|
|
68
|
+
* Reset the singleton (for testing)
|
|
69
|
+
*/
|
|
70
|
+
static reset(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Set the minimum log level to record
|
|
73
|
+
*/
|
|
74
|
+
setMinLevel(level: LogLevel): void;
|
|
75
|
+
/**
|
|
76
|
+
* Set maximum number of log entries to keep in memory
|
|
77
|
+
*/
|
|
78
|
+
setMaxLogSize(size: number): void;
|
|
79
|
+
/**
|
|
80
|
+
* Log a message
|
|
81
|
+
*/
|
|
82
|
+
log(level: LogLevel, source: LogSource, message: string, data?: Record<string, unknown>, error?: Error): void;
|
|
83
|
+
/**
|
|
84
|
+
* Log debug message
|
|
85
|
+
*/
|
|
86
|
+
debug(source: LogSource, message: string, data?: Record<string, unknown>): void;
|
|
87
|
+
/**
|
|
88
|
+
* Log info message
|
|
89
|
+
*/
|
|
90
|
+
info(source: LogSource, message: string, data?: Record<string, unknown>): void;
|
|
91
|
+
/**
|
|
92
|
+
* Log warning message
|
|
93
|
+
*/
|
|
94
|
+
warn(source: LogSource, message: string, data?: Record<string, unknown>): void;
|
|
95
|
+
/**
|
|
96
|
+
* Log error message
|
|
97
|
+
*/
|
|
98
|
+
error(source: LogSource, message: string, error?: Error, data?: Record<string, unknown>): void;
|
|
99
|
+
/**
|
|
100
|
+
* Trim logs to max size (keep most recent)
|
|
101
|
+
*/
|
|
102
|
+
private trimLogs;
|
|
103
|
+
/**
|
|
104
|
+
* Get all logs (optionally filtered)
|
|
105
|
+
*/
|
|
106
|
+
getLogs(filter?: LogFilter): LogEntry[];
|
|
107
|
+
/**
|
|
108
|
+
* Get recent logs (last N entries)
|
|
109
|
+
*/
|
|
110
|
+
getRecentLogs(count: number, filter?: LogFilter): LogEntry[];
|
|
111
|
+
/**
|
|
112
|
+
* Subscribe to all log events
|
|
113
|
+
*/
|
|
114
|
+
onLog(callback: (entry: LogEntry) => void): () => void;
|
|
115
|
+
/**
|
|
116
|
+
* Subscribe to specific log level
|
|
117
|
+
*/
|
|
118
|
+
onLevel(level: LogLevel, callback: (entry: LogEntry) => void): () => void;
|
|
119
|
+
/**
|
|
120
|
+
* Clear all logs
|
|
121
|
+
*/
|
|
122
|
+
clear(): void;
|
|
123
|
+
/**
|
|
124
|
+
* Get statistics about logs
|
|
125
|
+
*/
|
|
126
|
+
getStats(): {
|
|
127
|
+
total: number;
|
|
128
|
+
byLevel: Record<string, number>;
|
|
129
|
+
bySources: Record<string, number>;
|
|
130
|
+
oldestTimestamp?: number;
|
|
131
|
+
newestTimestamp?: number;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Format a log entry as a string
|
|
135
|
+
*/
|
|
136
|
+
format(entry: LogEntry, options?: {
|
|
137
|
+
includeTimestamp?: boolean;
|
|
138
|
+
includeSource?: boolean;
|
|
139
|
+
}): string;
|
|
140
|
+
/**
|
|
141
|
+
* Export logs as JSON
|
|
142
|
+
*/
|
|
143
|
+
exportJSON(filter?: LogFilter): string;
|
|
144
|
+
/**
|
|
145
|
+
* Export logs as plain text
|
|
146
|
+
*/
|
|
147
|
+
exportText(filter?: LogFilter, options?: {
|
|
148
|
+
includeTimestamp?: boolean;
|
|
149
|
+
includeSource?: boolean;
|
|
150
|
+
}): string;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get the global unified logger instance
|
|
154
|
+
*/
|
|
155
|
+
export declare function getUnifiedLogger(): UnifiedLogger;
|
|
156
|
+
/**
|
|
157
|
+
* Helper: Get log level from string
|
|
158
|
+
*/
|
|
159
|
+
export declare function parseLogLevel(level: string): LogLevel;
|
|
160
|
+
/**
|
|
161
|
+
* Helper: Get log level name
|
|
162
|
+
*/
|
|
163
|
+
export declare function getLogLevelName(level: LogLevel): string;
|