lemura 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.
Files changed (62) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/LICENSE +21 -0
  3. package/README.md +143 -0
  4. package/dist/adapters/index.d.mts +45 -0
  5. package/dist/adapters/index.d.ts +45 -0
  6. package/dist/adapters/index.js +371 -0
  7. package/dist/adapters/index.js.map +1 -0
  8. package/dist/adapters/index.mjs +369 -0
  9. package/dist/adapters/index.mjs.map +1 -0
  10. package/dist/adapters-BSkhv5ac.d.ts +208 -0
  11. package/dist/adapters-BnG0LEYD.d.mts +208 -0
  12. package/dist/context/index.d.mts +143 -0
  13. package/dist/context/index.d.ts +143 -0
  14. package/dist/context/index.js +321 -0
  15. package/dist/context/index.js.map +1 -0
  16. package/dist/context/index.mjs +314 -0
  17. package/dist/context/index.mjs.map +1 -0
  18. package/dist/index.d.mts +91 -0
  19. package/dist/index.d.ts +91 -0
  20. package/dist/index.js +1375 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/index.mjs +1348 -0
  23. package/dist/index.mjs.map +1 -0
  24. package/dist/logger/index.d.mts +19 -0
  25. package/dist/logger/index.d.ts +19 -0
  26. package/dist/logger/index.js +67 -0
  27. package/dist/logger/index.js.map +1 -0
  28. package/dist/logger/index.mjs +65 -0
  29. package/dist/logger/index.mjs.map +1 -0
  30. package/dist/logger-DxvKliuk.d.mts +37 -0
  31. package/dist/logger-DxvKliuk.d.ts +37 -0
  32. package/dist/rag/index.d.mts +10 -0
  33. package/dist/rag/index.d.ts +10 -0
  34. package/dist/rag/index.js +43 -0
  35. package/dist/rag/index.js.map +1 -0
  36. package/dist/rag/index.mjs +41 -0
  37. package/dist/rag/index.mjs.map +1 -0
  38. package/dist/rag-La_Bo-J8.d.mts +45 -0
  39. package/dist/rag-La_Bo-J8.d.ts +45 -0
  40. package/dist/skills/index.d.mts +15 -0
  41. package/dist/skills/index.d.ts +15 -0
  42. package/dist/skills/index.js +40 -0
  43. package/dist/skills/index.js.map +1 -0
  44. package/dist/skills/index.mjs +38 -0
  45. package/dist/skills/index.mjs.map +1 -0
  46. package/dist/skills-wc8S-OvC.d.mts +14 -0
  47. package/dist/skills-wc8S-OvC.d.ts +14 -0
  48. package/dist/storage-BGu4Loao.d.ts +121 -0
  49. package/dist/storage-DMcliVVj.d.mts +121 -0
  50. package/dist/tools/index.d.mts +17 -0
  51. package/dist/tools/index.d.ts +17 -0
  52. package/dist/tools/index.js +72 -0
  53. package/dist/tools/index.js.map +1 -0
  54. package/dist/tools/index.mjs +70 -0
  55. package/dist/tools/index.mjs.map +1 -0
  56. package/dist/types/index.d.mts +118 -0
  57. package/dist/types/index.d.ts +118 -0
  58. package/dist/types/index.js +84 -0
  59. package/dist/types/index.js.map +1 -0
  60. package/dist/types/index.mjs +74 -0
  61. package/dist/types/index.mjs.map +1 -0
  62. package/package.json +79 -0
