@reminix/runtime 0.3.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/LICENSE +21 -0
- package/README.md +56 -0
- package/dist/executor.d.ts +17 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/executor.js +22 -0
- package/dist/executor.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/loader.d.ts +19 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +52 -0
- package/dist/loader.js.map +1 -0
- package/dist/registry.d.ts +24 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +208 -0
- package/dist/registry.js.map +1 -0
- package/dist/types.d.ts +104 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Reminix
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# @reminix/runtime
|
|
2
|
+
|
|
3
|
+
Reminix runtime for building handlers that run on Reminix.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @reminix/runtime
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @reminix/runtime
|
|
11
|
+
# or
|
|
12
|
+
yarn add @reminix/runtime
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import type { AgentHandler, Context, Request, Response } from '@reminix/runtime';
|
|
19
|
+
|
|
20
|
+
const myAgent: AgentHandler = async (context: Context, request: Request): Promise<Response> => {
|
|
21
|
+
// Your handler logic here
|
|
22
|
+
return {
|
|
23
|
+
messages: [
|
|
24
|
+
{
|
|
25
|
+
role: 'assistant',
|
|
26
|
+
content: 'Hello from my handler!',
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Components
|
|
34
|
+
|
|
35
|
+
### Types
|
|
36
|
+
|
|
37
|
+
- `Message` - Conversation message
|
|
38
|
+
- `ToolCall` - Tool call made by an agent
|
|
39
|
+
- `Context` - Persistent resources provided to handlers
|
|
40
|
+
- `Request` - Current invocation request
|
|
41
|
+
- `Response` - Handler response
|
|
42
|
+
- `MemoryStore` - Memory store interface
|
|
43
|
+
- `KnowledgeBase` - Knowledge base interface
|
|
44
|
+
- `ToolRegistry` - Tool registry interface
|
|
45
|
+
- `AgentHandler` - Agent handler function type
|
|
46
|
+
- `ToolHandler` - Tool handler function type
|
|
47
|
+
|
|
48
|
+
### Utilities
|
|
49
|
+
|
|
50
|
+
- `load_handler(handlerPath)` - Load a handler from a file
|
|
51
|
+
- `discover_registry(handlerPath)` - Auto-discover handlers from a directory structure
|
|
52
|
+
- `execute_handler(handler, context, request)` - Execute a handler with context and request
|
|
53
|
+
|
|
54
|
+
## License
|
|
55
|
+
|
|
56
|
+
MIT
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core handler execution logic
|
|
3
|
+
*/
|
|
4
|
+
import type { AgentHandler, ToolHandler, Context, Request, Response } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Execute an agent handler
|
|
7
|
+
*/
|
|
8
|
+
export declare function executeAgent(handler: AgentHandler, context: Context, request: Request): Promise<Response>;
|
|
9
|
+
/**
|
|
10
|
+
* Execute a tool handler
|
|
11
|
+
*/
|
|
12
|
+
export declare function executeTool(handler: ToolHandler, context: Context, request: Request): Promise<Response>;
|
|
13
|
+
/**
|
|
14
|
+
* Execute a handler (agent or tool)
|
|
15
|
+
*/
|
|
16
|
+
export declare function executeHandler(handler: AgentHandler | ToolHandler, context: Context, request: Request): Promise<Response>;
|
|
17
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAErF;;GAEG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,QAAQ,CAAC,CAEnB;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,QAAQ,CAAC,CAEnB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,YAAY,GAAG,WAAW,EACnC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,QAAQ,CAAC,CAEnB"}
|
package/dist/executor.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core handler execution logic
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Execute an agent handler
|
|
6
|
+
*/
|
|
7
|
+
export async function executeAgent(handler, context, request) {
|
|
8
|
+
return await handler(context, request);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Execute a tool handler
|
|
12
|
+
*/
|
|
13
|
+
export async function executeTool(handler, context, request) {
|
|
14
|
+
return await handler(context, request);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Execute a handler (agent or tool)
|
|
18
|
+
*/
|
|
19
|
+
export async function executeHandler(handler, context, request) {
|
|
20
|
+
return await handler(context, request);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,OAAqB,EACrB,OAAgB,EAChB,OAAgB;IAEhB,OAAO,MAAM,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAoB,EACpB,OAAgB,EAChB,OAAgB;IAEhB,OAAO,MAAM,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAAmC,EACnC,OAAgB,EAChB,OAAgB;IAEhB,OAAO,MAAM,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reminix Runtime Types
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
export type { Message, ToolCall, Context, Request, Response, MemoryStore, KnowledgeBase, ToolRegistry, ToolHandler, AgentHandler, } from './types';
|
|
6
|
+
export { loadHandler, isFile, type LoadedHandler } from './loader';
|
|
7
|
+
export { discoverRegistry, type Registry } from './registry';
|
|
8
|
+
export { executeAgent, executeTool, executeHandler } from './executor';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EACV,OAAO,EACP,QAAQ,EACR,OAAO,EACP,OAAO,EACP,QAAQ,EACR,WAAW,EACX,aAAa,EACb,YAAY,EACZ,WAAW,EACX,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reminix Runtime Types
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
export { loadHandler, isFile } from './loader';
|
|
6
|
+
export { discoverRegistry } from './registry';
|
|
7
|
+
export { executeAgent, executeTool, executeHandler } from './executor';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAsB,MAAM,UAAU,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAiB,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/loader.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load handler from file
|
|
3
|
+
*/
|
|
4
|
+
import type { AgentHandler, ToolHandler } from './types';
|
|
5
|
+
export interface LoadedHandler {
|
|
6
|
+
agents?: Record<string, AgentHandler>;
|
|
7
|
+
tools?: Record<string, ToolHandler>;
|
|
8
|
+
prompts?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Load handler from a file path
|
|
12
|
+
* Supports both TypeScript (.ts) and JavaScript (.js) files
|
|
13
|
+
*/
|
|
14
|
+
export declare function loadHandler(handlerPath: string): Promise<LoadedHandler>;
|
|
15
|
+
/**
|
|
16
|
+
* Check if a path is a file (not a directory)
|
|
17
|
+
*/
|
|
18
|
+
export declare function isFile(path: string): boolean;
|
|
19
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEzD,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAqC7E;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAO5C"}
|
package/dist/loader.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load handler from file
|
|
3
|
+
*/
|
|
4
|
+
import { pathToFileURL } from 'url';
|
|
5
|
+
import { statSync } from 'fs';
|
|
6
|
+
/**
|
|
7
|
+
* Load handler from a file path
|
|
8
|
+
* Supports both TypeScript (.ts) and JavaScript (.js) files
|
|
9
|
+
*/
|
|
10
|
+
export async function loadHandler(handlerPath) {
|
|
11
|
+
try {
|
|
12
|
+
// Convert file path to file URL for ES modules
|
|
13
|
+
const fileUrl = pathToFileURL(handlerPath).href;
|
|
14
|
+
// Dynamic import of the handler module
|
|
15
|
+
const module = await import(fileUrl);
|
|
16
|
+
// Extract agents, tools, and prompts
|
|
17
|
+
const loaded = {};
|
|
18
|
+
if (module.agents) {
|
|
19
|
+
loaded.agents = module.agents;
|
|
20
|
+
}
|
|
21
|
+
if (module.tools) {
|
|
22
|
+
loaded.tools = module.tools;
|
|
23
|
+
}
|
|
24
|
+
if (module.prompts) {
|
|
25
|
+
loaded.prompts = module.prompts;
|
|
26
|
+
}
|
|
27
|
+
// Validate that at least one export exists
|
|
28
|
+
if (!loaded.agents && !loaded.tools && !loaded.prompts) {
|
|
29
|
+
throw new Error(`Handler file "${handlerPath}" must export at least one of: agents, tools, or prompts`);
|
|
30
|
+
}
|
|
31
|
+
return loaded;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (error instanceof Error) {
|
|
35
|
+
throw new Error(`Failed to load handler from "${handlerPath}": ${error.message}`);
|
|
36
|
+
}
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Check if a path is a file (not a directory)
|
|
42
|
+
*/
|
|
43
|
+
export function isFile(path) {
|
|
44
|
+
try {
|
|
45
|
+
const stats = statSync(path);
|
|
46
|
+
return stats.isFile();
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAS9B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,WAAmB;IACnD,IAAI,CAAC;QACH,+CAA+C;QAC/C,MAAM,OAAO,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;QAEhD,uCAAuC;QACvC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;QAErC,qCAAqC;QACrC,MAAM,MAAM,GAAkB,EAAE,CAAC;QAEjC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAChC,CAAC;QAED,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;YACjB,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;QAC9B,CAAC;QAED,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAClC,CAAC;QAED,2CAA2C;QAC3C,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACvD,MAAM,IAAI,KAAK,CACb,iBAAiB,WAAW,0DAA0D,CACvF,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,gCAAgC,WAAW,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACpF,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC7B,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry for auto-discovering agents, tools, and prompts from directories
|
|
3
|
+
*/
|
|
4
|
+
import type { AgentHandler, ToolHandler } from './types';
|
|
5
|
+
export interface Registry {
|
|
6
|
+
agents: Record<string, AgentHandler>;
|
|
7
|
+
tools: Record<string, ToolHandler>;
|
|
8
|
+
prompts: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Auto-discover and load handlers from a directory structure
|
|
12
|
+
*
|
|
13
|
+
* Expected structure:
|
|
14
|
+
* handler/
|
|
15
|
+
* agents/
|
|
16
|
+
* chatbot.ts
|
|
17
|
+
* assistant.ts
|
|
18
|
+
* tools/
|
|
19
|
+
* search.ts
|
|
20
|
+
* prompts/
|
|
21
|
+
* system.ts
|
|
22
|
+
*/
|
|
23
|
+
export declare function discoverRegistry(handlerPath: string): Promise<Registry>;
|
|
24
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEzD,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CA4E7E"}
|
package/dist/registry.js
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry for auto-discovering agents, tools, and prompts from directories
|
|
3
|
+
*/
|
|
4
|
+
import { readdir, stat } from 'fs/promises';
|
|
5
|
+
import { join, extname, basename } from 'path';
|
|
6
|
+
import { pathToFileURL } from 'url';
|
|
7
|
+
import { loadHandler } from './loader';
|
|
8
|
+
/**
|
|
9
|
+
* Auto-discover and load handlers from a directory structure
|
|
10
|
+
*
|
|
11
|
+
* Expected structure:
|
|
12
|
+
* handler/
|
|
13
|
+
* agents/
|
|
14
|
+
* chatbot.ts
|
|
15
|
+
* assistant.ts
|
|
16
|
+
* tools/
|
|
17
|
+
* search.ts
|
|
18
|
+
* prompts/
|
|
19
|
+
* system.ts
|
|
20
|
+
*/
|
|
21
|
+
export async function discoverRegistry(handlerPath) {
|
|
22
|
+
const registry = {
|
|
23
|
+
agents: {},
|
|
24
|
+
tools: {},
|
|
25
|
+
prompts: {},
|
|
26
|
+
};
|
|
27
|
+
try {
|
|
28
|
+
// Check if path exists and is a directory
|
|
29
|
+
const stats = await stat(handlerPath);
|
|
30
|
+
if (!stats.isDirectory()) {
|
|
31
|
+
throw new Error(`Handler path must be a directory: ${handlerPath}`);
|
|
32
|
+
}
|
|
33
|
+
// Discover agents
|
|
34
|
+
const agentsPath = join(handlerPath, 'agents');
|
|
35
|
+
try {
|
|
36
|
+
const agentsStats = await stat(agentsPath);
|
|
37
|
+
if (agentsStats.isDirectory()) {
|
|
38
|
+
const agents = await loadDirectory(agentsPath);
|
|
39
|
+
// Filter to only AgentHandler types
|
|
40
|
+
for (const [key, value] of Object.entries(agents)) {
|
|
41
|
+
if (typeof value === 'function') {
|
|
42
|
+
registry.agents[key] = value;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// agents/ directory doesn't exist, skip
|
|
49
|
+
}
|
|
50
|
+
// Discover tools
|
|
51
|
+
const toolsPath = join(handlerPath, 'tools');
|
|
52
|
+
try {
|
|
53
|
+
const toolsStats = await stat(toolsPath);
|
|
54
|
+
if (toolsStats.isDirectory()) {
|
|
55
|
+
const tools = await loadDirectory(toolsPath);
|
|
56
|
+
// Filter to only ToolHandler types
|
|
57
|
+
for (const [key, value] of Object.entries(tools)) {
|
|
58
|
+
if (typeof value === 'function') {
|
|
59
|
+
registry.tools[key] = value;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// tools/ directory doesn't exist, skip
|
|
66
|
+
}
|
|
67
|
+
// Discover prompts
|
|
68
|
+
const promptsPath = join(handlerPath, 'prompts');
|
|
69
|
+
try {
|
|
70
|
+
const promptsStats = await stat(promptsPath);
|
|
71
|
+
if (promptsStats.isDirectory()) {
|
|
72
|
+
const prompts = await loadDirectory(promptsPath);
|
|
73
|
+
registry.prompts = prompts;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// prompts/ directory doesn't exist, skip
|
|
78
|
+
}
|
|
79
|
+
// Validate that at least something was discovered
|
|
80
|
+
if (Object.keys(registry.agents).length === 0 &&
|
|
81
|
+
Object.keys(registry.tools).length === 0 &&
|
|
82
|
+
Object.keys(registry.prompts).length === 0) {
|
|
83
|
+
throw new Error(`No agents, tools, or prompts found in directory: ${handlerPath}`);
|
|
84
|
+
}
|
|
85
|
+
return registry;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (error instanceof Error) {
|
|
89
|
+
throw new Error(`Failed to discover registry from "${handlerPath}": ${error.message}`);
|
|
90
|
+
}
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Load all handler files from a directory
|
|
96
|
+
* Filename (without extension) becomes the key in the registry
|
|
97
|
+
*/
|
|
98
|
+
async function loadDirectory(dirPath) {
|
|
99
|
+
const handlers = {};
|
|
100
|
+
try {
|
|
101
|
+
const entries = await readdir(dirPath);
|
|
102
|
+
for (const entry of entries) {
|
|
103
|
+
const fullPath = join(dirPath, entry);
|
|
104
|
+
const stats = await stat(fullPath);
|
|
105
|
+
// Skip if not a file
|
|
106
|
+
if (!stats.isFile()) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
// Only process TypeScript/JavaScript files
|
|
110
|
+
const ext = extname(entry);
|
|
111
|
+
if (ext !== '.ts' && ext !== '.js' && ext !== '.mjs') {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
// Extract the key from filename (without extension)
|
|
115
|
+
const key = entry.replace(ext, '');
|
|
116
|
+
try {
|
|
117
|
+
// Try loading as a handler file (expects agents/tools/prompts exports)
|
|
118
|
+
const loaded = await loadHandler(fullPath);
|
|
119
|
+
// Merge agents, tools, and prompts into the registry
|
|
120
|
+
if (loaded.agents) {
|
|
121
|
+
const agentKeys = Object.keys(loaded.agents);
|
|
122
|
+
if (agentKeys.length === 1) {
|
|
123
|
+
handlers[key] = loaded.agents[agentKeys[0]];
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
for (const agentKey of agentKeys) {
|
|
127
|
+
handlers[`${key}.${agentKey}`] = loaded.agents[agentKey];
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (loaded.tools) {
|
|
132
|
+
const toolKeys = Object.keys(loaded.tools);
|
|
133
|
+
if (toolKeys.length === 1) {
|
|
134
|
+
handlers[key] = loaded.tools[toolKeys[0]];
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
for (const toolKey of toolKeys) {
|
|
138
|
+
handlers[`${key}.${toolKey}`] = loaded.tools[toolKey];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (loaded.prompts) {
|
|
143
|
+
const promptKeys = Object.keys(loaded.prompts);
|
|
144
|
+
if (promptKeys.length === 1) {
|
|
145
|
+
handlers[key] = loaded.prompts[promptKeys[0]];
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
for (const promptKey of promptKeys) {
|
|
149
|
+
handlers[`${key}.${promptKey}`] = loaded.prompts[promptKey];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
// If loadHandler fails, try loading as direct export
|
|
156
|
+
// This handles files that export functions directly (e.g., export const chatbot)
|
|
157
|
+
try {
|
|
158
|
+
const fileUrl = pathToFileURL(fullPath).href;
|
|
159
|
+
const module = await import(fileUrl);
|
|
160
|
+
// Determine type based on directory name
|
|
161
|
+
const dirName = basename(dirPath);
|
|
162
|
+
// Check for direct exports matching the directory type
|
|
163
|
+
if (dirName === 'agents') {
|
|
164
|
+
// Look for exported function with same name as file, or any exported function
|
|
165
|
+
const exportedFunction = module[key] || module.default;
|
|
166
|
+
if (typeof exportedFunction === 'function') {
|
|
167
|
+
handlers[key] = exportedFunction;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
else if (dirName === 'tools') {
|
|
171
|
+
const exportedFunction = module[key] || module.default;
|
|
172
|
+
if (typeof exportedFunction === 'function') {
|
|
173
|
+
handlers[key] = exportedFunction;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
else if (dirName === 'prompts') {
|
|
177
|
+
// For prompts, accept any export (function, object, string, etc.)
|
|
178
|
+
// Try to get export with same name as file, or default, or any named export
|
|
179
|
+
const exportedValue = module[key] || module.default;
|
|
180
|
+
if (exportedValue !== undefined) {
|
|
181
|
+
handlers[key] = exportedValue;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
// Check if module has any exports (excluding default module properties)
|
|
185
|
+
const moduleKeys = Object.keys(module).filter((k) => k !== 'default' && !k.startsWith('__'));
|
|
186
|
+
if (moduleKeys.length > 0) {
|
|
187
|
+
// Use the first export, or the module itself if it's a simple object
|
|
188
|
+
handlers[key] = module[moduleKeys[0]] || module;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
// Skip this file if both methods fail
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return handlers;
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
if (error instanceof Error) {
|
|
203
|
+
throw new Error(`Failed to load directory "${dirPath}": ${error.message}`);
|
|
204
|
+
}
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AASvC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,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C;4BACF,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gCAC1B,qEAAqE;gCACrE,QAAQ,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;4BAClD,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;gBAAC,MAAM,CAAC;oBACP,sCAAsC;oBACtC,SAAS;gBACX,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,6BAA6B,OAAO,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7E,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handler types for Reminix agents and tools
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Message in a conversation
|
|
6
|
+
*/
|
|
7
|
+
export interface Message {
|
|
8
|
+
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
9
|
+
content: string;
|
|
10
|
+
metadata?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Tool call made by an agent
|
|
14
|
+
*/
|
|
15
|
+
export interface ToolCall {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
arguments: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Context provides persistent resources to handlers
|
|
22
|
+
*/
|
|
23
|
+
export interface Context {
|
|
24
|
+
/** Chat/thread identifier */
|
|
25
|
+
chatId: string;
|
|
26
|
+
/** Thread identifier (optional) */
|
|
27
|
+
threadId?: string;
|
|
28
|
+
/** Memory store for persistent memory */
|
|
29
|
+
memory: MemoryStore;
|
|
30
|
+
/** Knowledge base for RAG/retrieval */
|
|
31
|
+
knowledgeBase: KnowledgeBase;
|
|
32
|
+
/** Available tools registry */
|
|
33
|
+
tools?: ToolRegistry;
|
|
34
|
+
/** User identifier */
|
|
35
|
+
userId?: string;
|
|
36
|
+
/** Session identifier */
|
|
37
|
+
sessionId?: string;
|
|
38
|
+
/** Additional metadata */
|
|
39
|
+
metadata?: Record<string, unknown>;
|
|
40
|
+
/** Extensible for future additions */
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Request represents the current invocation
|
|
45
|
+
*/
|
|
46
|
+
export interface Request {
|
|
47
|
+
/** Conversation messages */
|
|
48
|
+
messages: Message[];
|
|
49
|
+
/** Additional metadata for this request */
|
|
50
|
+
metadata?: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Response from a handler
|
|
54
|
+
*/
|
|
55
|
+
export interface Response {
|
|
56
|
+
/** Response messages */
|
|
57
|
+
messages: Message[];
|
|
58
|
+
/** Optional metadata (tokens, model, latency, etc.) */
|
|
59
|
+
metadata?: {
|
|
60
|
+
tokensUsed?: number;
|
|
61
|
+
model?: string;
|
|
62
|
+
latency?: number;
|
|
63
|
+
[key: string]: unknown;
|
|
64
|
+
};
|
|
65
|
+
/** Tool calls made by the agent */
|
|
66
|
+
toolCalls?: ToolCall[];
|
|
67
|
+
/** State updates */
|
|
68
|
+
stateUpdates?: Record<string, unknown>;
|
|
69
|
+
/** Extensible for future additions */
|
|
70
|
+
[key: string]: unknown;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Memory store interface
|
|
74
|
+
*/
|
|
75
|
+
export interface MemoryStore {
|
|
76
|
+
get(key: string): Promise<unknown>;
|
|
77
|
+
set(key: string, value: unknown): Promise<void>;
|
|
78
|
+
delete(key: string): Promise<void>;
|
|
79
|
+
clear(): Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Knowledge base interface
|
|
83
|
+
*/
|
|
84
|
+
export interface KnowledgeBase {
|
|
85
|
+
search(query: string, options?: Record<string, unknown>): Promise<unknown[]>;
|
|
86
|
+
add(content: string, metadata?: Record<string, unknown>): Promise<void>;
|
|
87
|
+
delete(id: string): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Tool registry interface
|
|
91
|
+
*/
|
|
92
|
+
export interface ToolRegistry {
|
|
93
|
+
get(name: string): ToolHandler | undefined;
|
|
94
|
+
list(): string[];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Tool handler function signature
|
|
98
|
+
*/
|
|
99
|
+
export type ToolHandler = (context: Context, request: Request) => Promise<Response>;
|
|
100
|
+
/**
|
|
101
|
+
* Agent handler function signature
|
|
102
|
+
*/
|
|
103
|
+
export type AgentHandler = (context: Context, request: Request) => Promise<Response>;
|
|
104
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IAEf,mCAAmC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,yCAAyC;IACzC,M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G,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7E,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;IAC3C,IAAI,IAAI,MAAM,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEpF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@reminix/runtime",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Reminix runtime for building handlers",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"keywords": [
|
|
19
|
+
"reminix",
|
|
20
|
+
"runtime",
|
|
21
|
+
"types",
|
|
22
|
+
"handler",
|
|
23
|
+
"typescript"
|
|
24
|
+
],
|
|
25
|
+
"author": "Reminix <support@reminix.com>",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/reminix-ai/reminix-typescript.git",
|
|
30
|
+
"directory": "packages/runtime"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/reminix-ai/reminix-typescript",
|
|
33
|
+
"dependencies": {},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/jest": "^29.5.0",
|
|
36
|
+
"vitest": "^4.0.16",
|
|
37
|
+
"tsd": "^0.33.0"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc",
|
|
44
|
+
"clean": "rm -rf dist",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"test:watch": "vitest",
|
|
47
|
+
"lint": "eslint src",
|
|
48
|
+
"preversion": "pnpm test && pnpm lint"
|
|
49
|
+
}
|
|
50
|
+
}
|