briyah 1.0.2 → 1.0.3
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/dist/server/src/ai/LLM/deepseek.service.js +1 -1
- package/package.json +2 -2
- package/dist/ai/LLM/anthropic.module.d.ts +0 -2
- package/dist/ai/LLM/anthropic.module.js +0 -21
- package/dist/ai/LLM/anthropic.service.d.ts +0 -27
- package/dist/ai/LLM/anthropic.service.js +0 -329
- package/dist/ai/LLM/base-ai.service.d.ts +0 -45
- package/dist/ai/LLM/base-ai.service.js +0 -409
- package/dist/ai/LLM/deepseek.module.d.ts +0 -2
- package/dist/ai/LLM/deepseek.module.js +0 -21
- package/dist/ai/LLM/deepseek.service.d.ts +0 -15
- package/dist/ai/LLM/deepseek.service.js +0 -279
- package/dist/ai/LLM/fal.module.d.ts +0 -2
- package/dist/ai/LLM/fal.module.js +0 -21
- package/dist/ai/LLM/fal.service.d.ts +0 -17
- package/dist/ai/LLM/fal.service.js +0 -314
- package/dist/ai/LLM/googleai.module.d.ts +0 -2
- package/dist/ai/LLM/googleai.module.js +0 -21
- package/dist/ai/LLM/googleai.service.d.ts +0 -20
- package/dist/ai/LLM/googleai.service.js +0 -271
- package/dist/ai/LLM/grok.module.d.ts +0 -2
- package/dist/ai/LLM/grok.module.js +0 -21
- package/dist/ai/LLM/grok.service.d.ts +0 -14
- package/dist/ai/LLM/grok.service.js +0 -263
- package/dist/ai/LLM/mock.module.d.ts +0 -2
- package/dist/ai/LLM/mock.module.js +0 -21
- package/dist/ai/LLM/mock.service.d.ts +0 -13
- package/dist/ai/LLM/mock.service.js +0 -194
- package/dist/ai/LLM/openai.module.d.ts +0 -2
- package/dist/ai/LLM/openai.module.js +0 -21
- package/dist/ai/LLM/openai.service.d.ts +0 -21
- package/dist/ai/LLM/openai.service.js +0 -421
- package/dist/ai/LLM/together.module.d.ts +0 -2
- package/dist/ai/LLM/together.module.js +0 -21
- package/dist/ai/LLM/together.service.d.ts +0 -18
- package/dist/ai/LLM/together.service.js +0 -285
- package/dist/ai/LLM/vertexai.module.d.ts +0 -2
- package/dist/ai/LLM/vertexai.module.js +0 -21
- package/dist/ai/LLM/vertexai.service.d.ts +0 -17
- package/dist/ai/LLM/vertexai.service.js +0 -323
- package/dist/ai/agent-config.d.ts +0 -32
- package/dist/ai/agent-config.js +0 -2
- package/dist/ai/agent-factory.d.ts +0 -15
- package/dist/ai/agent-factory.js +0 -24
- package/dist/ai/agent-message.service.d.ts +0 -9
- package/dist/ai/agent-message.service.js +0 -56
- package/dist/ai/agent-store.module.d.ts +0 -2
- package/dist/ai/agent-store.module.js +0 -21
- package/dist/ai/agent-store.service.d.ts +0 -31
- package/dist/ai/agent-store.service.js +0 -352
- package/dist/ai/agent.d.ts +0 -75
- package/dist/ai/agent.js +0 -174
- package/dist/ai/ai-factory.module.d.ts +0 -2
- package/dist/ai/ai-factory.module.js +0 -40
- package/dist/ai/ai-factory.service.d.ts +0 -24
- package/dist/ai/ai-factory.service.js +0 -94
- package/dist/ai/artifact.module.d.ts +0 -2
- package/dist/ai/artifact.module.js +0 -22
- package/dist/ai/artifact.service.d.ts +0 -21
- package/dist/ai/artifact.service.js +0 -239
- package/dist/ai/attached-file.module.d.ts +0 -2
- package/dist/ai/attached-file.module.js +0 -22
- package/dist/ai/attached-file.service.d.ts +0 -35
- package/dist/ai/attached-file.service.js +0 -253
- package/dist/ai/model_prices.d.ts +0 -2
- package/dist/ai/model_prices.js +0 -54
- package/dist/ai/published-agents.service.d.ts +0 -13
- package/dist/ai/published-agents.service.js +0 -118
- package/dist/app/balance-message.service.d.ts +0 -8
- package/dist/app/balance-message.service.js +0 -45
- package/dist/app/balance.module.d.ts +0 -2
- package/dist/app/balance.module.js +0 -20
- package/dist/app/balance.service.d.ts +0 -18
- package/dist/app/balance.service.js +0 -158
- package/dist/app/stripe.controller.d.ts +0 -31
- package/dist/app/stripe.controller.js +0 -150
- package/dist/app/stripe.module.d.ts +0 -2
- package/dist/app/stripe.module.js +0 -22
- package/dist/app/stripe.service.d.ts +0 -28
- package/dist/app/stripe.service.js +0 -198
- package/dist/app/transaction.service.d.ts +0 -15
- package/dist/app/transaction.service.js +0 -139
- package/dist/app/user-service-factory.d.ts +0 -21
- package/dist/app/user-service-factory.js +0 -81
- package/dist/app/user-service-manager.d.ts +0 -28
- package/dist/app/user-service-manager.js +0 -102
- package/dist/app.controller.d.ts +0 -232
- package/dist/app.controller.js +0 -2536
- package/dist/app.module.d.ts +0 -2
- package/dist/app.module.js +0 -45
- package/dist/app.service.d.ts +0 -186
- package/dist/app.service.js +0 -1334
- package/dist/auth/agent-access.decorator.d.ts +0 -2
- package/dist/auth/agent-access.decorator.js +0 -10
- package/dist/auth/auth.controller.d.ts +0 -38
- package/dist/auth/auth.controller.js +0 -356
- package/dist/auth/auth.module.d.ts +0 -2
- package/dist/auth/auth.module.js +0 -55
- package/dist/auth/auth.service.d.ts +0 -14
- package/dist/auth/auth.service.js +0 -84
- package/dist/auth/dto/bot-login.dto.d.ts +0 -4
- package/dist/auth/dto/bot-login.dto.js +0 -2
- package/dist/auth/dto/password-reset.dto.d.ts +0 -11
- package/dist/auth/dto/password-reset.dto.js +0 -2
- package/dist/auth/dto/phone-login.dto.d.ts +0 -8
- package/dist/auth/dto/phone-login.dto.js +0 -2
- package/dist/auth/dto/phone-verification.dto.d.ts +0 -9
- package/dist/auth/dto/phone-verification.dto.js +0 -2
- package/dist/auth/jwt-auth.guard.d.ts +0 -13
- package/dist/auth/jwt-auth.guard.js +0 -143
- package/dist/auth/jwt.strategy.d.ts +0 -17
- package/dist/auth/jwt.strategy.js +0 -45
- package/dist/auth/phone-validation.service.d.ts +0 -7
- package/dist/auth/phone-validation.service.js +0 -50
- package/dist/auth/public.decorator.d.ts +0 -2
- package/dist/auth/public.decorator.js +0 -7
- package/dist/auth/rate-limit.service.d.ts +0 -16
- package/dist/auth/rate-limit.service.js +0 -84
- package/dist/auth/room-access.decorator.d.ts +0 -2
- package/dist/auth/room-access.decorator.js +0 -10
- package/dist/auth/scopes.decorator.d.ts +0 -2
- package/dist/auth/scopes.decorator.js +0 -7
- package/dist/auth/scopes.guard.d.ts +0 -9
- package/dist/auth/scopes.guard.js +0 -82
- package/dist/auth/session.guard.d.ts +0 -7
- package/dist/auth/session.guard.js +0 -55
- package/dist/auth/twilio.service.d.ts +0 -15
- package/dist/auth/twilio.service.js +0 -139
- package/dist/auth/users.service.d.ts +0 -24
- package/dist/auth/users.service.js +0 -149
- package/dist/common/errors.d.ts +0 -12
- package/dist/common/errors.js +0 -43
- package/dist/config/configuration.module.d.ts +0 -2
- package/dist/config/configuration.module.js +0 -20
- package/dist/config/configuration.service.d.ts +0 -26
- package/dist/config/configuration.service.js +0 -131
- package/dist/main.js +0 -15749
- package/dist/room/artifact-store.service.d.ts +0 -15
- package/dist/room/artifact-store.service.js +0 -226
- package/dist/room/artifact.d.ts +0 -6
- package/dist/room/artifact.js +0 -2
- package/dist/room/message.d.ts +0 -19
- package/dist/room/message.js +0 -70
- package/dist/room/published-rooms.service.d.ts +0 -12
- package/dist/room/published-rooms.service.js +0 -108
- package/dist/room/room-config.d.ts +0 -12
- package/dist/room/room-config.js +0 -2
- package/dist/room/room-factory.d.ts +0 -7
- package/dist/room/room-factory.js +0 -16
- package/dist/room/room-message.module.d.ts +0 -2
- package/dist/room/room-message.module.js +0 -21
- package/dist/room/room-message.service.d.ts +0 -8
- package/dist/room/room-message.service.js +0 -44
- package/dist/room/room-store.module.d.ts +0 -2
- package/dist/room/room-store.module.js +0 -25
- package/dist/room/room-store.service.d.ts +0 -38
- package/dist/room/room-store.service.js +0 -353
- package/dist/room/room.d.ts +0 -107
- package/dist/room/room.js +0 -833
- package/dist/sdk/briyah-config.d.ts +0 -13
- package/dist/sdk/briyah-config.js +0 -32
- package/dist/sdk/briyah.d.ts +0 -36
- package/dist/sdk/briyah.js +0 -122
- package/dist/sdk/index.d.ts +0 -6
- package/dist/sdk/index.js +0 -11
- package/dist/shared/shared.module.d.ts +0 -2
- package/dist/shared/shared.module.js +0 -46
- package/dist/story/story-message.service.d.ts +0 -10
- package/dist/story/story-message.service.js +0 -57
- package/dist/story/story-progress.service.d.ts +0 -8
- package/dist/story/story-progress.service.js +0 -44
- package/dist/story/story-store.module.d.ts +0 -2
- package/dist/story/story-store.module.js +0 -22
- package/dist/story/story-store.service.d.ts +0 -23
- package/dist/story/story-store.service.js +0 -392
- package/dist/story/story.service.d.ts +0 -94
- package/dist/story/story.service.js +0 -1797
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Artifact } from './artifact';
|
|
2
|
-
export declare class ArtifactStoreService {
|
|
3
|
-
private readonly logger;
|
|
4
|
-
private readonly ARTIFACT_EXTENSION;
|
|
5
|
-
private readonly MAX_FILENAME_LENGTH;
|
|
6
|
-
private readonly UNSAFE_CHARS_REGEX;
|
|
7
|
-
saveArtifact(roomId: string, storageDir: string, artifact: Artifact): string;
|
|
8
|
-
loadArtifacts(roomId: string, storageDir: string): Artifact[];
|
|
9
|
-
deleteArtifact(roomId: string, storageDir: string, artifactName: string): boolean;
|
|
10
|
-
deleteAllArtifacts(roomId: string, storageDir: string): void;
|
|
11
|
-
sanitizeFilename(name: string, roomDir: string): string;
|
|
12
|
-
parseArtifactFile(content: string): Artifact | null;
|
|
13
|
-
formatArtifactFile(artifact: Artifact): string;
|
|
14
|
-
getArtifactFilePath(roomId: string, storageDir: string, sanitizedName: string): string;
|
|
15
|
-
}
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
var ArtifactStoreService_1;
|
|
42
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.ArtifactStoreService = void 0;
|
|
44
|
-
const common_1 = require("@nestjs/common");
|
|
45
|
-
const fs = __importStar(require("fs"));
|
|
46
|
-
const path = __importStar(require("path"));
|
|
47
|
-
let ArtifactStoreService = ArtifactStoreService_1 = class ArtifactStoreService {
|
|
48
|
-
logger = new common_1.Logger(ArtifactStoreService_1.name);
|
|
49
|
-
ARTIFACT_EXTENSION = '.artifact';
|
|
50
|
-
MAX_FILENAME_LENGTH = 200;
|
|
51
|
-
UNSAFE_CHARS_REGEX = /[<>:"/\\|?*]/g;
|
|
52
|
-
saveArtifact(roomId, storageDir, artifact) {
|
|
53
|
-
const roomDir = path.join(storageDir, roomId);
|
|
54
|
-
if (!fs.existsSync(roomDir)) {
|
|
55
|
-
fs.mkdirSync(roomDir, { recursive: true });
|
|
56
|
-
}
|
|
57
|
-
this.deleteArtifact(roomId, storageDir, artifact.name);
|
|
58
|
-
const sanitizedName = this.sanitizeFilename(artifact.name, roomDir);
|
|
59
|
-
const filePath = this.getArtifactFilePath(roomId, storageDir, sanitizedName);
|
|
60
|
-
const content = this.formatArtifactFile(artifact);
|
|
61
|
-
try {
|
|
62
|
-
fs.writeFileSync(filePath, content, 'utf-8');
|
|
63
|
-
this.logger.log(`Saved artifact "${artifact.name}" to ${filePath}`);
|
|
64
|
-
return filePath;
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
this.logger.error(`Failed to save artifact "${artifact.name}": ${error.message}`);
|
|
68
|
-
throw error;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
loadArtifacts(roomId, storageDir) {
|
|
72
|
-
const roomDir = path.join(storageDir, roomId);
|
|
73
|
-
if (!fs.existsSync(roomDir)) {
|
|
74
|
-
return [];
|
|
75
|
-
}
|
|
76
|
-
const artifacts = [];
|
|
77
|
-
try {
|
|
78
|
-
const files = fs.readdirSync(roomDir);
|
|
79
|
-
const artifactFiles = files.filter((file) => file.endsWith(this.ARTIFACT_EXTENSION));
|
|
80
|
-
for (const file of artifactFiles) {
|
|
81
|
-
const filePath = path.join(roomDir, file);
|
|
82
|
-
try {
|
|
83
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
84
|
-
const artifact = this.parseArtifactFile(content);
|
|
85
|
-
if (artifact) {
|
|
86
|
-
artifacts.push(artifact);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
this.logger.warn(`Skipping invalid artifact file: ${file}`);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
this.logger.error(`Error reading artifact file ${file}: ${error.message}`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
this.logger.log(`Loaded ${artifacts.length} artifacts for room ${roomId}`);
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
this.logger.error(`Error loading artifacts for room ${roomId}: ${error.message}`);
|
|
100
|
-
}
|
|
101
|
-
return artifacts;
|
|
102
|
-
}
|
|
103
|
-
deleteArtifact(roomId, storageDir, artifactName) {
|
|
104
|
-
const roomDir = path.join(storageDir, roomId);
|
|
105
|
-
if (!fs.existsSync(roomDir)) {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
try {
|
|
109
|
-
const files = fs.readdirSync(roomDir);
|
|
110
|
-
const artifactFiles = files.filter((file) => file.endsWith(this.ARTIFACT_EXTENSION));
|
|
111
|
-
for (const file of artifactFiles) {
|
|
112
|
-
const filePath = path.join(roomDir, file);
|
|
113
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
114
|
-
const artifact = this.parseArtifactFile(content);
|
|
115
|
-
if (artifact && artifact.name === artifactName) {
|
|
116
|
-
fs.unlinkSync(filePath);
|
|
117
|
-
this.logger.log(`Deleted artifact "${artifactName}" from ${filePath}`);
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
this.logger.error(`Error deleting artifact "${artifactName}": ${error.message}`);
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
deleteAllArtifacts(roomId, storageDir) {
|
|
129
|
-
const roomDir = path.join(storageDir, roomId);
|
|
130
|
-
if (!fs.existsSync(roomDir)) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
try {
|
|
134
|
-
const files = fs.readdirSync(roomDir);
|
|
135
|
-
const artifactFiles = files.filter((file) => file.endsWith(this.ARTIFACT_EXTENSION));
|
|
136
|
-
for (const file of artifactFiles) {
|
|
137
|
-
const filePath = path.join(roomDir, file);
|
|
138
|
-
fs.unlinkSync(filePath);
|
|
139
|
-
}
|
|
140
|
-
this.logger.log(`Deleted ${artifactFiles.length} artifact files from room ${roomId}`);
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
this.logger.error(`Error deleting artifacts for room ${roomId}: ${error.message}`);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
sanitizeFilename(name, roomDir) {
|
|
147
|
-
if (!name || name.trim().length === 0) {
|
|
148
|
-
throw new Error('Artifact name cannot be empty');
|
|
149
|
-
}
|
|
150
|
-
let sanitized = name.trim().replace(/^\.+|\.+$/g, '');
|
|
151
|
-
sanitized = sanitized.replace(this.UNSAFE_CHARS_REGEX, '_');
|
|
152
|
-
if (sanitized.length > this.MAX_FILENAME_LENGTH) {
|
|
153
|
-
sanitized = sanitized.substring(0, this.MAX_FILENAME_LENGTH);
|
|
154
|
-
}
|
|
155
|
-
let finalName = sanitized;
|
|
156
|
-
let counter = 2;
|
|
157
|
-
while (fs.existsSync(path.join(roomDir, finalName + this.ARTIFACT_EXTENSION))) {
|
|
158
|
-
finalName = `${sanitized}_${counter}`;
|
|
159
|
-
counter++;
|
|
160
|
-
if (counter > 1000) {
|
|
161
|
-
throw new Error(`Unable to generate unique filename for artifact "${name}"`);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return finalName;
|
|
165
|
-
}
|
|
166
|
-
parseArtifactFile(content) {
|
|
167
|
-
const lines = content.split('\n');
|
|
168
|
-
if (lines.length < 4) {
|
|
169
|
-
this.logger.error('Invalid artifact file: too few lines');
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
const nameLine = lines[0];
|
|
173
|
-
const creatorLine = lines[1];
|
|
174
|
-
const viewersLine = lines[2];
|
|
175
|
-
if (!nameLine.startsWith('# name: ')) {
|
|
176
|
-
this.logger.error('Invalid artifact file: missing or malformed name header');
|
|
177
|
-
return null;
|
|
178
|
-
}
|
|
179
|
-
const name = nameLine.substring('# name: '.length).trim();
|
|
180
|
-
if (!creatorLine.startsWith('# creator: ')) {
|
|
181
|
-
this.logger.error('Invalid artifact file: missing or malformed creator header');
|
|
182
|
-
return null;
|
|
183
|
-
}
|
|
184
|
-
const creator = creatorLine.substring('# creator: '.length).trim();
|
|
185
|
-
let viewers;
|
|
186
|
-
if (viewersLine.startsWith('# viewers: ')) {
|
|
187
|
-
const viewersStr = viewersLine.substring('# viewers: '.length).trim();
|
|
188
|
-
if (viewersStr.length > 0) {
|
|
189
|
-
viewers = viewersStr
|
|
190
|
-
.split(',')
|
|
191
|
-
.map((v) => v.trim())
|
|
192
|
-
.filter((v) => v.length > 0);
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
viewers = [creator];
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
viewers = [creator];
|
|
200
|
-
}
|
|
201
|
-
const body = lines.slice(3).join('\n');
|
|
202
|
-
return {
|
|
203
|
-
name,
|
|
204
|
-
creator,
|
|
205
|
-
body,
|
|
206
|
-
viewers,
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
formatArtifactFile(artifact) {
|
|
210
|
-
const viewersStr = artifact.viewers && artifact.viewers.length > 0
|
|
211
|
-
? artifact.viewers.join(', ')
|
|
212
|
-
: artifact.creator;
|
|
213
|
-
return `# name: ${artifact.name}
|
|
214
|
-
# creator: ${artifact.creator}
|
|
215
|
-
# viewers: ${viewersStr}
|
|
216
|
-
|
|
217
|
-
${artifact.body}`;
|
|
218
|
-
}
|
|
219
|
-
getArtifactFilePath(roomId, storageDir, sanitizedName) {
|
|
220
|
-
return path.join(storageDir, roomId, sanitizedName + this.ARTIFACT_EXTENSION);
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
exports.ArtifactStoreService = ArtifactStoreService;
|
|
224
|
-
exports.ArtifactStoreService = ArtifactStoreService = ArtifactStoreService_1 = __decorate([
|
|
225
|
-
(0, common_1.Injectable)()
|
|
226
|
-
], ArtifactStoreService);
|
package/dist/room/artifact.d.ts
DELETED
package/dist/room/artifact.js
DELETED
package/dist/room/message.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Message, MessageAction } from '../shared/types/app.types';
|
|
2
|
-
export declare class RoomMessage implements Message {
|
|
3
|
-
sender: string;
|
|
4
|
-
action: MessageAction;
|
|
5
|
-
content: string;
|
|
6
|
-
targets: string[];
|
|
7
|
-
timestamp: Date;
|
|
8
|
-
name?: string;
|
|
9
|
-
situation?: string;
|
|
10
|
-
index?: number;
|
|
11
|
-
constructor(sender: string, action: MessageAction, content: string, targets?: string[], name?: string, situation?: string);
|
|
12
|
-
getSender(): string;
|
|
13
|
-
getAction(): MessageAction;
|
|
14
|
-
getContent(): string;
|
|
15
|
-
getTargets(): string[];
|
|
16
|
-
getTimestamp(): Date;
|
|
17
|
-
isTarget(agentName: string): boolean;
|
|
18
|
-
canHear(agentNickname: string): boolean;
|
|
19
|
-
}
|
package/dist/room/message.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RoomMessage = void 0;
|
|
4
|
-
const app_types_1 = require("../shared/types/app.types");
|
|
5
|
-
class RoomMessage {
|
|
6
|
-
sender;
|
|
7
|
-
action;
|
|
8
|
-
content;
|
|
9
|
-
targets;
|
|
10
|
-
timestamp;
|
|
11
|
-
name;
|
|
12
|
-
situation;
|
|
13
|
-
index;
|
|
14
|
-
constructor(sender, action = app_types_1.MessageAction.SPEAK, content, targets = [], name, situation) {
|
|
15
|
-
this.sender = sender;
|
|
16
|
-
this.action = action;
|
|
17
|
-
this.content = content;
|
|
18
|
-
this.targets = targets;
|
|
19
|
-
this.name = name;
|
|
20
|
-
this.timestamp = new Date();
|
|
21
|
-
this.situation = situation;
|
|
22
|
-
}
|
|
23
|
-
getSender() {
|
|
24
|
-
return this.sender;
|
|
25
|
-
}
|
|
26
|
-
getAction() {
|
|
27
|
-
return this.action;
|
|
28
|
-
}
|
|
29
|
-
getContent() {
|
|
30
|
-
return this.content;
|
|
31
|
-
}
|
|
32
|
-
getTargets() {
|
|
33
|
-
return [...this.targets];
|
|
34
|
-
}
|
|
35
|
-
getTimestamp() {
|
|
36
|
-
return this.timestamp;
|
|
37
|
-
}
|
|
38
|
-
isTarget(agentName) {
|
|
39
|
-
if (this.action === app_types_1.MessageAction.SHOUT)
|
|
40
|
-
return true;
|
|
41
|
-
if (this.action === app_types_1.MessageAction.THINK) {
|
|
42
|
-
return this.sender === agentName;
|
|
43
|
-
}
|
|
44
|
-
if (this.action === app_types_1.MessageAction.WHISPER ||
|
|
45
|
-
this.action === app_types_1.MessageAction.RELAY ||
|
|
46
|
-
this.action === app_types_1.MessageAction.RELAY_SILENT) {
|
|
47
|
-
return this.targets.includes(agentName);
|
|
48
|
-
}
|
|
49
|
-
if (this.targets.length > 0) {
|
|
50
|
-
return this.targets.includes(agentName);
|
|
51
|
-
}
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
canHear(agentNickname) {
|
|
55
|
-
if (this.sender === agentNickname) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
if (this.action === app_types_1.MessageAction.RELAY || this.action === app_types_1.MessageAction.RELAY_SILENT)
|
|
59
|
-
return this.targets.includes(agentNickname);
|
|
60
|
-
if (this.action === app_types_1.MessageAction.PUBLISH)
|
|
61
|
-
return this.targets.includes(agentNickname) || this.targets.length === 0;
|
|
62
|
-
if (this.action === app_types_1.MessageAction.EXECUTE)
|
|
63
|
-
return this.targets.includes(agentNickname) || this.targets.length === 0;
|
|
64
|
-
if (this.action === app_types_1.MessageAction.WHISPER) {
|
|
65
|
-
return this.targets.includes(agentNickname);
|
|
66
|
-
}
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.RoomMessage = RoomMessage;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare class PublishedRoomsService {
|
|
2
|
-
private mapping;
|
|
3
|
-
private filePath;
|
|
4
|
-
constructor();
|
|
5
|
-
private load;
|
|
6
|
-
private save;
|
|
7
|
-
getUserId(roomId: string): string | undefined;
|
|
8
|
-
addPublishedRoom(roomId: string, userId: string): void;
|
|
9
|
-
removePublishedRoom(roomId: string): void;
|
|
10
|
-
isPublished(roomId: string): boolean;
|
|
11
|
-
getPublishedRoomsForUser(userId: string): string[];
|
|
12
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
-
var ownKeys = function(o) {
|
|
26
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
-
var ar = [];
|
|
28
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
return ownKeys(o);
|
|
32
|
-
};
|
|
33
|
-
return function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
})();
|
|
41
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
-
};
|
|
44
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.PublishedRoomsService = void 0;
|
|
46
|
-
const common_1 = require("@nestjs/common");
|
|
47
|
-
const fs = __importStar(require("fs"));
|
|
48
|
-
const path = __importStar(require("path"));
|
|
49
|
-
let PublishedRoomsService = class PublishedRoomsService {
|
|
50
|
-
mapping;
|
|
51
|
-
filePath;
|
|
52
|
-
constructor() {
|
|
53
|
-
this.filePath = path.join(process.cwd(), 'data', 'common', 'published-rooms.json');
|
|
54
|
-
this.mapping = new Map();
|
|
55
|
-
this.load();
|
|
56
|
-
}
|
|
57
|
-
load() {
|
|
58
|
-
try {
|
|
59
|
-
if (fs.existsSync(this.filePath)) {
|
|
60
|
-
const data = JSON.parse(fs.readFileSync(this.filePath, 'utf8'));
|
|
61
|
-
this.mapping = new Map(Object.entries(data.mapping));
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
console.error('Failed to load published rooms mapping:', error);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
save() {
|
|
69
|
-
try {
|
|
70
|
-
const dir = path.dirname(this.filePath);
|
|
71
|
-
if (!fs.existsSync(dir)) {
|
|
72
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
73
|
-
}
|
|
74
|
-
const data = {
|
|
75
|
-
mapping: Object.fromEntries(this.mapping),
|
|
76
|
-
version: 1,
|
|
77
|
-
};
|
|
78
|
-
fs.writeFileSync(this.filePath, JSON.stringify(data, null, 2));
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
console.error('Failed to save published rooms mapping:', error);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
getUserId(roomId) {
|
|
85
|
-
return this.mapping.get(roomId);
|
|
86
|
-
}
|
|
87
|
-
addPublishedRoom(roomId, userId) {
|
|
88
|
-
this.mapping.set(roomId, userId);
|
|
89
|
-
this.save();
|
|
90
|
-
}
|
|
91
|
-
removePublishedRoom(roomId) {
|
|
92
|
-
this.mapping.delete(roomId);
|
|
93
|
-
this.save();
|
|
94
|
-
}
|
|
95
|
-
isPublished(roomId) {
|
|
96
|
-
return this.mapping.has(roomId);
|
|
97
|
-
}
|
|
98
|
-
getPublishedRoomsForUser(userId) {
|
|
99
|
-
return (Array.from(this.mapping.entries())
|
|
100
|
-
.filter(([_roomId, uid]) => uid === userId)
|
|
101
|
-
.map(([roomId, _uid]) => roomId));
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
exports.PublishedRoomsService = PublishedRoomsService;
|
|
105
|
-
exports.PublishedRoomsService = PublishedRoomsService = __decorate([
|
|
106
|
-
(0, common_1.Injectable)(),
|
|
107
|
-
__metadata("design:paramtypes", [])
|
|
108
|
-
], PublishedRoomsService);
|
package/dist/room/room-config.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Room } from './room';
|
|
2
|
-
import { RoomStoreService } from './room-store.service';
|
|
3
|
-
export declare class RoomFactory {
|
|
4
|
-
private readonly roomStoreService;
|
|
5
|
-
constructor(roomStoreService: RoomStoreService);
|
|
6
|
-
createRoom(name: string, goal: string, baseRoomDir?: string, storageDir?: string): Room;
|
|
7
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RoomFactory = void 0;
|
|
4
|
-
const room_1 = require("./room");
|
|
5
|
-
class RoomFactory {
|
|
6
|
-
roomStoreService;
|
|
7
|
-
constructor(roomStoreService) {
|
|
8
|
-
this.roomStoreService = roomStoreService;
|
|
9
|
-
}
|
|
10
|
-
createRoom(name, goal, baseRoomDir = '', storageDir = '') {
|
|
11
|
-
const finalStorageDir = storageDir || this.roomStoreService.getDefaultStorageDir();
|
|
12
|
-
const room = new room_1.Room(null, name, goal, baseRoomDir, finalStorageDir, this.roomStoreService);
|
|
13
|
-
return room;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.RoomFactory = RoomFactory;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.RoomMessageModule = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const room_message_service_1 = require("./room-message.service");
|
|
12
|
-
let RoomMessageModule = class RoomMessageModule {
|
|
13
|
-
};
|
|
14
|
-
exports.RoomMessageModule = RoomMessageModule;
|
|
15
|
-
exports.RoomMessageModule = RoomMessageModule = __decorate([
|
|
16
|
-
(0, common_1.Module)({
|
|
17
|
-
imports: [],
|
|
18
|
-
providers: [room_message_service_1.RoomMessageService],
|
|
19
|
-
exports: [room_message_service_1.RoomMessageService],
|
|
20
|
-
})
|
|
21
|
-
], RoomMessageModule);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'events';
|
|
2
|
-
export declare class RoomMessageService {
|
|
3
|
-
private messageEmitters;
|
|
4
|
-
getOrCreateEmitter(roomId: string): EventEmitter;
|
|
5
|
-
emitUpdate(roomId: string, roomState: any): void;
|
|
6
|
-
emitError(roomId: string, error: Error): void;
|
|
7
|
-
cleanup(roomId: string): void;
|
|
8
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.RoomMessageService = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const events_1 = require("events");
|
|
12
|
-
let RoomMessageService = class RoomMessageService {
|
|
13
|
-
messageEmitters = new Map();
|
|
14
|
-
getOrCreateEmitter(roomId) {
|
|
15
|
-
if (!this.messageEmitters.has(roomId)) {
|
|
16
|
-
this.messageEmitters.set(roomId, new events_1.EventEmitter());
|
|
17
|
-
}
|
|
18
|
-
return this.messageEmitters.get(roomId);
|
|
19
|
-
}
|
|
20
|
-
emitUpdate(roomId, roomState) {
|
|
21
|
-
const emitter = this.getOrCreateEmitter(roomId);
|
|
22
|
-
emitter.emit('update', roomState);
|
|
23
|
-
}
|
|
24
|
-
emitError(roomId, error) {
|
|
25
|
-
const emitter = this.getOrCreateEmitter(roomId);
|
|
26
|
-
emitter.emit('update', {
|
|
27
|
-
timestamp: Date.now(),
|
|
28
|
-
type: 'error',
|
|
29
|
-
errorType: error.name,
|
|
30
|
-
message: error.message,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
cleanup(roomId) {
|
|
34
|
-
const emitter = this.messageEmitters.get(roomId);
|
|
35
|
-
if (emitter) {
|
|
36
|
-
emitter.removeAllListeners();
|
|
37
|
-
this.messageEmitters.delete(roomId);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
exports.RoomMessageService = RoomMessageService;
|
|
42
|
-
exports.RoomMessageService = RoomMessageService = __decorate([
|
|
43
|
-
(0, common_1.Injectable)()
|
|
44
|
-
], RoomMessageService);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.RoomStoreModule = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const room_store_service_1 = require("./room-store.service");
|
|
12
|
-
const artifact_store_service_1 = require("./artifact-store.service");
|
|
13
|
-
const configuration_module_1 = require("../config/configuration.module");
|
|
14
|
-
const agent_store_module_1 = require("../ai/agent-store.module");
|
|
15
|
-
const attached_file_module_1 = require("../ai/attached-file.module");
|
|
16
|
-
let RoomStoreModule = class RoomStoreModule {
|
|
17
|
-
};
|
|
18
|
-
exports.RoomStoreModule = RoomStoreModule;
|
|
19
|
-
exports.RoomStoreModule = RoomStoreModule = __decorate([
|
|
20
|
-
(0, common_1.Module)({
|
|
21
|
-
imports: [configuration_module_1.ConfigurationModule, agent_store_module_1.AgentStoreModule, attached_file_module_1.AttachedFileModule],
|
|
22
|
-
providers: [room_store_service_1.RoomStoreService, artifact_store_service_1.ArtifactStoreService],
|
|
23
|
-
exports: [room_store_service_1.RoomStoreService],
|
|
24
|
-
})
|
|
25
|
-
], RoomStoreModule);
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Room } from './room';
|
|
2
|
-
import { ConfigurationService } from '../config/configuration.service';
|
|
3
|
-
import { AgentStoreService } from '../ai/agent-store.service';
|
|
4
|
-
import { AttachedFileService } from '../ai/attached-file.service';
|
|
5
|
-
import { RoomInfo } from '../shared/types/app.types';
|
|
6
|
-
import { RoomMessage } from './message';
|
|
7
|
-
import { ArtifactStoreService } from './artifact-store.service';
|
|
8
|
-
import { Artifact } from './artifact';
|
|
9
|
-
export declare class RoomStoreService {
|
|
10
|
-
private readonly configService;
|
|
11
|
-
private readonly agentStore;
|
|
12
|
-
private readonly attachedFileService;
|
|
13
|
-
private readonly artifactStoreService;
|
|
14
|
-
private rooms;
|
|
15
|
-
private readonly defaultStorageDir;
|
|
16
|
-
private loaded;
|
|
17
|
-
private loadPromise;
|
|
18
|
-
constructor(configService: ConfigurationService, agentStore: AgentStoreService, attachedFileService: AttachedFileService, artifactStoreService: ArtifactStoreService);
|
|
19
|
-
getDefaultStorageDir(): string;
|
|
20
|
-
storeRoom(room: Room, storageDir?: string): string;
|
|
21
|
-
getRoom(id: string): Promise<Room | null>;
|
|
22
|
-
removeRoom(id: string, storageDir?: string, deleteAgents?: boolean): boolean;
|
|
23
|
-
getAllRoomIds(): Promise<string[]>;
|
|
24
|
-
getRoomCount(): number;
|
|
25
|
-
cloneRoomAsPublished(templateId: string, publishedName: string, userId: string): Promise<string>;
|
|
26
|
-
getPublishedInstances(templateId: string): Promise<Room[]>;
|
|
27
|
-
private ensureLoaded;
|
|
28
|
-
getAllRooms(): Promise<RoomInfo[]>;
|
|
29
|
-
readRoomMessagesFromFileAsync(messagesPath: string): Promise<RoomMessage[]>;
|
|
30
|
-
loadRoomsFromDirectory(storageDir: string): Promise<void>;
|
|
31
|
-
private saveRoomToFile;
|
|
32
|
-
appendMessageToFile(roomId: string, message: RoomMessage, storageDir: string): void;
|
|
33
|
-
clearRoomMessages(roomId: string, storageDir?: string): void;
|
|
34
|
-
saveArtifactFile(roomId: string, storageDir: string, artifact: Artifact): void;
|
|
35
|
-
deleteArtifactFile(roomId: string, storageDir: string, artifactName: string): boolean;
|
|
36
|
-
deleteAllArtifactFiles(roomId: string, storageDir: string): void;
|
|
37
|
-
private deleteRoomFile;
|
|
38
|
-
}
|