@rolexjs/core 0.1.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 ADDED
@@ -0,0 +1,22 @@
1
+ # @rolexjs/core
2
+
3
+ RoleX Core - AI Agent Role Management Framework
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @rolexjs/core
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { createRole } from "@rolexjs/core";
15
+
16
+ const role = createRole();
17
+ console.log(role);
18
+ ```
19
+
20
+ ## License
21
+
22
+ MIT
@@ -0,0 +1,190 @@
1
+ import { RXR, Registry } from "resourcexjs";
2
+ /**
3
+ * RoleX Core Types
4
+ * @rolexjs/core
5
+ */
6
+ /**
7
+ * Rendered Role object
8
+ */
9
+ interface RenderedRole {
10
+ /** Final rendered complete prompt */
11
+ readonly prompt: string;
12
+ /** Personality section */
13
+ readonly personality: string;
14
+ /** Principle section */
15
+ readonly principle: string;
16
+ /** Knowledge section */
17
+ readonly knowledge: string;
18
+ }
19
+ /**
20
+ * Thought sub-tag types
21
+ */
22
+ type ThoughtSubTag = "exploration" | "reasoning" | "challenge" | "plan";
23
+ /**
24
+ * Execution sub-tag types
25
+ */
26
+ type ExecutionSubTag = "process" | "constraint" | "rule" | "guideline" | "criteria";
27
+ /**
28
+ * Parsed Thought content
29
+ */
30
+ interface ParsedThought {
31
+ readonly exploration?: string;
32
+ readonly reasoning?: string;
33
+ readonly challenge?: string;
34
+ readonly plan?: string;
35
+ }
36
+ /**
37
+ * Parsed Execution content
38
+ */
39
+ interface ParsedExecution {
40
+ readonly process?: string;
41
+ readonly constraint?: string;
42
+ readonly rule?: string;
43
+ readonly guideline?: string;
44
+ readonly criteria?: string;
45
+ }
46
+ /**
47
+ * Resource resolver function type
48
+ */
49
+ type ResourceResolver = (src: string) => Promise<string>;
50
+ /**
51
+ * Load and render a Role from RXR
52
+ *
53
+ * @param rxr - Role resource (RXL + RXM + RXC)
54
+ * @param registry - Registry instance (for resolving ARP rxr:// references)
55
+ * @returns Rendered Role object
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const registry = createRegistry();
60
+ * const rxr = await registry.get('localhost/my.role@1.0.0');
61
+ * const role = await loadRole(rxr, registry);
62
+ * console.log(role.prompt);
63
+ * ```
64
+ */
65
+ declare function loadRole(rxr: RXR, registry: Registry): Promise<RenderedRole>;
66
+ import { ResourceType } from "resourcexjs";
67
+ /**
68
+ * Role resource type for ResourceX integration
69
+ *
70
+ * @example
71
+ * ```typescript
72
+ * import { createRegistry } from 'resourcexjs';
73
+ * import { roleType } from '@rolexjs/core';
74
+ *
75
+ * const registry = createRegistry();
76
+ * registry.supportType(roleType);
77
+ *
78
+ * const resource = await registry.resolve('deepractice.dev/nuwa.role@1.0.0');
79
+ * const role = await resource.execute();
80
+ * console.log(role.prompt);
81
+ * ```
82
+ */
83
+ declare const roleType: ResourceType<void, RenderedRole>;
84
+ /**
85
+ * RoleX Error Classes
86
+ * @rolexjs/core
87
+ */
88
+ /**
89
+ * Base error class for all RoleX errors
90
+ */
91
+ declare class RoleXError extends Error {
92
+ constructor(message: string, options?: ErrorOptions);
93
+ }
94
+ /**
95
+ * Error thrown when role loading fails
96
+ */
97
+ declare class RoleLoadError extends RoleXError {
98
+ readonly locator?: string;
99
+ constructor(message: string, locator?: string);
100
+ }
101
+ /**
102
+ * Error thrown when resource resolution fails
103
+ */
104
+ declare class ResourceResolveError extends RoleXError {
105
+ readonly src?: string;
106
+ constructor(message: string, src?: string);
107
+ }
108
+ /**
109
+ * Error thrown when DPML parsing fails
110
+ */
111
+ declare class DPMLParseError extends RoleXError {
112
+ constructor(message: string);
113
+ }
114
+ import { Schema } from "dpml";
115
+ /**
116
+ * RoleX schema collection
117
+ */
118
+ interface RoleSchemas {
119
+ readonly role: Schema;
120
+ readonly thought: Schema;
121
+ readonly execution: Schema;
122
+ readonly knowledge: Schema;
123
+ }
124
+ import { Schema as Schema2 } from "dpml";
125
+ /**
126
+ * Create all RoleX schemas
127
+ *
128
+ * Role structure:
129
+ * <role>
130
+ * <personality>...</personality>
131
+ * <principle>...</principle>
132
+ * <knowledge>...</knowledge>
133
+ * </role>
134
+ */
135
+ declare function defineRoleSchemas(): RoleSchemas;
136
+ declare const roleSchema: Schema2;
137
+ declare const thoughtSchema: Schema2;
138
+ declare const executionSchema: Schema2;
139
+ declare const knowledgeSchema: Schema2;
140
+ /**
141
+ * Transformer input interface (compatible with dpml 0.3.0)
142
+ */
143
+ interface TransformInput {
144
+ document: {
145
+ rootNode: unknown
146
+ nodesById?: Map<string, unknown>
147
+ metadata?: Record<string, unknown>
148
+ };
149
+ isValid?: boolean;
150
+ validation?: {
151
+ isValid: boolean
152
+ errors: unknown[]
153
+ warnings: unknown[]
154
+ };
155
+ resources?: unknown[];
156
+ }
157
+ /**
158
+ * Role transformer type
159
+ */
160
+ interface RoleTransformer {
161
+ name: string;
162
+ description?: string;
163
+ transform(input: TransformInput): RenderedRole;
164
+ }
165
+ import { Transformer } from "dpml";
166
+ /**
167
+ * Role Transformer
168
+ * Transforms DPML role document into RenderedRole
169
+ */
170
+ declare const roleTransformer: Transformer<{
171
+ document: {
172
+ rootNode: unknown
173
+ }
174
+ }, RenderedRole>;
175
+ import { Registry as Registry2 } from "resourcexjs";
176
+ /**
177
+ * Create a resource resolver function
178
+ *
179
+ * @param registry - Registry instance (required for RxrTransport)
180
+ * @returns Resource resolver function that accepts ARP URLs
181
+ *
182
+ * @example
183
+ * ```typescript
184
+ * const resolver = createResourceResolver(registry);
185
+ * const content = await resolver('arp:text:rxr://localhost/my.role@1.0.0/thought/first.thought.md');
186
+ * ```
187
+ */
188
+ declare function createResourceResolver(registry: Registry2): ResourceResolver;
189
+ declare const VERSION: string;
190
+ export { thoughtSchema, roleType, roleTransformer, roleSchema, loadRole, knowledgeSchema, executionSchema, defineRoleSchemas, createResourceResolver, VERSION, ThoughtSubTag, RoleXError, RoleTransformer, RoleSchemas, RoleLoadError, ResourceResolver, ResourceResolveError, RenderedRole, ParsedThought, ParsedExecution, ExecutionSubTag, DPMLParseError };