@autonav/core 1.0.0
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 +115 -0
- package/dist/adapter/claude-adapter.d.ts +136 -0
- package/dist/adapter/claude-adapter.d.ts.map +1 -0
- package/dist/adapter/claude-adapter.js +340 -0
- package/dist/adapter/claude-adapter.js.map +1 -0
- package/dist/adapter/index.d.ts +7 -0
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/adapter/index.js +7 -0
- package/dist/adapter/index.js.map +1 -0
- package/dist/cli/autonav.d.ts +11 -0
- package/dist/cli/autonav.d.ts.map +1 -0
- package/dist/cli/autonav.js +79 -0
- package/dist/cli/autonav.js.map +1 -0
- package/dist/cli/nav-chat.d.ts +3 -0
- package/dist/cli/nav-chat.d.ts.map +1 -0
- package/dist/cli/nav-chat.js +151 -0
- package/dist/cli/nav-chat.js.map +1 -0
- package/dist/cli/nav-init.d.ts +3 -0
- package/dist/cli/nav-init.d.ts.map +1 -0
- package/dist/cli/nav-init.js +366 -0
- package/dist/cli/nav-init.js.map +1 -0
- package/dist/cli/nav-query.d.ts +3 -0
- package/dist/cli/nav-query.d.ts.map +1 -0
- package/dist/cli/nav-query.js +217 -0
- package/dist/cli/nav-query.js.map +1 -0
- package/dist/conversation/App.d.ts +14 -0
- package/dist/conversation/App.d.ts.map +1 -0
- package/dist/conversation/App.js +229 -0
- package/dist/conversation/App.js.map +1 -0
- package/dist/conversation/index.d.ts +29 -0
- package/dist/conversation/index.d.ts.map +1 -0
- package/dist/conversation/index.js +44 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/conversation/prompts.d.ts +9 -0
- package/dist/conversation/prompts.d.ts.map +1 -0
- package/dist/conversation/prompts.js +47 -0
- package/dist/conversation/prompts.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/interview/App.d.ts +14 -0
- package/dist/interview/App.d.ts.map +1 -0
- package/dist/interview/App.js +159 -0
- package/dist/interview/App.js.map +1 -0
- package/dist/interview/index.d.ts +30 -0
- package/dist/interview/index.d.ts.map +1 -0
- package/dist/interview/index.js +52 -0
- package/dist/interview/index.js.map +1 -0
- package/dist/interview/prompts.d.ts +36 -0
- package/dist/interview/prompts.d.ts.map +1 -0
- package/dist/interview/prompts.js +116 -0
- package/dist/interview/prompts.js.map +1 -0
- package/dist/pack-installer/github.d.ts +41 -0
- package/dist/pack-installer/github.d.ts.map +1 -0
- package/dist/pack-installer/github.js +294 -0
- package/dist/pack-installer/github.js.map +1 -0
- package/dist/pack-installer/index.d.ts +57 -0
- package/dist/pack-installer/index.d.ts.map +1 -0
- package/dist/pack-installer/index.js +257 -0
- package/dist/pack-installer/index.js.map +1 -0
- package/dist/plugins/config-schema.d.ts +32 -0
- package/dist/plugins/config-schema.d.ts.map +1 -0
- package/dist/plugins/config-schema.js +26 -0
- package/dist/plugins/config-schema.js.map +1 -0
- package/dist/plugins/implementations/file-watcher/index.d.ts +110 -0
- package/dist/plugins/implementations/file-watcher/index.d.ts.map +1 -0
- package/dist/plugins/implementations/file-watcher/index.js +212 -0
- package/dist/plugins/implementations/file-watcher/index.js.map +1 -0
- package/dist/plugins/implementations/github/index.d.ts +201 -0
- package/dist/plugins/implementations/github/index.d.ts.map +1 -0
- package/dist/plugins/implementations/github/index.js +337 -0
- package/dist/plugins/implementations/github/index.js.map +1 -0
- package/dist/plugins/implementations/slack/index.d.ts +153 -0
- package/dist/plugins/implementations/slack/index.d.ts.map +1 -0
- package/dist/plugins/implementations/slack/index.js +221 -0
- package/dist/plugins/implementations/slack/index.js.map +1 -0
- package/dist/plugins/index.d.ts +23 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +35 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/plugin-manager.d.ts +66 -0
- package/dist/plugins/plugin-manager.d.ts.map +1 -0
- package/dist/plugins/plugin-manager.js +198 -0
- package/dist/plugins/plugin-manager.js.map +1 -0
- package/dist/plugins/types.d.ts +102 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +38 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/plugins/utils/security.d.ts +43 -0
- package/dist/plugins/utils/security.d.ts.map +1 -0
- package/dist/plugins/utils/security.js +115 -0
- package/dist/plugins/utils/security.js.map +1 -0
- package/dist/query-engine/index.d.ts +10 -0
- package/dist/query-engine/index.d.ts.map +1 -0
- package/dist/query-engine/index.js +10 -0
- package/dist/query-engine/index.js.map +1 -0
- package/dist/query-engine/navigator-loader.d.ts +37 -0
- package/dist/query-engine/navigator-loader.d.ts.map +1 -0
- package/dist/query-engine/navigator-loader.js +167 -0
- package/dist/query-engine/navigator-loader.js.map +1 -0
- package/dist/query-engine/output-formatter.d.ts +55 -0
- package/dist/query-engine/output-formatter.d.ts.map +1 -0
- package/dist/query-engine/output-formatter.js +165 -0
- package/dist/query-engine/output-formatter.js.map +1 -0
- package/dist/query-engine/response-validator.d.ts +55 -0
- package/dist/query-engine/response-validator.d.ts.map +1 -0
- package/dist/query-engine/response-validator.js +92 -0
- package/dist/query-engine/response-validator.js.map +1 -0
- package/dist/templates/.gitignore.template +23 -0
- package/dist/templates/CLAUDE-pack.md.template +32 -0
- package/dist/templates/CLAUDE.md.template +128 -0
- package/dist/templates/README.md.template +174 -0
- package/dist/templates/config-pack.json.template +16 -0
- package/dist/templates/config.json.template +11 -0
- package/dist/templates/index.d.ts +22 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +32 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/plugins.json.template +33 -0
- package/dist/templates/system-configuration.md.template +66 -0
- package/dist/tools/handler.d.ts +20 -0
- package/dist/tools/handler.d.ts.map +1 -0
- package/dist/tools/handler.js +202 -0
- package/dist/tools/handler.js.map +1 -0
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +10 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/response.d.ts +30 -0
- package/dist/tools/response.d.ts.map +1 -0
- package/dist/tools/response.js +68 -0
- package/dist/tools/response.js.map +1 -0
- package/dist/tools/self-config.d.ts +54 -0
- package/dist/tools/self-config.d.ts.map +1 -0
- package/dist/tools/self-config.js +84 -0
- package/dist/tools/self-config.js.map +1 -0
- package/dist/validation/index.d.ts +19 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +91 -0
- package/dist/validation/index.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Base plugin interface that all plugins must implement.
|
|
4
|
+
* Plugins provide bidirectional communication between navigators and external systems.
|
|
5
|
+
*/
|
|
6
|
+
export interface Plugin<TConfig = unknown, TEvent = unknown, TAction = unknown> {
|
|
7
|
+
/** Unique plugin identifier (e.g., "slack", "github") */
|
|
8
|
+
readonly name: string;
|
|
9
|
+
/** Semantic version (e.g., "1.0.0") */
|
|
10
|
+
readonly version: string;
|
|
11
|
+
/** Human-readable description */
|
|
12
|
+
readonly description: string;
|
|
13
|
+
/** Zod schema for validating plugin configuration */
|
|
14
|
+
readonly configSchema: z.ZodType<TConfig, any, any>;
|
|
15
|
+
/** Zod schema for validating events (input) */
|
|
16
|
+
readonly eventSchema: z.ZodType<TEvent, any, any>;
|
|
17
|
+
/** Zod schema for validating actions (output) */
|
|
18
|
+
readonly actionSchema: z.ZodType<TAction, any, any>;
|
|
19
|
+
/**
|
|
20
|
+
* Initialize the plugin with validated configuration.
|
|
21
|
+
* Called once when plugin is loaded.
|
|
22
|
+
*
|
|
23
|
+
* @param config - Validated configuration from .claude/plugins.json
|
|
24
|
+
* @throws PluginInitializationError if initialization fails
|
|
25
|
+
*/
|
|
26
|
+
initialize(config: TConfig): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Listen for events from the external system.
|
|
29
|
+
* Called periodically by the plugin manager (or on-demand).
|
|
30
|
+
*
|
|
31
|
+
* @returns Array of events that occurred since last check
|
|
32
|
+
* @throws PluginListenError if listening fails
|
|
33
|
+
*/
|
|
34
|
+
listen(): Promise<TEvent[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Execute an action on the external system.
|
|
37
|
+
* Called when navigator requests plugin action.
|
|
38
|
+
*
|
|
39
|
+
* @param action - Validated action to execute
|
|
40
|
+
* @returns Result of the action (plugin-specific)
|
|
41
|
+
* @throws PluginActionError if action execution fails
|
|
42
|
+
*/
|
|
43
|
+
execute(action: TAction): Promise<unknown>;
|
|
44
|
+
/**
|
|
45
|
+
* Update plugin configuration.
|
|
46
|
+
* Allows navigators to self-configure via conversation.
|
|
47
|
+
*
|
|
48
|
+
* @param updates - Partial configuration updates
|
|
49
|
+
* @returns Updated full configuration
|
|
50
|
+
* @throws PluginConfigurationError if update fails
|
|
51
|
+
*/
|
|
52
|
+
updateConfig(updates: Partial<TConfig>): Promise<TConfig>;
|
|
53
|
+
/**
|
|
54
|
+
* Get current plugin configuration.
|
|
55
|
+
* Used for displaying settings to navigator.
|
|
56
|
+
*
|
|
57
|
+
* @returns Current configuration
|
|
58
|
+
*/
|
|
59
|
+
getConfig(): TConfig;
|
|
60
|
+
/**
|
|
61
|
+
* Check if plugin is healthy and operational.
|
|
62
|
+
* Called during health checks.
|
|
63
|
+
*
|
|
64
|
+
* @returns Health status with optional details
|
|
65
|
+
*/
|
|
66
|
+
healthCheck(): Promise<PluginHealthStatus>;
|
|
67
|
+
/**
|
|
68
|
+
* Clean up resources when plugin is disabled or navigator shuts down.
|
|
69
|
+
* Called once during shutdown.
|
|
70
|
+
*/
|
|
71
|
+
shutdown(): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Plugin health status
|
|
75
|
+
*/
|
|
76
|
+
export interface PluginHealthStatus {
|
|
77
|
+
healthy: boolean;
|
|
78
|
+
message?: string;
|
|
79
|
+
lastError?: Error;
|
|
80
|
+
metadata?: Record<string, unknown>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Base plugin errors for standardized error handling
|
|
84
|
+
*/
|
|
85
|
+
export declare class PluginError extends Error {
|
|
86
|
+
readonly pluginName: string;
|
|
87
|
+
readonly originalError?: Error | undefined;
|
|
88
|
+
constructor(pluginName: string, message: string, originalError?: Error | undefined);
|
|
89
|
+
}
|
|
90
|
+
export declare class PluginInitializationError extends PluginError {
|
|
91
|
+
constructor(pluginName: string, message: string, originalError?: Error);
|
|
92
|
+
}
|
|
93
|
+
export declare class PluginListenError extends PluginError {
|
|
94
|
+
constructor(pluginName: string, message: string, originalError?: Error);
|
|
95
|
+
}
|
|
96
|
+
export declare class PluginActionError extends PluginError {
|
|
97
|
+
constructor(pluginName: string, message: string, originalError?: Error);
|
|
98
|
+
}
|
|
99
|
+
export declare class PluginConfigurationError extends PluginError {
|
|
100
|
+
constructor(pluginName: string, message: string, originalError?: Error);
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugins/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,WAAW,MAAM,CAAC,OAAO,GAAG,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IAC5E,yDAAyD;IACzD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,iCAAiC;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,qDAAqD;IACrD,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAEpD,+CAA+C;IAC/C,Q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AAM,EAAE,aAAa,CAAC,EAAE,KAAK;CAIvE;AAED,qBAAa,iBAAkB,SAAQ,WAAW;gBACpC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,KAAK;CAIvE;AAED,qBAAa,iBAAkB,SAAQ,WAAW;gBACpC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,KAAK;CAIvE;AAED,qBAAa,wBAAyB,SAAQ,WAAW;gBAC3C,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,KAAK;CAIvE"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base plugin errors for standardized error handling
|
|
3
|
+
*/
|
|
4
|
+
export class PluginError extends Error {
|
|
5
|
+
pluginName;
|
|
6
|
+
originalError;
|
|
7
|
+
constructor(pluginName, message, originalError) {
|
|
8
|
+
super(`[${pluginName}] ${message}`);
|
|
9
|
+
this.pluginName = pluginName;
|
|
10
|
+
this.originalError = originalError;
|
|
11
|
+
this.name = 'PluginError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class PluginInitializationError extends PluginError {
|
|
15
|
+
constructor(pluginName, message, originalError) {
|
|
16
|
+
super(pluginName, `Initialization failed: ${message}`, originalError);
|
|
17
|
+
this.name = 'PluginInitializationError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class PluginListenError extends PluginError {
|
|
21
|
+
constructor(pluginName, message, originalError) {
|
|
22
|
+
super(pluginName, `Listen failed: ${message}`, originalError);
|
|
23
|
+
this.name = 'PluginListenError';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export class PluginActionError extends PluginError {
|
|
27
|
+
constructor(pluginName, message, originalError) {
|
|
28
|
+
super(pluginName, `Action execution failed: ${message}`, originalError);
|
|
29
|
+
this.name = 'PluginActionError';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export class PluginConfigurationError extends PluginError {
|
|
33
|
+
constructor(pluginName, message, originalError) {
|
|
34
|
+
super(pluginName, `Configuration update failed: ${message}`, originalError);
|
|
35
|
+
this.name = 'PluginConfigurationError';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/plugins/types.ts"],"names":[],"mappings":"AAgGA;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAElB;IAEA;IAHlB,YACkB,UAAkB,EAClC,OAAe,EACC,aAAqB;QAErC,KAAK,CAAC,IAAI,UAAU,KAAK,OAAO,EAAE,CAAC,CAAC;QAJpB,eAAU,GAAV,UAAU,CAAQ;QAElB,kBAAa,GAAb,aAAa,CAAQ;QAGrC,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AAED,MAAM,OAAO,yBAA0B,SAAQ,WAAW;IACxD,YAAY,UAAkB,EAAE,OAAe,EAAE,aAAqB;QACpE,KAAK,CAAC,UAAU,EAAE,0BAA0B,OAAO,EAAE,EAAE,aAAa,CAAC,CAAC;QACtE,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC1C,CAAC;CACF;AAED,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAChD,YAAY,UAAkB,EAAE,OAAe,EAAE,aAAqB;QACpE,KAAK,CAAC,UAAU,EAAE,kBAAkB,OAAO,EAAE,EAAE,aAAa,CAAC,CAAC;QAC9D,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAChD,YAAY,UAAkB,EAAE,OAAe,EAAE,aAAqB;QACpE,KAAK,CAAC,UAAU,EAAE,4BAA4B,OAAO,EAAE,EAAE,aAAa,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,MAAM,OAAO,wBAAyB,SAAQ,WAAW;IACvD,YAAY,UAAkB,EAAE,OAAe,EAAE,aAAqB;QACpE,KAAK,CAAC,UAAU,EAAE,gCAAgC,OAAO,EAAE,EAAE,aAAa,CAAC,CAAC;QAC5E,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security utilities for protecting sensitive data in plugins
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Sanitize a string by masking sensitive tokens and credentials
|
|
6
|
+
*
|
|
7
|
+
* @param text - Text that may contain sensitive data
|
|
8
|
+
* @returns Sanitized text with credentials masked
|
|
9
|
+
*/
|
|
10
|
+
export declare function sanitizeCredentials(text: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Sanitize an error message before logging or throwing
|
|
13
|
+
*
|
|
14
|
+
* @param error - Error object or message
|
|
15
|
+
* @returns Sanitized error message
|
|
16
|
+
*/
|
|
17
|
+
export declare function sanitizeError(error: Error | string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Sanitize a configuration object for safe logging
|
|
20
|
+
* Never log the actual config - only structure
|
|
21
|
+
*
|
|
22
|
+
* @param config - Configuration object
|
|
23
|
+
* @returns Sanitized config summary
|
|
24
|
+
*/
|
|
25
|
+
export declare function sanitizeConfigForLogging(config: Record<string, unknown>): Record<string, unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* Create a safe error for external display
|
|
28
|
+
* Strips sensitive information and provides sanitized message
|
|
29
|
+
*
|
|
30
|
+
* @param error - Original error
|
|
31
|
+
* @param context - Additional context (will be sanitized)
|
|
32
|
+
* @returns Safe error object
|
|
33
|
+
*/
|
|
34
|
+
export declare function createSafeError(error: Error | string, context?: Record<string, unknown>): Error;
|
|
35
|
+
/**
|
|
36
|
+
* Validate that a string doesn't contain obvious sensitive data
|
|
37
|
+
* Throws if sensitive data is detected
|
|
38
|
+
*
|
|
39
|
+
* @param text - Text to validate
|
|
40
|
+
* @param fieldName - Name of the field being validated (for error message)
|
|
41
|
+
*/
|
|
42
|
+
export declare function assertNoCredentialsInText(text: string, fieldName: string): void;
|
|
43
|
+
//# sourceMappingURL=security.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../../src/plugins/utils/security.ts"],"names":[],"mappings":"AAAA;;GAEG;AAwBH;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAiBxD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAG3D;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAoBjG;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,KAAK,GAAG,MAAM,EACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,KAAK,CAUP;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAS/E"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security utilities for protecting sensitive data in plugins
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Patterns for detecting sensitive tokens and credentials
|
|
6
|
+
*/
|
|
7
|
+
const SENSITIVE_PATTERNS = [
|
|
8
|
+
// API tokens
|
|
9
|
+
/xoxb-[a-zA-Z0-9-]+/gi, // Slack bot tokens
|
|
10
|
+
/xoxp-[a-zA-Z0-9-]+/gi, // Slack user tokens
|
|
11
|
+
/ghp_[a-zA-Z0-9]+/gi, // GitHub personal access tokens
|
|
12
|
+
/gho_[a-zA-Z0-9]+/gi, // GitHub OAuth tokens
|
|
13
|
+
/ghs_[a-zA-Z0-9]+/gi, // GitHub server tokens
|
|
14
|
+
// Generic patterns
|
|
15
|
+
/sk-[a-zA-Z0-9]{20,}/gi, // OpenAI/Anthropic style keys
|
|
16
|
+
/Bearer\s+[a-zA-Z0-9_\-\.]+/gi, // Bearer tokens
|
|
17
|
+
/api[_-]?key['":\s=]+[a-zA-Z0-9_\-]+/gi, // API keys
|
|
18
|
+
/token['":\s=]+[a-zA-Z0-9_\-]+/gi, // Generic tokens
|
|
19
|
+
// AWS credentials
|
|
20
|
+
/AKIA[0-9A-Z]{16}/gi, // AWS access key IDs
|
|
21
|
+
/aws_secret_access_key['":\s=]+[a-zA-Z0-9\/\+]{40}/gi, // AWS secret keys
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Sanitize a string by masking sensitive tokens and credentials
|
|
25
|
+
*
|
|
26
|
+
* @param text - Text that may contain sensitive data
|
|
27
|
+
* @returns Sanitized text with credentials masked
|
|
28
|
+
*/
|
|
29
|
+
export function sanitizeCredentials(text) {
|
|
30
|
+
let sanitized = text;
|
|
31
|
+
for (const pattern of SENSITIVE_PATTERNS) {
|
|
32
|
+
sanitized = sanitized.replace(pattern, (match) => {
|
|
33
|
+
// Keep first 4 and last 4 characters, mask the middle
|
|
34
|
+
if (match.length <= 12) {
|
|
35
|
+
return '***REDACTED***';
|
|
36
|
+
}
|
|
37
|
+
const prefix = match.substring(0, 4);
|
|
38
|
+
const suffix = match.substring(match.length - 4);
|
|
39
|
+
const maskedLength = Math.min(match.length - 8, 20);
|
|
40
|
+
return `${prefix}${'*'.repeat(maskedLength)}${suffix}`;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return sanitized;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Sanitize an error message before logging or throwing
|
|
47
|
+
*
|
|
48
|
+
* @param error - Error object or message
|
|
49
|
+
* @returns Sanitized error message
|
|
50
|
+
*/
|
|
51
|
+
export function sanitizeError(error) {
|
|
52
|
+
const message = typeof error === 'string' ? error : error.message;
|
|
53
|
+
return sanitizeCredentials(message);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sanitize a configuration object for safe logging
|
|
57
|
+
* Never log the actual config - only structure
|
|
58
|
+
*
|
|
59
|
+
* @param config - Configuration object
|
|
60
|
+
* @returns Sanitized config summary
|
|
61
|
+
*/
|
|
62
|
+
export function sanitizeConfigForLogging(config) {
|
|
63
|
+
const sanitized = {};
|
|
64
|
+
for (const [key, value] of Object.entries(config)) {
|
|
65
|
+
// Always mask these fields
|
|
66
|
+
const sensitiveKeys = ['token', 'password', 'secret', 'key', 'apiKey', 'apiSecret', 'accessToken'];
|
|
67
|
+
const isSensitive = sensitiveKeys.some(k => key.toLowerCase().includes(k.toLowerCase()));
|
|
68
|
+
if (isSensitive && typeof value === 'string') {
|
|
69
|
+
sanitized[key] = value.length > 0 ? '***SET***' : '***EMPTY***';
|
|
70
|
+
}
|
|
71
|
+
else if (Array.isArray(value)) {
|
|
72
|
+
sanitized[key] = `Array(${value.length})`;
|
|
73
|
+
}
|
|
74
|
+
else if (typeof value === 'object' && value !== null) {
|
|
75
|
+
sanitized[key] = '[Object]';
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
sanitized[key] = value;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return sanitized;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Create a safe error for external display
|
|
85
|
+
* Strips sensitive information and provides sanitized message
|
|
86
|
+
*
|
|
87
|
+
* @param error - Original error
|
|
88
|
+
* @param context - Additional context (will be sanitized)
|
|
89
|
+
* @returns Safe error object
|
|
90
|
+
*/
|
|
91
|
+
export function createSafeError(error, context) {
|
|
92
|
+
const message = sanitizeError(error);
|
|
93
|
+
const safeError = new Error(message);
|
|
94
|
+
if (context) {
|
|
95
|
+
// Attach sanitized context
|
|
96
|
+
safeError.context = sanitizeConfigForLogging(context);
|
|
97
|
+
}
|
|
98
|
+
return safeError;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Validate that a string doesn't contain obvious sensitive data
|
|
102
|
+
* Throws if sensitive data is detected
|
|
103
|
+
*
|
|
104
|
+
* @param text - Text to validate
|
|
105
|
+
* @param fieldName - Name of the field being validated (for error message)
|
|
106
|
+
*/
|
|
107
|
+
export function assertNoCredentialsInText(text, fieldName) {
|
|
108
|
+
for (const pattern of SENSITIVE_PATTERNS) {
|
|
109
|
+
if (pattern.test(text)) {
|
|
110
|
+
throw new Error(`Potential credential detected in ${fieldName}. ` +
|
|
111
|
+
`Please do not include tokens, API keys, or passwords in user-facing content.`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=security.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security.js","sourceRoot":"","sources":["../../../src/plugins/utils/security.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,kBAAkB,GAAG;IACzB,aAAa;IACb,sBAAsB,EAAE,mBAAmB;IAC3C,sBAAsB,EAAE,oBAAoB;IAC5C,oBAAoB,EAAE,gCAAgC;IACtD,oBAAoB,EAAE,sBAAsB;IAC5C,oBAAoB,EAAE,uBAAuB;IAE7C,mBAAmB;IACnB,uBAAuB,EAAE,8BAA8B;IACvD,8BAA8B,EAAE,gBAAgB;IAChD,uCAAuC,EAAE,WAAW;IACpD,iCAAiC,EAAE,iBAAiB;IAEpD,kBAAkB;IAClB,oBAAoB,EAAE,qBAAqB;IAC3C,qDAAqD,EAAE,kBAAkB;CAC1E,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,IAAI,SAAS,GAAG,IAAI,CAAC;IAErB,KAAK,MAAM,OAAO,IAAI,kBAAkB,EAAE,CAAC;QACzC,S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ACb,oCAAoC,SAAS,IAAI;gBACjD,8EAA8E,CAC/E,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query Engine
|
|
3
|
+
*
|
|
4
|
+
* Core functionality for loading navigators, executing queries,
|
|
5
|
+
* validating responses, and formatting output.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./navigator-loader.js";
|
|
8
|
+
export * from "./response-validator.js";
|
|
9
|
+
export * from "./output-formatter.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/query-engine/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query Engine
|
|
3
|
+
*
|
|
4
|
+
* Core functionality for loading navigators, executing queries,
|
|
5
|
+
* validating responses, and formatting output.
|
|
6
|
+
*/
|
|
7
|
+
export * from "./navigator-loader.js";
|
|
8
|
+
export * from "./response-validator.js";
|
|
9
|
+
export * from "./output-formatter.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/query-engine/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { NavigatorConfig } from "@autonav/communication-layer";
|
|
2
|
+
/**
|
|
3
|
+
* Loaded navigator with all necessary context
|
|
4
|
+
*/
|
|
5
|
+
export interface LoadedNavigator {
|
|
6
|
+
config: NavigatorConfig;
|
|
7
|
+
systemPrompt: string;
|
|
8
|
+
navigatorPath: string;
|
|
9
|
+
knowledgeBasePath: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Navigator resolution options
|
|
13
|
+
*/
|
|
14
|
+
export interface NavigatorResolveOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Current working directory to resolve relative paths
|
|
17
|
+
*/
|
|
18
|
+
cwd?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Load a navigator from a directory
|
|
22
|
+
*
|
|
23
|
+
* Reads and validates config.json and CLAUDE.md
|
|
24
|
+
*
|
|
25
|
+
* @param navigatorPathInput - Path to navigator (relative or absolute)
|
|
26
|
+
* @param options - Resolution options
|
|
27
|
+
* @returns Loaded navigator with configuration and context
|
|
28
|
+
*/
|
|
29
|
+
export declare function loadNavigator(navigatorPathInput: string, options?: NavigatorResolveOptions): LoadedNavigator;
|
|
30
|
+
/**
|
|
31
|
+
* Navigator load error with additional context
|
|
32
|
+
*/
|
|
33
|
+
export declare class NavigatorLoadError extends Error {
|
|
34
|
+
context?: Record<string, unknown> | undefined;
|
|
35
|
+
constructor(message: string, context?: Record<string, unknown> | undefined);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=navigator-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigator-loader.d.ts","sourceRoot":"","sources":["../../src/query-engine/navigator-loader.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EAEhB,MAAM,8BAA8B,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,eAAe,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,kBAAkB,EAAE,MAAM,EAC1B,OAAO,CAAC,EAAE,uBAAuB,GAChC,eAAe,CAuCjB;AAgKD;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAGlC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBADxC,OAAO,EAAE,MAAM,EACR,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;CAK3C"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { NavigatorConfigSchema, } from "@autonav/communication-layer";
|
|
4
|
+
/**
|
|
5
|
+
* Load a navigator from a directory
|
|
6
|
+
*
|
|
7
|
+
* Reads and validates config.json and CLAUDE.md
|
|
8
|
+
*
|
|
9
|
+
* @param navigatorPathInput - Path to navigator (relative or absolute)
|
|
10
|
+
* @param options - Resolution options
|
|
11
|
+
* @returns Loaded navigator with configuration and context
|
|
12
|
+
*/
|
|
13
|
+
export function loadNavigator(navigatorPathInput, options) {
|
|
14
|
+
const cwd = options?.cwd || process.cwd();
|
|
15
|
+
const navigatorPath = resolveNavigatorPath(navigatorPathInput, cwd);
|
|
16
|
+
// Validate directory exists
|
|
17
|
+
if (!fs.existsSync(navigatorPath)) {
|
|
18
|
+
throw new NavigatorLoadError(`Navigator directory not found: ${navigatorPath}`, {
|
|
19
|
+
searchedPath: navigatorPath,
|
|
20
|
+
suggestions: findSimilarNavigators(cwd),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
// Check if it's a directory
|
|
24
|
+
const stats = fs.statSync(navigatorPath);
|
|
25
|
+
if (!stats.isDirectory()) {
|
|
26
|
+
throw new NavigatorLoadError(`Navigator path is not a directory: ${navigatorPath}`);
|
|
27
|
+
}
|
|
28
|
+
// Load and validate config.json
|
|
29
|
+
const config = loadNavigatorConfig(navigatorPath);
|
|
30
|
+
// Load CLAUDE.md instructions
|
|
31
|
+
const systemPrompt = loadSystemPrompt(navigatorPath, config);
|
|
32
|
+
// Validate knowledge base exists
|
|
33
|
+
const knowledgeBasePath = resolveKnowledgeBasePath(navigatorPath, config);
|
|
34
|
+
validateKnowledgeBase(knowledgeBasePath);
|
|
35
|
+
return {
|
|
36
|
+
config,
|
|
37
|
+
systemPrompt,
|
|
38
|
+
navigatorPath,
|
|
39
|
+
knowledgeBasePath,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Resolve navigator path from user input
|
|
44
|
+
*
|
|
45
|
+
* Handles:
|
|
46
|
+
* - Relative paths: ./my-nav
|
|
47
|
+
* - Absolute paths: /path/to/navigator
|
|
48
|
+
* - By name: my-nav (searches in current directory)
|
|
49
|
+
*/
|
|
50
|
+
function resolveNavigatorPath(input, cwd) {
|
|
51
|
+
// If it's already absolute, use it
|
|
52
|
+
if (path.isAbsolute(input)) {
|
|
53
|
+
return input;
|
|
54
|
+
}
|
|
55
|
+
// Resolve relative to cwd
|
|
56
|
+
return path.resolve(cwd, input);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Load and validate navigator config.json
|
|
60
|
+
*/
|
|
61
|
+
function loadNavigatorConfig(navigatorPath) {
|
|
62
|
+
const configPath = path.join(navigatorPath, "config.json");
|
|
63
|
+
if (!fs.existsSync(configPath)) {
|
|
64
|
+
throw new NavigatorLoadError(`config.json not found in ${navigatorPath}`, {
|
|
65
|
+
missingFile: "config.json",
|
|
66
|
+
suggestion: "Make sure you're pointing to a valid navigator directory. Use 'autonav init' to create a new navigator.",
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
const configContent = fs.readFileSync(configPath, "utf-8");
|
|
71
|
+
const configJson = JSON.parse(configContent);
|
|
72
|
+
return NavigatorConfigSchema.parse(configJson);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error instanceof SyntaxError) {
|
|
76
|
+
throw new NavigatorLoadError(`Invalid JSON in config.json: ${error.message}`, {
|
|
77
|
+
file: configPath,
|
|
78
|
+
error: error.message,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
throw new NavigatorLoadError(`Invalid config.json: ${error instanceof Error ? error.message : String(error)}`, {
|
|
82
|
+
file: configPath,
|
|
83
|
+
validationError: error,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Load system prompt from CLAUDE.md
|
|
89
|
+
*/
|
|
90
|
+
function loadSystemPrompt(navigatorPath, _config) {
|
|
91
|
+
// Standard location for CLAUDE.md instructions
|
|
92
|
+
const instructionsPath = path.join(navigatorPath, "CLAUDE.md");
|
|
93
|
+
if (!fs.existsSync(instructionsPath)) {
|
|
94
|
+
throw new NavigatorLoadError(`Instructions file not found: CLAUDE.md`, {
|
|
95
|
+
missingFile: "CLAUDE.md",
|
|
96
|
+
suggestion: "Navigator requires a CLAUDE.md file with instructions for Claude.",
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
return fs.readFileSync(instructionsPath, "utf-8");
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
throw new NavigatorLoadError(`Failed to read instructions file: ${error instanceof Error ? error.message : String(error)}`, {
|
|
104
|
+
file: instructionsPath,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Resolve knowledge base path
|
|
110
|
+
*/
|
|
111
|
+
function resolveKnowledgeBasePath(navigatorPath, config) {
|
|
112
|
+
return path.join(navigatorPath, config.knowledgeBase);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Validate knowledge base directory exists
|
|
116
|
+
*/
|
|
117
|
+
function validateKnowledgeBase(knowledgeBasePath) {
|
|
118
|
+
if (!fs.existsSync(knowledgeBasePath)) {
|
|
119
|
+
throw new NavigatorLoadError(`Knowledge base directory not found: ${knowledgeBasePath}`, {
|
|
120
|
+
missingDirectory: knowledgeBasePath,
|
|
121
|
+
suggestion: "Navigator requires a knowledge-base directory with documentation files.",
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
const stats = fs.statSync(knowledgeBasePath);
|
|
125
|
+
if (!stats.isDirectory()) {
|
|
126
|
+
throw new NavigatorLoadError(`Knowledge base path is not a directory: ${knowledgeBasePath}`);
|
|
127
|
+
}
|
|
128
|
+
// Check if knowledge base has any files
|
|
129
|
+
const files = fs.readdirSync(knowledgeBasePath);
|
|
130
|
+
if (files.length === 0) {
|
|
131
|
+
console.warn(`⚠ Warning: Knowledge base is empty: ${knowledgeBasePath}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Find similar navigators in the current directory
|
|
136
|
+
* (for error messages with suggestions)
|
|
137
|
+
*/
|
|
138
|
+
function findSimilarNavigators(cwd) {
|
|
139
|
+
try {
|
|
140
|
+
const entries = fs.readdirSync(cwd, { withFileTypes: true });
|
|
141
|
+
const navigators = [];
|
|
142
|
+
for (const entry of entries) {
|
|
143
|
+
if (entry.isDirectory()) {
|
|
144
|
+
const configPath = path.join(cwd, entry.name, "config.json");
|
|
145
|
+
if (fs.existsSync(configPath)) {
|
|
146
|
+
navigators.push(entry.name);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return navigators;
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
return [];
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Navigator load error with additional context
|
|
158
|
+
*/
|
|
159
|
+
export class NavigatorLoadError extends Error {
|
|
160
|
+
context;
|
|
161
|
+
constructor(message, context) {
|
|
162
|
+
super(message);
|
|
163
|
+
this.context = context;
|
|
164
|
+
this.name = "NavigatorLoadError";
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=navigator-loader.js.map
|
|
@@ -0,0 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0B;QAGxC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { NavigatorResponse } from "@autonav/communication-layer";
|
|
2
|
+
/**
|
|
3
|
+
* Output format mode
|
|
4
|
+
*/
|
|
5
|
+
export type OutputFormat = "pretty" | "compact" | "json";
|
|
6
|
+
/**
|
|
7
|
+
* Output formatting options
|
|
8
|
+
*/
|
|
9
|
+
export interface OutputFormatOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Output format mode
|
|
12
|
+
*/
|
|
13
|
+
format: OutputFormat;
|
|
14
|
+
/**
|
|
15
|
+
* Disable colored output
|
|
16
|
+
*/
|
|
17
|
+
noColor?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Show verbose information (debug mode)
|
|
20
|
+
*/
|
|
21
|
+
verbose?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Format a navigator response for display
|
|
25
|
+
*
|
|
26
|
+
* @param response - Navigator response to format
|
|
27
|
+
* @param options - Formatting options
|
|
28
|
+
* @returns Formatted string for display
|
|
29
|
+
*/
|
|
30
|
+
export declare function formatResponse(response: NavigatorResponse, options: OutputFormatOptions): string;
|
|
31
|
+
/**
|
|
32
|
+
* Format loading message
|
|
33
|
+
*/
|
|
34
|
+
export declare function formatLoadingMessage(navigatorName: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Format query message
|
|
37
|
+
*/
|
|
38
|
+
export declare function formatQueryMessage(question: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Format success message
|
|
41
|
+
*/
|
|
42
|
+
export declare function formatSuccessMessage(sourcesCount: number): string;
|
|
43
|
+
/**
|
|
44
|
+
* Format error message
|
|
45
|
+
*/
|
|
46
|
+
export declare function formatErrorMessage(error: Error | string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Format warning message
|
|
49
|
+
*/
|
|
50
|
+
export declare function formatWarningMessage(message: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Create a suggestion message with helpful text
|
|
53
|
+
*/
|
|
54
|
+
export declare function formatSuggestion(title: string, suggestions: string[]): string;
|
|
55
|
+
//# sourceMappingURL=output-formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-formatter.d.ts","sourceRoot":"","sources":["../../src/query-engine/output-formatter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAwB,MAAM,8BAA8B,CAAC;AAEvF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,MAAM,EAAE,YAAY,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,mBAAmB,GAC3B,MAAM,CAeR;AA8HD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAGhE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EAAE,GACpB,MAAM,CAOR"}
|