@idiomark/projectors 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +253 -2
- package/dist/chunk-2DZ2XQGO.js +241 -0
- package/dist/chunk-2DZ2XQGO.js.map +1 -0
- package/dist/chunk-5CUPJM5O.js +920 -0
- package/dist/chunk-5CUPJM5O.js.map +1 -0
- package/dist/chunk-6UR4KMMX.js +275 -0
- package/dist/chunk-6UR4KMMX.js.map +1 -0
- package/dist/chunk-DH3HI5PA.js +453 -0
- package/dist/chunk-DH3HI5PA.js.map +1 -0
- package/dist/chunk-NWOITAMN.js +287 -0
- package/dist/chunk-NWOITAMN.js.map +1 -0
- package/dist/gaming/index.js +16 -0
- package/dist/gaming/index.js.map +1 -0
- package/dist/http/index.js +8 -0
- package/dist/http/index.js.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/index.js +8 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/ucp/index.js +8 -0
- package/dist/ucp/index.js.map +1 -0
- package/package.json +82 -5
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
// src/base.ts
|
|
2
|
+
import { EventEmitter } from "events";
|
|
3
|
+
var RateLimiter = class {
|
|
4
|
+
config;
|
|
5
|
+
requests = [];
|
|
6
|
+
emitter;
|
|
7
|
+
constructor(config, emitter) {
|
|
8
|
+
this.config = config;
|
|
9
|
+
this.emitter = emitter;
|
|
10
|
+
}
|
|
11
|
+
async throttle() {
|
|
12
|
+
const now = Date.now();
|
|
13
|
+
const windowStart = now - this.config.windowDuration;
|
|
14
|
+
this.requests = this.requests.filter((time) => time > windowStart);
|
|
15
|
+
if (this.requests.length >= this.config.maxRequests) {
|
|
16
|
+
const oldestRequest = this.requests[0];
|
|
17
|
+
const waitTime = oldestRequest + this.config.windowDuration - now;
|
|
18
|
+
this.emitter.emit("rateLimit", { waitTime });
|
|
19
|
+
await sleep(waitTime);
|
|
20
|
+
}
|
|
21
|
+
this.requests.push(now);
|
|
22
|
+
}
|
|
23
|
+
reset() {
|
|
24
|
+
this.requests = [];
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var CacheManager = class {
|
|
28
|
+
cache = /* @__PURE__ */ new Map();
|
|
29
|
+
config;
|
|
30
|
+
constructor(config) {
|
|
31
|
+
this.config = config;
|
|
32
|
+
}
|
|
33
|
+
async get(key) {
|
|
34
|
+
if (!this.config.enabled) return void 0;
|
|
35
|
+
const entry = this.cache.get(key);
|
|
36
|
+
if (!entry) return void 0;
|
|
37
|
+
if (Date.now() > entry.expiry) {
|
|
38
|
+
this.cache.delete(key);
|
|
39
|
+
return void 0;
|
|
40
|
+
}
|
|
41
|
+
return entry.value;
|
|
42
|
+
}
|
|
43
|
+
async set(key, value) {
|
|
44
|
+
if (!this.config.enabled) return;
|
|
45
|
+
this.cache.set(key, {
|
|
46
|
+
value,
|
|
47
|
+
expiry: Date.now() + this.config.ttl
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async clear() {
|
|
51
|
+
this.cache.clear();
|
|
52
|
+
}
|
|
53
|
+
async close() {
|
|
54
|
+
this.cache.clear();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var RetryHandler = class {
|
|
58
|
+
config;
|
|
59
|
+
emitter;
|
|
60
|
+
constructor(config, emitter) {
|
|
61
|
+
this.config = config;
|
|
62
|
+
this.emitter = emitter;
|
|
63
|
+
}
|
|
64
|
+
async execute(fn) {
|
|
65
|
+
let lastError;
|
|
66
|
+
for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {
|
|
67
|
+
try {
|
|
68
|
+
return await fn();
|
|
69
|
+
} catch (error) {
|
|
70
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
71
|
+
this.emitter.emit("retry", { attempt, error: lastError });
|
|
72
|
+
if (attempt < this.config.maxRetries) {
|
|
73
|
+
const delay = Math.min(
|
|
74
|
+
this.config.baseDelay * Math.pow(2, attempt),
|
|
75
|
+
this.config.maxDelay
|
|
76
|
+
);
|
|
77
|
+
await sleep(delay);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
throw lastError;
|
|
82
|
+
}
|
|
83
|
+
reset() {
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
var MetricsCollector = class {
|
|
87
|
+
metrics = /* @__PURE__ */ new Map();
|
|
88
|
+
latencies = [];
|
|
89
|
+
recordLatency(latency) {
|
|
90
|
+
this.latencies.push(latency);
|
|
91
|
+
}
|
|
92
|
+
increment(metric) {
|
|
93
|
+
const current = this.metrics.get(metric) || 0;
|
|
94
|
+
this.metrics.set(metric, current + 1);
|
|
95
|
+
}
|
|
96
|
+
getCount(metric) {
|
|
97
|
+
return this.metrics.get(metric) || 0;
|
|
98
|
+
}
|
|
99
|
+
getAverageLatency() {
|
|
100
|
+
if (this.latencies.length === 0) return 0;
|
|
101
|
+
const sum = this.latencies.reduce((a, b) => a + b, 0);
|
|
102
|
+
return sum / this.latencies.length;
|
|
103
|
+
}
|
|
104
|
+
reset() {
|
|
105
|
+
this.metrics.clear();
|
|
106
|
+
this.latencies = [];
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
function sleep(ms) {
|
|
110
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
111
|
+
}
|
|
112
|
+
var BaseProjectionAdapter = class {
|
|
113
|
+
name;
|
|
114
|
+
config;
|
|
115
|
+
personality = null;
|
|
116
|
+
// Built-in components (mirrors BaseAdapter)
|
|
117
|
+
rateLimiter;
|
|
118
|
+
cache;
|
|
119
|
+
retry;
|
|
120
|
+
metrics;
|
|
121
|
+
emitter;
|
|
122
|
+
constructor(name, config = { name }) {
|
|
123
|
+
this.name = name;
|
|
124
|
+
this.config = config;
|
|
125
|
+
this.emitter = new EventEmitter();
|
|
126
|
+
this.emitter.setMaxListeners(100);
|
|
127
|
+
this.rateLimiter = new RateLimiter(
|
|
128
|
+
config.rateLimiter || { maxRequests: 100, windowDuration: 6e4 },
|
|
129
|
+
this.emitter
|
|
130
|
+
);
|
|
131
|
+
this.cache = new CacheManager(
|
|
132
|
+
config.cache || { enabled: true, ttl: 3e5 }
|
|
133
|
+
);
|
|
134
|
+
this.retry = new RetryHandler(
|
|
135
|
+
config.retry || { maxRetries: 3, baseDelay: 1e3, maxDelay: 1e4 },
|
|
136
|
+
this.emitter
|
|
137
|
+
);
|
|
138
|
+
this.metrics = new MetricsCollector();
|
|
139
|
+
}
|
|
140
|
+
// ============================================================
|
|
141
|
+
// High-level methods
|
|
142
|
+
// ============================================================
|
|
143
|
+
/**
|
|
144
|
+
* Main projection method with caching, retry, and metrics
|
|
145
|
+
*/
|
|
146
|
+
async apply(options) {
|
|
147
|
+
const start = Date.now();
|
|
148
|
+
try {
|
|
149
|
+
if (!this.personality) {
|
|
150
|
+
this.personality = options.personality;
|
|
151
|
+
}
|
|
152
|
+
this.emitter.emit("projectionStart", { options });
|
|
153
|
+
const cacheKey = this.getCacheKey(options);
|
|
154
|
+
const cached = await this.cache.get(cacheKey);
|
|
155
|
+
if (cached) {
|
|
156
|
+
this.emitter.emit("cacheHit", { key: cacheKey });
|
|
157
|
+
return {
|
|
158
|
+
success: true,
|
|
159
|
+
content: cached[0]?.content || "",
|
|
160
|
+
duration: Date.now() - start
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
await this.rateLimiter.throttle();
|
|
164
|
+
const result = await this.retry.execute(async () => {
|
|
165
|
+
const output = await this.transform({ message: options.target || "", context: void 0 });
|
|
166
|
+
return await this.send(output);
|
|
167
|
+
});
|
|
168
|
+
if (result.success && result.content) {
|
|
169
|
+
await this.cache.set(cacheKey, [{ content: result.content, format: "text" }]);
|
|
170
|
+
}
|
|
171
|
+
const duration = Date.now() - start;
|
|
172
|
+
this.metrics.recordLatency(duration);
|
|
173
|
+
this.metrics.increment("requests");
|
|
174
|
+
this.metrics.increment(result.success ? "successes" : "failures");
|
|
175
|
+
this.emitter.emit("projectionComplete", { result, duration });
|
|
176
|
+
return {
|
|
177
|
+
...result,
|
|
178
|
+
duration
|
|
179
|
+
};
|
|
180
|
+
} catch (error) {
|
|
181
|
+
const duration = Date.now() - start;
|
|
182
|
+
this.metrics.increment("failures");
|
|
183
|
+
this.emitter.emit("projectionError", { error, duration });
|
|
184
|
+
return {
|
|
185
|
+
success: false,
|
|
186
|
+
error: error instanceof Error ? error.message : String(error),
|
|
187
|
+
duration
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Apply personality transformation to a message
|
|
193
|
+
* Subclasses can override for custom logic
|
|
194
|
+
*/
|
|
195
|
+
async applyPersonality(message, options = { mode: "balanced" }) {
|
|
196
|
+
if (!this.personality) {
|
|
197
|
+
throw new Error("Personality not loaded. Call apply() with ProjectionOptions first.");
|
|
198
|
+
}
|
|
199
|
+
const { buildSystemPrompt } = await import("@idiomark/inference");
|
|
200
|
+
const systemPrompt = buildSystemPrompt(this.personality, options.mode);
|
|
201
|
+
return `[System: ${systemPrompt}]
|
|
202
|
+
[User: ${message}]`;
|
|
203
|
+
}
|
|
204
|
+
// ============================================================
|
|
205
|
+
// Health & Metrics
|
|
206
|
+
// ============================================================
|
|
207
|
+
/**
|
|
208
|
+
* Health check for adapter
|
|
209
|
+
*/
|
|
210
|
+
async healthCheck() {
|
|
211
|
+
const start = Date.now();
|
|
212
|
+
try {
|
|
213
|
+
return {
|
|
214
|
+
healthy: true,
|
|
215
|
+
latency: Date.now() - start
|
|
216
|
+
};
|
|
217
|
+
} catch (error) {
|
|
218
|
+
return {
|
|
219
|
+
healthy: false,
|
|
220
|
+
latency: Date.now() - start,
|
|
221
|
+
error: error instanceof Error ? error.message : String(error)
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Get adapter metrics
|
|
227
|
+
*/
|
|
228
|
+
getMetrics() {
|
|
229
|
+
return {
|
|
230
|
+
requests: this.metrics.getCount("requests"),
|
|
231
|
+
successes: this.metrics.getCount("successes"),
|
|
232
|
+
failures: this.metrics.getCount("failures"),
|
|
233
|
+
avgLatency: this.metrics.getAverageLatency(),
|
|
234
|
+
totalRequestsProcessed: this.metrics.getCount("requests")
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
// ============================================================
|
|
238
|
+
// Utility methods
|
|
239
|
+
// ============================================================
|
|
240
|
+
/**
|
|
241
|
+
* Get adapter events
|
|
242
|
+
*/
|
|
243
|
+
on(event, listener) {
|
|
244
|
+
this.emitter.on(event, listener);
|
|
245
|
+
return this;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Remove event listener
|
|
249
|
+
*/
|
|
250
|
+
off(event, listener) {
|
|
251
|
+
this.emitter.off(event, listener);
|
|
252
|
+
return this;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Reset adapter state
|
|
256
|
+
*/
|
|
257
|
+
async reset() {
|
|
258
|
+
await this.cache.clear();
|
|
259
|
+
this.rateLimiter.reset();
|
|
260
|
+
this.retry.reset();
|
|
261
|
+
this.metrics.reset();
|
|
262
|
+
this.emitter.emit("reset");
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Dispose of adapter resources
|
|
266
|
+
*/
|
|
267
|
+
async dispose() {
|
|
268
|
+
await this.cache.close();
|
|
269
|
+
this.emitter.removeAllListeners();
|
|
270
|
+
this.emitter.emit("dispose");
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Generate cache key from options
|
|
274
|
+
*/
|
|
275
|
+
getCacheKey(options) {
|
|
276
|
+
return JSON.stringify({
|
|
277
|
+
target: options.target,
|
|
278
|
+
mode: options.mode,
|
|
279
|
+
personality: options.personality.personality?.voice?.tone?.primary || "default"
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
export {
|
|
285
|
+
BaseProjectionAdapter
|
|
286
|
+
};
|
|
287
|
+
//# sourceMappingURL=chunk-NWOITAMN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/base.ts"],"sourcesContent":["/**\n * Base Projection Adapter\n *\n * Mirrors BaseAdapter but for projecting Idiomark personalities\n * TO external systems instead of extracting FROM them.\n *\n * Direction: Idiomark Personality → External System\n */\n\nimport { EventEmitter } from 'events'\nimport type {\n ProjectionInput,\n ProjectionOutput,\n ProjectionOptions,\n ResponseResult,\n PersonalityMode,\n PersonalityTransformOptions,\n ProjectionHealth,\n ProjectionMetrics,\n ConversationContext\n} from './types'\nimport type { IdiomarkFile } from '@idiomark/core'\n\n// ============================================================\n// Local Utility Classes (simplified from core)\n// ============================================================\n\nexport interface RateLimiterConfig {\n maxRequests: number\n windowDuration: number\n}\n\nexport interface CacheConfig {\n enabled: boolean\n ttl: number\n}\n\nexport interface RetryConfig {\n maxRetries: number\n baseDelay: number\n maxDelay: number\n}\n\nclass RateLimiter {\n private config: RateLimiterConfig\n private requests: number[] = []\n private emitter: EventEmitter\n\n constructor(config: RateLimiterConfig, emitter: EventEmitter) {\n this.config = config\n this.emitter = emitter\n }\n\n async throttle(): Promise<void> {\n const now = Date.now()\n const windowStart = now - this.config.windowDuration\n\n // Clean old requests\n this.requests = this.requests.filter(time => time > windowStart)\n\n // Check if limit reached\n if (this.requests.length >= this.config.maxRequests) {\n const oldestRequest = this.requests[0]\n const waitTime = oldestRequest + this.config.windowDuration - now\n this.emitter.emit('rateLimit', { waitTime })\n await sleep(waitTime)\n }\n\n this.requests.push(now)\n }\n\n reset(): void {\n this.requests = []\n }\n}\n\nclass CacheManager {\n private cache = new Map<string, { value: unknown; expiry: number }>()\n private config: CacheConfig\n\n constructor(config: CacheConfig) {\n this.config = config\n }\n\n async get(key: string): Promise<unknown | undefined> {\n if (!this.config.enabled) return undefined\n\n const entry = this.cache.get(key)\n if (!entry) return undefined\n\n if (Date.now() > entry.expiry) {\n this.cache.delete(key)\n return undefined\n }\n\n return entry.value\n }\n\n async set(key: string, value: unknown): Promise<void> {\n if (!this.config.enabled) return\n\n this.cache.set(key, {\n value,\n expiry: Date.now() + this.config.ttl\n })\n }\n\n async clear(): Promise<void> {\n this.cache.clear()\n }\n\n async close(): Promise<void> {\n this.cache.clear()\n }\n}\n\nclass RetryHandler {\n private config: RetryConfig\n private emitter: EventEmitter\n\n constructor(config: RetryConfig, emitter: EventEmitter) {\n this.config = config\n this.emitter = emitter\n }\n\n async execute<T>(fn: () => Promise<T>): Promise<T> {\n let lastError: Error | undefined\n\n for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {\n try {\n return await fn()\n } catch (error) {\n lastError = error instanceof Error ? error : new Error(String(error))\n this.emitter.emit('retry', { attempt, error: lastError })\n\n if (attempt < this.config.maxRetries) {\n const delay = Math.min(\n this.config.baseDelay * Math.pow(2, attempt),\n this.config.maxDelay\n )\n await sleep(delay)\n }\n }\n }\n\n throw lastError\n }\n\n reset(): void {\n // Reset state if needed\n }\n}\n\nclass MetricsCollector {\n private metrics = new Map<string, number>()\n private latencies: number[] = []\n\n recordLatency(latency: number): void {\n this.latencies.push(latency)\n }\n\n increment(metric: string): void {\n const current = this.metrics.get(metric) || 0\n this.metrics.set(metric, current + 1)\n }\n\n getCount(metric: string): number {\n return this.metrics.get(metric) || 0\n }\n\n getAverageLatency(): number {\n if (this.latencies.length === 0) return 0\n const sum = this.latencies.reduce((a, b) => a + b, 0)\n return sum / this.latencies.length\n }\n\n reset(): void {\n this.metrics.clear()\n this.latencies = []\n }\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms))\n}\n\n// ============================================================\n// Configuration\n// ============================================================\n\nexport interface ProjectionAdapterConfig {\n name: string\n rateLimiter?: RateLimiterConfig\n cache?: CacheConfig\n retry?: RetryConfig\n}\n\nexport interface ProjectionProgress {\n processed: number\n total: number\n percent: number\n currentResult?: ResponseResult\n}\n\n// ============================================================\n// Base Projection Adapter\n// ============================================================\n\n/**\n * Base class for all projection adapters\n *\n * Provides:\n * - Rate limiting (for outgoing requests)\n * - Caching (for personality applications)\n * - Retry logic (for failed sends)\n * - Metrics collection\n * - Event emission\n */\nexport abstract class BaseProjectionAdapter {\n readonly name: string\n protected config: ProjectionAdapterConfig\n protected personality: IdiomarkFile | null = null\n\n // Built-in components (mirrors BaseAdapter)\n protected readonly rateLimiter: RateLimiter\n protected readonly cache: CacheManager\n protected readonly retry: RetryHandler\n protected readonly metrics: MetricsCollector\n protected readonly emitter: EventEmitter\n\n constructor(name: string, config: ProjectionAdapterConfig = { name }) {\n this.name = name\n this.config = config\n\n this.emitter = new EventEmitter()\n this.emitter.setMaxListeners(100)\n\n // Initialize components\n this.rateLimiter = new RateLimiter(\n config.rateLimiter || { maxRequests: 100, windowDuration: 60000 },\n this.emitter\n )\n\n this.cache = new CacheManager(\n config.cache || { enabled: true, ttl: 300000 }\n )\n\n this.retry = new RetryHandler(\n config.retry || { maxRetries: 3, baseDelay: 1000, maxDelay: 10000 },\n this.emitter\n )\n\n this.metrics = new MetricsCollector()\n }\n\n // ============================================================\n // Abstract methods (must be implemented by subclasses)\n // ============================================================\n\n /**\n * Transform input using personality into output format\n */\n abstract transform(input: ProjectionInput): Promise<ProjectionOutput>\n\n /**\n * Send output to target platform/system\n */\n abstract send(output: ProjectionOutput): Promise<ResponseResult>\n\n /**\n * Start the adapter (for server-type adapters)\n */\n abstract start?(options: ProjectionOptions): Promise<void>\n\n /**\n * Stop the adapter (cleanup resources)\n */\n abstract stop?(): Promise<void>\n\n // ============================================================\n // High-level methods\n // ============================================================\n\n /**\n * Main projection method with caching, retry, and metrics\n */\n async apply(options: ProjectionOptions): Promise<ResponseResult> {\n const start = Date.now()\n\n try {\n // Load personality\n if (!this.personality) {\n this.personality = options.personality\n }\n\n this.emitter.emit('projectionStart', { options })\n\n // Check cache\n const cacheKey = this.getCacheKey(options)\n const cached = await this.cache.get(cacheKey)\n if (cached) {\n this.emitter.emit('cacheHit', { key: cacheKey })\n return {\n success: true,\n content: cached[0]?.content || '',\n duration: Date.now() - start\n }\n }\n\n // Rate limit (for outgoing requests)\n await this.rateLimiter.throttle()\n\n // Transform and send with retry\n const result = await this.retry.execute(async () => {\n const output = await this.transform({ message: options.target || '', context: undefined })\n return await this.send(output)\n })\n\n // Cache successful results\n if (result.success && result.content) {\n await this.cache.set(cacheKey, [{ content: result.content, format: 'text' }])\n }\n\n // Record metrics\n const duration = Date.now() - start\n this.metrics.recordLatency(duration)\n this.metrics.increment('requests')\n this.metrics.increment(result.success ? 'successes' : 'failures')\n\n this.emitter.emit('projectionComplete', { result, duration })\n\n return {\n ...result,\n duration\n }\n\n } catch (error) {\n const duration = Date.now() - start\n this.metrics.increment('failures')\n\n this.emitter.emit('projectionError', { error, duration })\n\n return {\n success: false,\n error: error instanceof Error ? error.message : String(error),\n duration\n }\n }\n }\n\n /**\n * Apply personality transformation to a message\n * Subclasses can override for custom logic\n */\n protected async applyPersonality(\n message: string,\n options: PersonalityTransformOptions = { mode: 'balanced' }\n ): Promise<string> {\n if (!this.personality) {\n throw new Error('Personality not loaded. Call apply() with ProjectionOptions first.')\n }\n\n // Use the inference package to apply personality\n const { buildSystemPrompt } = await import('@idiomark/inference')\n\n const systemPrompt = buildSystemPrompt(this.personality, options.mode)\n\n // For now, return the system prompt + message\n // Subclasses can override to use actual LLM generation\n return `[System: ${systemPrompt}]\\n[User: ${message}]`\n }\n\n // ============================================================\n // Health & Metrics\n // ============================================================\n\n /**\n * Health check for adapter\n */\n async healthCheck(): Promise<ProjectionHealth> {\n const start = Date.now()\n\n try {\n return {\n healthy: true,\n latency: Date.now() - start\n }\n } catch (error) {\n return {\n healthy: false,\n latency: Date.now() - start,\n error: error instanceof Error ? error.message : String(error)\n }\n }\n }\n\n /**\n * Get adapter metrics\n */\n getMetrics(): ProjectionMetrics {\n return {\n requests: this.metrics.getCount('requests'),\n successes: this.metrics.getCount('successes'),\n failures: this.metrics.getCount('failures'),\n avgLatency: this.metrics.getAverageLatency(),\n totalRequestsProcessed: this.metrics.getCount('requests')\n }\n }\n\n // ============================================================\n // Utility methods\n // ============================================================\n\n /**\n * Get adapter events\n */\n on(event: string, listener: (...args: unknown[]) => void): this {\n this.emitter.on(event, listener)\n return this\n }\n\n /**\n * Remove event listener\n */\n off(event: string, listener: (...args: unknown[]) => void): this {\n this.emitter.off(event, listener)\n return this\n }\n\n /**\n * Reset adapter state\n */\n async reset(): Promise<void> {\n await this.cache.clear()\n this.rateLimiter.reset()\n this.retry.reset()\n this.metrics.reset()\n this.emitter.emit('reset')\n }\n\n /**\n * Dispose of adapter resources\n */\n async dispose(): Promise<void> {\n await this.cache.close()\n this.emitter.removeAllListeners()\n this.emitter.emit('dispose')\n }\n\n /**\n * Generate cache key from options\n */\n protected getCacheKey(options: ProjectionOptions): string {\n return JSON.stringify({\n target: options.target,\n mode: options.mode,\n personality: options.personality.personality?.voice?.tone?.primary || 'default'\n })\n }\n}\n\n// Re-export sleep utility\nexport { sleep }\n"],"mappings":";AASA,SAAS,oBAAoB;AAkC7B,IAAM,cAAN,MAAkB;AAAA,EACR;AAAA,EACA,WAAqB,CAAC;AAAA,EACtB;AAAA,EAER,YAAY,QAA2B,SAAuB;AAC5D,SAAK,SAAS;AACd,SAAK,UAAU;AAAA,EACjB;AAAA,EAEA,MAAM,WAA0B;AAC9B,UAAM,MAAM,KAAK,IAAI;AACrB,UAAM,cAAc,MAAM,KAAK,OAAO;AAGtC,SAAK,WAAW,KAAK,SAAS,OAAO,UAAQ,OAAO,WAAW;AAG/D,QAAI,KAAK,SAAS,UAAU,KAAK,OAAO,aAAa;AACnD,YAAM,gBAAgB,KAAK,SAAS,CAAC;AACrC,YAAM,WAAW,gBAAgB,KAAK,OAAO,iBAAiB;AAC9D,WAAK,QAAQ,KAAK,aAAa,EAAE,SAAS,CAAC;AAC3C,YAAM,MAAM,QAAQ;AAAA,IACtB;AAEA,SAAK,SAAS,KAAK,GAAG;AAAA,EACxB;AAAA,EAEA,QAAc;AACZ,SAAK,WAAW,CAAC;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
} from "../chunk-5CUPJM5O.js";
|
|
8
|
+
import "../chunk-NWOITAMN.js";
|
|
9
|
+
export {
|
|
10
|
+
FortniteAdapter,
|
|
11
|
+
GameAdapter,
|
|
12
|
+
MinecraftAdapter,
|
|
13
|
+
RobloxAdapter,
|
|
14
|
+
VRChatAdapter
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MCPServer
|
|
3
|
+
} from "./chunk-DH3HI5PA.js";
|
|
4
|
+
import {
|
|
5
|
+
UCPAdapter
|
|
6
|
+
} from "./chunk-2DZ2XQGO.js";
|
|
7
|
+
import {
|
|
8
|
+
HTTPServerAdapter
|
|
9
|
+
} from "./chunk-6UR4KMMX.js";
|
|
10
|
+
import {
|
|
11
|
+
FortniteAdapter,
|
|
12
|
+
GameAdapter,
|
|
13
|
+
MinecraftAdapter,
|
|
14
|
+
RobloxAdapter,
|
|
15
|
+
VRChatAdapter
|
|
16
|
+
} from "./chunk-5CUPJM5O.js";
|
|
17
|
+
import {
|
|
18
|
+
BaseProjectionAdapter
|
|
19
|
+
} from "./chunk-NWOITAMN.js";
|
|
20
|
+
export {
|
|
21
|
+
BaseProjectionAdapter,
|
|
22
|
+
FortniteAdapter,
|
|
23
|
+
GameAdapter,
|
|
24
|
+
HTTPServerAdapter,
|
|
25
|
+
MCPServer,
|
|
26
|
+
MinecraftAdapter,
|
|
27
|
+
RobloxAdapter,
|
|
28
|
+
UCPAdapter,
|
|
29
|
+
VRChatAdapter
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,83 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@idiomark/projectors",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
1
|
+
{
|
|
2
|
+
"name": "@idiomark/projectors",
|
|
3
|
+
"license": "MIT",
|
|
4
|
+
"version": "0.1.1",
|
|
5
|
+
"description": "Idiomark Projectors - Apply personalities to external systems (MCP, UCP, HTTP, Gaming)",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.mts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.mts"
|
|
13
|
+
},
|
|
14
|
+
"./mcp": {
|
|
15
|
+
"import": "./dist/mcp/index.js",
|
|
16
|
+
"types": "./dist/mcp/index.d.mts"
|
|
17
|
+
},
|
|
18
|
+
"./ucp": {
|
|
19
|
+
"import": "./dist/ucp/index.js",
|
|
20
|
+
"types": "./dist/ucp/index.d.mts"
|
|
21
|
+
},
|
|
22
|
+
"./http": {
|
|
23
|
+
"import": "./dist/http/index.js",
|
|
24
|
+
"types": "./dist/http/index.d.mts"
|
|
25
|
+
},
|
|
26
|
+
"./gaming": {
|
|
27
|
+
"import": "./dist/gaming/index.js",
|
|
28
|
+
"types": "./dist/gaming/index.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./gaming/minecraft": {
|
|
31
|
+
"import": "./dist/gaming/minecraft/index.js",
|
|
32
|
+
"types": "./dist/gaming/minecraft/index.d.ts"
|
|
33
|
+
},
|
|
34
|
+
"./gaming/roblox": {
|
|
35
|
+
"import": "./dist/gaming/roblox/index.js",
|
|
36
|
+
"types": "./dist/gaming/roblox/index.d.ts"
|
|
37
|
+
},
|
|
38
|
+
"./gaming/vrchat": {
|
|
39
|
+
"import": "./dist/gaming/vrchat/index.js",
|
|
40
|
+
"types": "./dist/gaming/vrchat/index.d.ts"
|
|
41
|
+
},
|
|
42
|
+
"./gaming/fortnite": {
|
|
43
|
+
"import": "./dist/gaming/fortnite/index.js",
|
|
44
|
+
"types": "./dist/gaming/fortnite/index.d.ts"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"dev": "tsup --watch",
|
|
49
|
+
"build": "tsup",
|
|
50
|
+
"test": "vitest run --passWithNoTests",
|
|
51
|
+
"lint": "eslint src/",
|
|
52
|
+
"clean": "rm -rf dist"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@idiomark/core": "^0.1.0",
|
|
56
|
+
"@idiomark/inference": "^0.1.0"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/node": "^22.13.5",
|
|
60
|
+
"tsup": "^8.4.0",
|
|
61
|
+
"typescript": "^5.7.3",
|
|
62
|
+
"vitest": "^3.0.7"
|
|
63
|
+
},
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">=18.0.0"
|
|
66
|
+
},
|
|
67
|
+
"files": [
|
|
68
|
+
"dist",
|
|
69
|
+
"README.md"
|
|
70
|
+
],
|
|
71
|
+
"repository": {
|
|
72
|
+
"type": "git",
|
|
73
|
+
"url": "git+https://github.com/idiomark/idiomark.git",
|
|
74
|
+
"directory": "packages/projectors"
|
|
75
|
+
},
|
|
76
|
+
"homepage": "https://github.com/idiomark/idiomark#readme",
|
|
77
|
+
"bugs": {
|
|
78
|
+
"url": "https://github.com/idiomark/idiomark/issues"
|
|
79
|
+
},
|
|
80
|
+
"publishConfig": {
|
|
81
|
+
"access": "public"
|
|
82
|
+
}
|
|
6
83
|
}
|