@@ -0,0 +1,70 @@
1
+ // src/types/errors.ts
2
+ var LemuraError = class extends Error {
3
+ /**
4
+ * @param message - The error message
5
+ * @param code - The error code for programmatic handling
6
+ * @param problem - A clear description of the problem for the end user
7
+ * @param hints - A list of suggestions to resolve the issue
8
+ */
9
+ constructor(message, code, problem, hints = []) {
10
+ super(message);
11
+ this.code = code;
12
+ this.problem = problem;
13
+ this.hints = hints;
14
+ this.name = "LemuraError";
15
+ Object.setPrototypeOf(this, new.target.prototype);
16
+ }
17
+ };
18
+ var LemuraToolNotFoundError = class extends LemuraError {
19
+ constructor(message) {
20
+ super(message, "TOOL_NOT_FOUND");
21
+ this.name = "LemuraToolNotFoundError";
22
+ }
23
+ };
24
+ var LemuraToolValidationError = class extends LemuraError {
25
+ constructor(message) {
26
+ super(message, "TOOL_VALIDATION_FAILED");
27
+ this.name = "LemuraToolValidationError";
28
+ }
29
+ };
30
+
31
+ // src/tools/ToolRegistry.ts
32
+ var ToolRegistry = class {
33
+ tools = /* @__PURE__ */ new Map();
34
+ constructor(initialTools = []) {
35
+ for (const tool of initialTools) {
36
+ this.register(tool);
37
+ }
38
+ }
39
+ register(tool) {
40
+ if (this.tools.has(tool.name)) {
41
+ throw new Error(`Tool ${tool.name} is already registered.`);
42
+ }
43
+ this.tools.set(tool.name, tool);
44
+ }
45
+ get(name) {
46
+ return this.tools.get(name);
47
+ }
48
+ getAll() {
49
+ return Array.from(this.tools.values());
50
+ }
51
+ async execute(name, params, context) {
52
+ const tool = this.tools.get(name);
53
+ if (!tool) {
54
+ throw new LemuraToolNotFoundError(`Tool '${name}' not found.`);
55
+ }
56
+ try {
57
+ const result = await tool.execute(params, context);
58
+ return result;
59
+ } catch (err) {
60
+ if (err instanceof LemuraToolValidationError) {
61
+ throw err;
62
+ }
63
+ throw new Error(`Tool execution failed for '${name}': ${err.message}`);
64
+ }
65
+ }
66
+ };
67
+
68
+ export { ToolRegistry };
69
+ //# sourceMappingURL=index.mjs.map
70
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/types/errors.ts","../../src/tools/ToolRegistry.ts"],"names":[],"mappings":";AAMO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOnC,YACI,OAAA,EACgB,IAAA,EACA,OAAA,EACA,KAAA,GAAkB,EAAC,EACrC;AACE,IAAA,KAAA,CAAM,OAAO,CAAA;AAJG,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AACA,IAAA,IAAA,CAAA,KAAA,GAAA,KAAA;AAGhB,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAAA,EACpD;AACJ,CAAA;AAWO,IAAM,uBAAA,GAAN,cAAsC,WAAA,CAAY;AAAA,EACrD,YAAY,OAAA,EAAiB;AACzB,IAAA,KAAA,CA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AC,IAAA,EAAM;AACP,MAAA,MAAM,IAAI,uBAAA,CAAwB,CAAA,MAAA,EAAS,IAAI,CAAA,YAAA,CAAc,CAAA;AAAA,IACjE;AAEA,IAAA,IAAI;AAGA,MAAA,MAAM,MAAA,GAAS,MAAM,IAAA,CAAK,OAAA,CAAQ,QAAQ,OAAO,CAAA;AACjD,MAAA,OAAO,MAAA;AAAA,IACX,SAAS,GAAA,EAAU;AACf,MAAA,IAAI,eAAe,yBAAA,EAA2B;AAC1C,QAAA,MAAM,GAAA;AAAA,MACV;AACA,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,2BAAA,EAA8B,IAAI,CAAA,GAAA,EAAM,GAAA,CAAI,OAAO,CAAA,CAAE,CAAA;AAAA,IACzE;AAAA,EACJ;AACJ","file":"index.mjs","sourcesContent":["/**\n * Base class for all custom errors thrown by lemura.\n *\n * @example\n * throw new LemuraError('Something went wrong', 'UNKNOWN_ERROR');\n */\nexport class LemuraError extends Error {\n /**\n * @param message - The error message\n * @param code - The error code for programmatic handling\n * @param problem - A clear description of the problem for the end user\n * @param hints - A list of suggestions to resolve the issue\n */\n constructor(\n message: string,\n public readonly code: string,\n public readonly problem?: string,\n public readonly hints: string[] = []\n ) {\n super(message);\n this.name = 'LemuraError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Error thrown when context exceeds max tokens and cannot be compressed further */\nexport class LemuraContextOverflowError extends LemuraError {\n constructor(message: string) {\n super(message, 'CONTEXT_OVERFLOW');\n this.name = 'LemuraContextOverflowError';\n }\n}\n\n/** Error thrown when a requested tool is not found in the registry */\nexport class LemuraToolNotFoundError extends LemuraError {\n constructor(message: string) {\n super(message, 'TOOL_NOT_FOUND');\n this.name = 'LemuraToolNotFoundError';\n }\n}\n\n/** Error thrown when an adapter encounters an API or formatting issue */\nexport class LemuraAdapterError extends LemuraError {\n constructor(\n message: string,\n code = 'ADAPTER_ERROR',\n public cause?: any,\n problem?: string,\n hints: string[] = []\n ) {\n super(message, code, problem, hints);\n this.name = 'LemuraAdapterError';\n }\n}\n\n/** Error thrown when a skill cannot be parsed or injected */\nexport class LemuraSkillInjectionError extends LemuraError {\n constructor(message: string) {\n super(message, 'SKILL_INJECTION_FAILED');\n this.name = 'LemuraSkillInjectionError';\n }\n}\n\n/** Error thrown when the ReAct loop exceeds the configured max iterations */\nexport class LemuraMaxIterationsError extends LemuraError {\n constructor(message: string) {\n super(message, 'MAX_ITERATIONS_EXCEEDED');\n this.name = 'LemuraMaxIterationsError';\n }\n}\n\n/** Error thrown when tool parameters fail JSON schema validation */\nexport class LemuraToolValidationError extends LemuraError {\n constructor(message: string) {\n super(message, 'TOOL_VALIDATION_FAILED');\n this.name = 'LemuraToolValidationError';\n }\n}\n\n/** Error thrown when a tool execute function exceeds its timeout */\nexport class LemuraToolTimeoutError extends LemuraError {\n constructor(message: string) {\n super(message, 'TOOL_TIMEOUT');\n this.name = 'LemuraToolTimeoutError';\n }\n}\n","import { IToolDefinition, LemuraToolNotFoundError, LemuraToolValidationError, ToolContext } from '../types/index.js';\n\n/**\n * Manages registered tools and their execution\n */\nexport class ToolRegistry {\n private tools: Map<string, IToolDefinition> = new Map();\n\n constructor(initialTools: IToolDefinition[] = []) {\n for (const tool of initialTools) {\n this.register(tool);\n }\n }\n\n register(tool: IToolDefinition): void {\n if (this.tools.has(tool.name)) {\n throw new Error(`Tool ${tool.name} is already registered.`);\n }\n this.tools.set(tool.name, tool);\n }\n\n get(name: string): IToolDefinition | undefined {\n return this.tools.get(name);\n }\n\n getAll(): IToolDefinition[] {\n return Array.from(this.tools.values());\n }\n\n async execute(name: string, params: unknown, context: ToolContext): Promise<unknown> {\n const tool = this.tools.get(name);\n if (!tool) {\n throw new LemuraToolNotFoundError(`Tool '${name}' not found.`);\n }\n\n try {\n // Basic JSON schema validation logic goes here\n // Real implementation would use Ajv or similar to validate `params` against `tool.parameters`\n const result = await tool.execute(params, context);\n return result;\n } catch (err: any) {\n if (err instanceof LemuraToolValidationError) {\n throw err;\n }\n throw new Error(`Tool execution failed for '${name}': ${err.message}`);\n }\n }\n}\n"]}
@@ -0,0 +1,118 @@
1
+ import { e as IProviderAdapter, I as IContextStrategy } from '../adapters-BnG0LEYD.mjs';
2
+ export { A as AudioChunk, b as CompletionChunk, c as CompletionRequest, d as CompletionResponse, a as ContentBlock, C as ContextWindow, f as ImageGenRequest, g as ImageGenResponse, M as ModelInfo, N as NormalizedMessage, S as SynthesisRequest, h as TokenUsage, i as ToolCall, j as ToolResult, k as TranscriptionRequest, l as TranscriptionResponse, T as Turn, V as VisionRequest, m as VisionResponse } from '../adapters-BnG0LEYD.mjs';
3
+ import { I as IToolDefinition, c as ShortTermMemoryRegistry } from '../storage-DMcliVVj.mjs';
4
+ export { a as IStorageAdapter, S as STMItem, T as ToolContext } from '../storage-DMcliVVj.mjs';
5
+ import { I as ILogger } from '../logger-DxvKliuk.mjs';
6
+ export { L as LogLevel, a as LogMetadata, S as Severity } from '../logger-DxvKliuk.mjs';
7
+ import { I as ISkill } from '../skills-wc8S-OvC.mjs';
8
+ import { I as IRAGAdapter } from '../rag-La_Bo-J8.mjs';
9
+ export { R as RAGDocument, a as RAGIngestOptions, b as RAGIngestRequest, c as RAGIngestResponse, d as RAGQueryRequest, e as RAGQueryResponse, f as RAGResult } from '../rag-La_Bo-J8.mjs';
10
+
11
+ interface ToolResponseEvaluation {
12
+ relevanceScore: number;
13
+ sizeClass: 'small' | 'medium' | 'large' | 'oversized';
14
+ shouldCompress: boolean;
15
+ suggestedMaxTokens: number;
16
+ answered: boolean;
17
+ answeredPartially: boolean;
18
+ errorDetected: boolean;
19
+ suggestedAction: 'continue' | 'retry' | 'retry_with_params' | 'skip' | 'escalate';
20
+ }
21
+ interface IToolResponseProcessor {
22
+ evaluate(response: string, tool: IToolDefinition, context: unknown): ToolResponseEvaluation;
23
+ compress(response: string, evaluation: ToolResponseEvaluation): string;
24
+ }
25
+ /** Configuration for a lemura Session */
26
+ interface SessionConfig {
27
+ /** The provider adapter to use */
28
+ adapter: IProviderAdapter;
29
+ /** Model string */
30
+ model: string;
31
+ /** Max context tokens */
32
+ maxTokens: number;
33
+ /** Max ReAct cycles */
34
+ maxIterations?: number;
35
+ /** Explicit tools */
36
+ tools?: IToolDefinition[];
37
+ /** Explicit skills */
38
+ skills?: ISkill[];
39
+ /** RAG adapter */
40
+ ragAdapter?: IRAGAdapter;
41
+ /** Context compression strategies */
42
+ compressionStrategies?: IContextStrategy[];
43
+ /** System prompt base */
44
+ systemPrompt?: string;
45
+ /** Logger */
46
+ logger?: ILogger;
47
+ /** Budget for tool responses before compression */
48
+ toolResponseTokenBudget?: number;
49
+ /** Processor for tool responses */
50
+ toolResponseProcessor?: IToolResponseProcessor;
51
+ /** Max single steps (tool calls) */
52
+ maxSteps?: number;
53
+ /** Enable tool continuation planning */
54
+ enableContinuationPlanning?: boolean;
55
+ continuationStrategy?: 'sequential' | 'parallel' | 'conditional';
56
+ /** Enable goal planning */
57
+ enableGoalPlanning?: boolean;
58
+ goalInjectionFrequency?: 'always' | 'every_N_turns' | 'on_compression';
59
+ goalInjectionPosition?: 'system_prompt' | 'pre_turn';
60
+ /** Skill budget */
61
+ skillTokenBudget?: number;
62
+ /** Callback for each turn in the session */
63
+ onTurn?: (turn: any) => void;
64
+ /** Short Term Memory Registry */
65
+ stmRegistry?: ShortTermMemoryRegistry;
66
+ /** Max tokens allowed for a single tool response */
67
+ maxTokensPerTool?: number;
68
+ }
69
+
70
+ /**
71
+ * Base class for all custom errors thrown by lemura.
72
+ *
73
+ * @example
74
+ * throw new LemuraError('Something went wrong', 'UNKNOWN_ERROR');
75
+ */
76
+ declare class LemuraError extends Error {
77
+ readonly code: string;
78
+ readonly problem?: string | undefined;
79
+ readonly hints: string[];
80
+ /**
81
+ * @param message - The error message
82
+ * @param code - The error code for programmatic handling
83
+ * @param problem - A clear description of the problem for the end user
84
+ * @param hints - A list of suggestions to resolve the issue
85
+ */
86
+ constructor(message: string, code: string, problem?: string | undefined, hints?: string[]);
87
+ }
88
+ /** Error thrown when context exceeds max tokens and cannot be compressed further */
89
+ declare class LemuraContextOverflowError extends LemuraError {
90
+ constructor(message: string);
91
+ }
92
+ /** Error thrown when a requested tool is not found in the registry */
93
+ declare class LemuraToolNotFoundError extends LemuraError {
94
+ constructor(message: string);
95
+ }
96
+ /** Error thrown when an adapter encounters an API or formatting issue */
97
+ declare class LemuraAdapterError extends LemuraError {
98
+ cause?: any | undefined;
99
+ constructor(message: string, code?: string, cause?: any | undefined, problem?: string, hints?: string[]);
100
+ }
101
+ /** Error thrown when a skill cannot be parsed or injected */
102
+ declare class LemuraSkillInjectionError extends LemuraError {
103
+ constructor(message: string);
104
+ }
105
+ /** Error thrown when the ReAct loop exceeds the configured max iterations */
106
+ declare class LemuraMaxIterationsError extends LemuraError {
107
+ constructor(message: string);
108
+ }
109
+ /** Error thrown when tool parameters fail JSON schema validation */
110
+ declare class LemuraToolValidationError extends LemuraError {
111
+ constructor(message: string);
112
+ }
113
+ /** Error thrown when a tool execute function exceeds its timeout */
114
+ declare class LemuraToolTimeoutError extends LemuraError {
115
+ constructor(message: string);
116
+ }
117
+
118
+ export { IContextStrategy, ILogger, IProviderAdapter, IRAGAdapter, ISkill, IToolDefinition, type IToolResponseProcessor, LemuraAdapterError, LemuraContextOverflowError, LemuraError, LemuraMaxIterationsError, LemuraSkillInjectionError, LemuraToolNotFoundError, LemuraToolTimeoutError, LemuraToolValidationError, type SessionConfig, type ToolResponseEvaluation };
@@ -0,0 +1,118 @@
1
+ import { e as IProviderAdapter, I as IContextStrategy } from '../adapters-BSkhv5ac.js';
2
+ export { A as AudioChunk, b as CompletionChunk, c as CompletionRequest, d as CompletionResponse, a as ContentBlock, C as ContextWindow, f as ImageGenRequest, g as ImageGenResponse, M as ModelInfo, N as NormalizedMessage, S as SynthesisRequest, h as TokenUsage, i as ToolCall, j as ToolResult, k as TranscriptionRequest, l as TranscriptionResponse, T as Turn, V as VisionRequest, m as VisionResponse } from '../adapters-BSkhv5ac.js';
3
+ import { I as IToolDefinition, c as ShortTermMemoryRegistry } from '../storage-BGu4Loao.js';
4
+ export { a as IStorageAdapter, S as STMItem, T as ToolContext } from '../storage-BGu4Loao.js';
5
+ import { I as ILogger } from '../logger-DxvKliuk.js';
6
+ export { L as LogLevel, a as LogMetadata, S as Severity } from '../logger-DxvKliuk.js';
7
+ import { I as ISkill } from '../skills-wc8S-OvC.js';
8
+ import { I as IRAGAdapter } from '../rag-La_Bo-J8.js';
9
+ export { R as RAGDocument, a as RAGIngestOptions, b as RAGIngestRequest, c as RAGIngestResponse, d as RAGQueryRequest, e as RAGQueryResponse, f as RAGResult } from '../rag-La_Bo-J8.js';
10
+
11
+ interface ToolResponseEvaluation {
12
+ relevanceScore: number;
13
+ sizeClass: 'small' | 'medium' | 'large' | 'oversized';
14
+ shouldCompress: boolean;
15
+ suggestedMaxTokens: number;
16
+ answered: boolean;
17
+ answeredPartially: boolean;
18
+ errorDetected: boolean;
19
+ suggestedAction: 'continue' | 'retry' | 'retry_with_params' | 'skip' | 'escalate';
20
+ }
21
+ interface IToolResponseProcessor {
22
+ evaluate(response: string, tool: IToolDefinition, context: unknown): ToolResponseEvaluation;
23
+ compress(response: string, evaluation: ToolResponseEvaluation): string;
24
+ }
25
+ /** Configuration for a lemura Session */
26
+ interface SessionConfig {
27
+ /** The provider adapter to use */
28
+ adapter: IProviderAdapter;
29
+ /** Model string */
30
+ model: string;
31
+ /** Max context tokens */
32
+ maxTokens: number;
33
+ /** Max ReAct cycles */
34
+ maxIterations?: number;
35
+ /** Explicit tools */
36
+ tools?: IToolDefinition[];
37
+ /** Explicit skills */
38
+ skills?: ISkill[];
39
+ /** RAG adapter */
40
+ ragAdapter?: IRAGAdapter;
41
+ /** Context compression strategies */
42
+ compressionStrategies?: IContextStrategy[];
43
+ /** System prompt base */
44
+ systemPrompt?: string;
45
+ /** Logger */
46
+ logger?: ILogger;
47
+ /** Budget for tool responses before compression */
48
+ toolResponseTokenBudget?: number;
49
+ /** Processor for tool responses */
50
+ toolResponseProcessor?: IToolResponseProcessor;
51
+ /** Max single steps (tool calls) */
52
+ maxSteps?: number;
53
+ /** Enable tool continuation planning */
54
+ enableContinuationPlanning?: boolean;
55
+ continuationStrategy?: 'sequential' | 'parallel' | 'conditional';
56
+ /** Enable goal planning */
57
+ enableGoalPlanning?: boolean;
58
+ goalInjectionFrequency?: 'always' | 'every_N_turns' | 'on_compression';
59
+ goalInjectionPosition?: 'system_prompt' | 'pre_turn';
60
+ /** Skill budget */
61
+ skillTokenBudget?: number;
62
+ /** Callback for each turn in the session */
63
+ onTurn?: (turn: any) => void;
64
+ /** Short Term Memory Registry */
65
+ stmRegistry?: ShortTermMemoryRegistry;
66
+ /** Max tokens allowed for a single tool response */
67
+ maxTokensPerTool?: number;
68
+ }
69
+
70
+ /**
71
+ * Base class for all custom errors thrown by lemura.
72
+ *
73
+ * @example
74
+ * throw new LemuraError('Something went wrong', 'UNKNOWN_ERROR');
75
+ */
76
+ declare class LemuraError extends Error {
77
+ readonly code: string;
78
+ readonly problem?: string | undefined;
79
+ readonly hints: string[];
80
+ /**
81
+ * @param message - The error message
82
+ * @param code - The error code for programmatic handling
83
+ * @param problem - A clear description of the problem for the end user
84
+ * @param hints - A list of suggestions to resolve the issue
85
+ */
86
+ constructor(message: string, code: string, problem?: string | undefined, hints?: string[]);
87
+ }
88
+ /** Error thrown when context exceeds max tokens and cannot be compressed further */
89
+ declare class LemuraContextOverflowError extends LemuraError {
90
+ constructor(message: string);
91
+ }
92
+ /** Error thrown when a requested tool is not found in the registry */
93
+ declare class LemuraToolNotFoundError extends LemuraError {
94
+ constructor(message: string);
95
+ }
96
+ /** Error thrown when an adapter encounters an API or formatting issue */
97
+ declare class LemuraAdapterError extends LemuraError {
98
+ cause?: any | undefined;
99
+ constructor(message: string, code?: string, cause?: any | undefined, problem?: string, hints?: string[]);
100
+ }
101
+ /** Error thrown when a skill cannot be parsed or injected */
102
+ declare class LemuraSkillInjectionError extends LemuraError {
103
+ constructor(message: string);
104
+ }
105
+ /** Error thrown when the ReAct loop exceeds the configured max iterations */
106
+ declare class LemuraMaxIterationsError extends LemuraError {
107
+ constructor(message: string);
108
+ }
109
+ /** Error thrown when tool parameters fail JSON schema validation */
110
+ declare class LemuraToolValidationError extends LemuraError {
111
+ constructor(message: string);
112
+ }
113
+ /** Error thrown when a tool execute function exceeds its timeout */
114
+ declare class LemuraToolTimeoutError extends LemuraError {
115
+ constructor(message: string);
116
+ }
117
+
118
+ export { IContextStrategy, ILogger, IProviderAdapter, IRAGAdapter, ISkill, IToolDefinition, type IToolResponseProcessor, LemuraAdapterError, LemuraContextOverflowError, LemuraError, LemuraMaxIterationsError, LemuraSkillInjectionError, LemuraToolNotFoundError, LemuraToolTimeoutError, LemuraToolValidationError, type SessionConfig, type ToolResponseEvaluation };
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+
3
+ // src/types/errors.ts
4
+ var LemuraError = class extends Error {
5
+ /**
6
+ * @param message - The error message
7
+ * @param code - The error code for programmatic handling
8
+ * @param problem - A clear description of the problem for the end user
9
+ * @param hints - A list of suggestions to resolve the issue
10
+ */
11
+ constructor(message, code, problem, hints = []) {
12
+ super(message);
13
+ this.code = code;
14
+ this.problem = problem;
15
+ this.hints = hints;
16
+ this.name = "LemuraError";
17
+ Object.setPrototypeOf(this, new.target.prototype);
18
+ }
19
+ };
20
+ var LemuraContextOverflowError = class extends LemuraError {
21
+ constructor(message) {
22
+ super(message, "CONTEXT_OVERFLOW");
23
+ this.name = "LemuraContextOverflowError";
24
+ }
25
+ };
26
+ var LemuraToolNotFoundError = class extends LemuraError {
27
+ constructor(message) {
28
+ super(message, "TOOL_NOT_FOUND");
29
+ this.name = "LemuraToolNotFoundError";
30
+ }
31
+ };
32
+ var LemuraAdapterError = class extends LemuraError {
33
+ constructor(message, code = "ADAPTER_ERROR", cause, problem, hints = []) {
34
+ super(message, code, problem, hints);
35
+ this.cause = cause;
36
+ this.name = "LemuraAdapterError";
37
+ }
38
+ };
39
+ var LemuraSkillInjectionError = class extends LemuraError {
40
+ constructor(message) {
41
+ super(message, "SKILL_INJECTION_FAILED");
42
+ this.name = "LemuraSkillInjectionError";
43
+ }
44
+ };
45
+ var LemuraMaxIterationsError = class extends LemuraError {
46
+ constructor(message) {
47
+ super(message, "MAX_ITERATIONS_EXCEEDED");
48
+ this.name = "LemuraMaxIterationsError";
49
+ }
50
+ };
51
+ var LemuraToolValidationError = class extends LemuraError {
52
+ constructor(message) {
53
+ super(message, "TOOL_VALIDATION_FAILED");
54
+ this.name = "LemuraToolValidationError";
55
+ }
56
+ };
57
+ var LemuraToolTimeoutError = class extends LemuraError {
58
+ constructor(message) {
59
+ super(message, "TOOL_TIMEOUT");
60
+ this.name = "LemuraToolTimeoutError";
61
+ }
62
+ };
63
+
64
+ // src/types/logger.ts
65
+ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
66
+ LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
67
+ LogLevel2[LogLevel2["INFO"] = 1] = "INFO";
68
+ LogLevel2[LogLevel2["WARN"] = 2] = "WARN";
69
+ LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";
70
+ LogLevel2[LogLevel2["FATAL"] = 4] = "FATAL";
71
+ return LogLevel2;
72
+ })(LogLevel || {});
73
+
74
+ exports.LemuraAdapterError = LemuraAdapterError;
75
+ exports.LemuraContextOverflowError = LemuraContextOverflowError;
76
+ exports.LemuraError = LemuraError;
77
+ exports.LemuraMaxIterationsError = LemuraMaxIterationsError;
78
+ exports.LemuraSkillInjectionError = LemuraSkillInjectionError;
79
+ exports.LemuraToolNotFoundError = LemuraToolNotFoundError;
80
+ exports.LemuraToolTimeoutError = LemuraToolTimeoutError;
81
+ exports.LemuraToolValidationError = LemuraToolValidationError;
82
+ exports.LogLevel = LogLevel;
83
+ //# sourceMappingURL=index.js.map
84
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/types/errors.ts","../../src/types/logger.ts"],"names":["LogLevel"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AAA,KAAA,CAAM,SAAS,wBAAwB,CAAA;AACvC,IAAA,IAAA,CAAK,IAAA,GAAO,2BAAA;AAAA,EAChB;AACJ;AAGO,IAAM,wBAAA,GAAN,cAAuC,WAAA,CAAY;AAAA,EACtD,YAAY,OAAA,EAAiB;AACzB,IAAA,KAAA,CAAM,SAAS,yBAAyB,CAAA;AACxC,IAAA,IAAA,CAAK,IAAA,GAAO,0BAAA;AAAA,EAChB;AACJ;AAGO,IAAM,yBAAA,GAAN,cAAwC,WAAA,CAAY;AAAA,EACvD,YAAY,OAAA,EAAiB;AACzB,IAAA,KAAA,CAAM,SAAS,wBAAwB,CAAA;AACvC,IAAA,IAAA,CAAK,IAAA,GAAO,2BAAA;AAAA,EAChB;AACJ;AAGO,IAAM,sBAAA,GAAN,cAAqC,WAAA,CAAY;AAAA,EACpD,YAAY,OAAA,EAAiB;AACzB,IAAA,KAAA,CAAM,SAAS,cAAc,CAAA;AAC7B,IAAA,IAAA,CAAK,IAAA,GAAO,wBAAA;AAAA,EAChB;AACJ;;;ACpFO,IAAK,QAAA,qBAAAA,SAAAA,KAAL;AACH,EAAAA,SAAAA,CAAAA,SAAAA,CAAA,WAAQ,CAAA,CAAA,GAAR,OAAA;AACA,EAAAA,SAAAA,CAAAA,SAAAA,CAAA,UAAO,CAAA,CAAA,GAAP,MAAA;AACA,EAAAA,SAAAA,CAAAA,SAAAA,CAAA,UAAO,CAAA,CAAA,GAAP,MAAA;AACA,EAAAA,SAAAA,CAAAA,SAAAA,CAAA,WAAQ,CAAA,CAAA,GAAR,OAAA;AACA,EAAAA,SAAAA,CAAAA,SAAAA,CAAA,WAAQ,CAAA,CAAA,GAAR,OAAA;AALQ,EAAA,OAAAA,SAAAA;AAAA,CAAA,EAAA,QAAA,IAAA,EAAA","file":"index.js","sourcesContent":["/**\n * Base class for all custom errors thrown by lemura.\n *\n * @example\n * throw new LemuraError('Something went wrong', 'UNKNOWN_ERROR');\n */\nexport class LemuraError extends Error {\n /**\n * @param message - The error message\n * @param code - The error code for programmatic handling\n * @param problem - A clear description of the problem for the end user\n * @param hints - A list of suggestions to resolve the issue\n */\n constructor(\n message: string,\n public readonly code: string,\n public readonly problem?: string,\n public readonly hints: string[] = []\n ) {\n super(message);\n this.name = 'LemuraError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Error thrown when context exceeds max tokens and cannot be compressed further */\nexport class LemuraContextOverflowError extends LemuraError {\n constructor(message: string) {\n super(message, 'CONTEXT_OVERFLOW');\n this.name = 'LemuraContextOverflowError';\n }\n}\n\n/** Error thrown when a requested tool is not found in the registry */\nexport class LemuraToolNotFoundError extends LemuraError {\n constructor(message: string) {\n super(message, 'TOOL_NOT_FOUND');\n this.name = 'LemuraToolNotFoundError';\n }\n}\n\n/** Error thrown when an adapter encounters an API or formatting issue */\nexport class LemuraAdapterError extends LemuraError {\n constructor(\n message: string,\n code = 'ADAPTER_ERROR',\n public cause?: any,\n problem?: string,\n hints: string[] = []\n ) {\n super(message, code, problem, hints);\n this.name = 'LemuraAdapterError';\n }\n}\n\n/** Error thrown when a skill cannot be parsed or injected */\nexport class LemuraSkillInjectionError extends LemuraError {\n constructor(message: string) {\n super(message, 'SKILL_INJECTION_FAILED');\n this.name = 'LemuraSkillInjectionError';\n }\n}\n\n/** Error thrown when the ReAct loop exceeds the configured max iterations */\nexport class LemuraMaxIterationsError extends LemuraError {\n constructor(message: string) {\n super(message, 'MAX_ITERATIONS_EXCEEDED');\n this.name = 'LemuraMaxIterationsError';\n }\n}\n\n/** Error thrown when tool parameters fail JSON schema validation */\nexport class LemuraToolValidationError extends LemuraError {\n constructor(message: string) {\n super(message, 'TOOL_VALIDATION_FAILED');\n this.name = 'LemuraToolValidationError';\n }\n}\n\n/** Error thrown when a tool execute function exceeds its timeout */\nexport class LemuraToolTimeoutError extends LemuraError {\n constructor(message: string) {\n super(message, 'TOOL_TIMEOUT');\n this.name = 'LemuraToolTimeoutError';\n }\n}\n","/** Log levels supported by lemura */\nexport enum LogLevel {\n DEBUG = 0,\n INFO = 1,\n WARN = 2,\n ERROR = 3,\n FATAL = 4,\n}\n\n/** Severity levels for user-facing logs */\nexport type Severity = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'FATAL';\n\n/** Metadata for structured logging and error reporting */\nexport interface LogMetadata {\n problem?: string;\n hints?: string[];\n severity?: Severity;\n [key: string]: unknown;\n}\n\n/**\n * Enhanced logger interface for lemura.\n * Supports structured logging with problems and hints.\n */\nexport interface ILogger {\n /** Log a debug message (trace-level details) */\n debug(message: string, metadata?: LogMetadata): void;\n /** Log an informational message */\n info(message: string, metadata?: LogMetadata): void;\n /** Log a warning */\n warn(message: string, metadata?: LogMetadata): void;\n /** Log an error */\n error(message: string, metadata?: LogMetadata): void;\n /** Log a fatal error that prevents execution */\n fatal(message: string, metadata?: LogMetadata): void;\n\n /** Set the minimum log level to display */\n setLevel(level: LogLevel): void;\n}\n"]}
@@ -0,0 +1,74 @@
1
+ // src/types/errors.ts
2
+ var LemuraError = class extends Error {
3
+ /**
4
+ * @param message - The error message
5
+ * @param code - The error code for programmatic handling
6
+ * @param problem - A clear description of the problem for the end user
7
+ * @param hints - A list of suggestions to resolve the issue
8
+ */
9
+ constructor(message, code, problem, hints = []) {
10
+ super(message);
11
+ this.code = code;
12
+ this.problem = problem;
13
+ this.hints = hints;
14
+ this.name = "LemuraError";
15
+ Object.setPrototypeOf(this, new.target.prototype);
16
+ }
17
+ };
18
+ var LemuraContextOverflowError = class extends LemuraError {
19
+ constructor(message) {
20
+ super(message, "CONTEXT_OVERFLOW");
21
+ this.name = "LemuraContextOverflowError";
22
+ }
23
+ };
24
+ var LemuraToolNotFoundError = class extends LemuraError {
25
+ constructor(message) {
26
+ super(message, "TOOL_NOT_FOUND");
27
+ this.name = "LemuraToolNotFoundError";
28
+ }
29
+ };
30
+ var LemuraAdapterError = class extends LemuraError {
31
+ constructor(message, code = "ADAPTER_ERROR", cause, problem, hints = []) {
32
+ super(message, code, problem, hints);
33
+ this.cause = cause;
34
+ this.name = "LemuraAdapterError";
35
+ }
36
+ };
37
+ var LemuraSkillInjectionError = class extends LemuraError {
38
+ constructor(message) {
39
+ super(message, "SKILL_INJECTION_FAILED");
40
+ this.name = "LemuraSkillInjectionError";
41
+ }
42
+ };
43
+ var LemuraMaxIterationsError = class extends LemuraError {
44
+ constructor(message) {
45
+ super(message, "MAX_ITERATIONS_EXCEEDED");
46
+ this.name = "LemuraMaxIterationsError";
47
+ }
48
+ };
49
+ var LemuraToolValidationError = class extends LemuraError {
50
+ constructor(message) {
51
+ super(message, "TOOL_VALIDATION_FAILED");
52
+ this.name = "LemuraToolValidationError";
53
+ }
54
+ };
55
+ var LemuraToolTimeoutError = class extends LemuraError {
56
+ constructor(message) {
57
+ super(message, "TOOL_TIMEOUT");
58
+ this.name = "LemuraToolTimeoutError";
59
+ }
60
+ };
61
+
62
+ // src/types/logger.ts
63
+ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
64
+ LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
65
+ LogLevel2[LogLevel2["INFO"] = 1] = "INFO";
66
+ LogLevel2[LogLevel2["WARN"] = 2] = "WARN";
67
+ LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";
68
+ LogLevel2[LogLevel2["FATAL"] = 4] = "FATAL";
69
+ return LogLevel2;
70
+ })(LogLevel || {});
71
+
72
+ export { LemuraAdapterError, LemuraContextOverflowError, LemuraError, LemuraMaxIterationsError, LemuraSkillInjectionError, LemuraToolNotFoundError, LemuraToolTimeoutError, LemuraToolValidationError, LogLevel };
73
+ //# sourceMappingURL=index.mjs.map
74
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/types/errors.ts","../../src/types/logger.ts"],"names":["LogLevel"],"mappings":";AAMO,IAAM,WAAA,GAAN,cAA0B,KAAA,CAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOnC,YACI,OAAA,EACgB,IAAA,EACA,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WAAA,CAAY;AAAA,EACtD,YAAY,OAAA,EAAiB;AACzB,IAAA,KAAA,CAAM,SAAS,yBAAyB,CAAA;AACxC,IAAA,IAAA,CAAK,IAAA,GAAO,0BAAA;AAAA,EAChB;AACJ;AAGO,IAAM,yBAAA,GAAN,cAAwC,WAAA,CAAY;AAAA,EACvD,YAAY,OAAA,EAAiB;AACzB,IAAA,KAAA,CAAM,SAAS,wBAAwB,CAAA;AACvC,IAAA,IAAA,CAAK,IAAA,GAAO,2BAAA;AAAA,EAChB;AACJ;AAGO,IAAM,sBAAA,GAAN,cAAqC,WAAA,CAAY;AAAA,EACpD,YAAY,OAAA,EAAiB;AACzB,IAAA,KAAA,CAAM,SAAS,cAAc,CAAA;AAC7B,IAAA,IAAA,CAAK,IAAA,GAAO,wBAAA;AAAA,EAChB;AACJ;;;ACpFO,IAAK,QAAA,qBAAAA,SAAAA,KAAL;AACH,EAAAA,SAAAA,CAAAA,SAAAA,CAAA,WAAQ,CAAA,CAAA,GAAR,OAAA;AACA,EAAAA,SAAAA,CAAAA,SAAAA,CAAA,UAAO,CAAA,CAAA,GAAP,MAAA;AACA,EAAAA,SAAAA,CAAAA,SAAAA,CAAA,UAAO,CAAA,CAAA,GAAP,MAAA;AACA,EAAAA,SAAAA,CAAAA,SAAAA,CAAA,WAAQ,CAAA,CAAA,GAAR,OAAA;AACA,EAAAA,SAAAA,CAAAA,SAAAA,CAAA,WAAQ,CAAA,CAAA,GAAR,OAAA;AALQ,EAAA,OAAAA,SAAAA;AAAA,CAAA,EAAA,QAAA,IAAA,EAAA","file":"index.mjs","sourcesContent":["/**\n * Base class for all custom errors thrown by lemura.\n *\n * @example\n * throw new LemuraError('Something went wrong', 'UNKNOWN_ERROR');\n */\nexport class LemuraError extends Error {\n /**\n * @param message - The error message\n * @param code - The error code for programmatic handling\n * @param problem - A clear description of the problem for the end user\n * @param hints - A list of suggestions to resolve the issue\n */\n constructor(\n message: string,\n public readonly code: string,\n public readonly problem?: string,\n public readonly hints: string[] = []\n ) {\n super(message);\n this.name = 'LemuraError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Error thrown when context exceeds max tokens and cannot be compressed further */\nexport class LemuraContextOverflowError extends LemuraError {\n constructor(message: string) {\n super(message, 'CONTEXT_OVERFLOW');\n this.name = 'LemuraContextOverflowError';\n }\n}\n\n/** Error thrown when a requested tool is not found in the registry */\nexport class LemuraToolNotFoundError extends LemuraError {\n constructor(message: string) {\n super(message, 'TOOL_NOT_FOUND');\n this.name = 'LemuraToolNotFoundError';\n }\n}\n\n/** Error thrown when an adapter encounters an API or formatting issue */\nexport class LemuraAdapterError extends LemuraError {\n constructor(\n message: string,\n code = 'ADAPTER_ERROR',\n public cause?: any,\n problem?: string,\n hints: string[] = []\n ) {\n super(message, code, problem, hints);\n this.name = 'LemuraAdapterError';\n }\n}\n\n/** Error thrown when a skill cannot be parsed or injected */\nexport class LemuraSkillInjectionError extends LemuraError {\n constructor(message: string) {\n super(message, 'SKILL_INJECTION_FAILED');\n this.name = 'LemuraSkillInjectionError';\n }\n}\n\n/** Error thrown when the ReAct loop exceeds the configured max iterations */\nexport class LemuraMaxIterationsError extends LemuraError {\n constructor(message: string) {\n super(message, 'MAX_ITERATIONS_EXCEEDED');\n this.name = 'LemuraMaxIterationsError';\n }\n}\n\n/** Error thrown when tool parameters fail JSON schema validation */\nexport class LemuraToolValidationError extends LemuraError {\n constructor(message: string) {\n super(message, 'TOOL_VALIDATION_FAILED');\n this.name = 'LemuraToolValidationError';\n }\n}\n\n/** Error thrown when a tool execute function exceeds its timeout */\nexport class LemuraToolTimeoutError extends LemuraError {\n constructor(message: string) {\n super(message, 'TOOL_TIMEOUT');\n this.name = 'LemuraToolTimeoutError';\n }\n}\n","/** Log levels supported by lemura */\nexport enum LogLevel {\n DEBUG = 0,\n INFO = 1,\n WARN = 2,\n ERROR = 3,\n FATAL = 4,\n}\n\n/** Severity levels for user-facing logs */\nexport type Severity = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'FATAL';\n\n/** Metadata for structured logging and error reporting */\nexport interface LogMetadata {\n problem?: string;\n hints?: string[];\n severity?: Severity;\n [key: string]: unknown;\n}\n\n/**\n * Enhanced logger interface for lemura.\n * Supports structured logging with problems and hints.\n */\nexport interface ILogger {\n /** Log a debug message (trace-level details) */\n debug(message: string, metadata?: LogMetadata): void;\n /** Log an informational message */\n info(message: string, metadata?: LogMetadata): void;\n /** Log a warning */\n warn(message: string, metadata?: LogMetadata): void;\n /** Log an error */\n error(message: string, metadata?: LogMetadata): void;\n /** Log a fatal error that prevents execution */\n fatal(message: string, metadata?: LogMetadata): void;\n\n /** Set the minimum log level to display */\n setLevel(level: LogLevel): void;\n}\n"]}
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "lemura",
3
+ "version": "1.0.0",
4
+ "description": "Provider-agnostic agentic AI runtime",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "import": "./dist/index.mjs",
9
+ "require": "./dist/index.js"
10
+ },
11
+ "./adapters": {
12
+ "types": "./dist/adapters/index.d.ts",
13
+ "import": "./dist/adapters/index.mjs",
14
+ "require": "./dist/adapters/index.js"
15
+ },
16
+ "./context": {
17
+ "types": "./dist/context/index.d.ts",
18
+ "import": "./dist/context/index.mjs",
19
+ "require": "./dist/context/index.js"
20
+ },
21
+ "./tools": {
22
+ "types": "./dist/tools/index.d.ts",
23
+ "import": "./dist/tools/index.mjs",
24
+ "require": "./dist/tools/index.js"
25
+ },
26
+ "./skills": {
27
+ "types": "./dist/skills/index.d.ts",
28
+ "import": "./dist/skills/index.mjs",
29
+ "require": "./dist/skills/index.js"
30
+ },
31
+ "./rag": {
32
+ "types": "./dist/rag/index.d.ts",
33
+ "import": "./dist/rag/index.mjs",
34
+ "require": "./dist/rag/index.js"
35
+ },
36
+ "./logger": {
37
+ "types": "./dist/logger/index.d.ts",
38
+ "import": "./dist/logger/index.mjs",
39
+ "require": "./dist/logger/index.js"
40
+ },
41
+ "./types": {
42
+ "types": "./dist/types/index.d.ts",
43
+ "import": "./dist/types/index.mjs",
44
+ "require": "./dist/types/index.js"
45
+ }
46
+ },
47
+ "main": "./dist/index.js",
48
+ "module": "./dist/index.mjs",
49
+ "types": "./dist/index.d.ts",
50
+ "sideEffects": false,
51
+ "files": [
52
+ "dist",
53
+ "skills",
54
+ "LICENSE",
55
+ "README.md",
56
+ "CHANGELOG.md"
57
+ ],
58
+ "engines": {
59
+ "node": ">=18.0.0"
60
+ },
61
+ "scripts": {
62
+ "build": "tsup",
63
+ "package": "pnpm pack --pack-destination ./package",
64
+ "test": "vitest",
65
+ "test:coverage": "vitest run --coverage",
66
+ "test:docs": "vitest run tests/docs/",
67
+ "typecheck": "tsc --noEmit",
68
+ "clean": "rm -rf dist coverage .turbo",
69
+ "docs:api": "typedoc --out docs/api src/index.ts"
70
+ },
71
+ "devDependencies": {
72
+ "@types/node": "20.11.24",
73
+ "@vitest/coverage-v8": "^1.0.0",
74
+ "tsup": "^8.0.0",
75
+ "typedoc": "^0.28.17",
76
+ "typescript": "^5.0.0",
77
+ "vitest": "^1.0.0"
78
+ }
79
+ }