chatroom-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +86 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +29 -0
- package/dist/api.js.map +1 -0
- package/dist/commands/auth-login.d.ts +10 -0
- package/dist/commands/auth-login.d.ts.map +1 -0
- package/dist/commands/auth-login.js +165 -0
- package/dist/commands/auth-login.js.map +1 -0
- package/dist/commands/auth-logout.d.ts +6 -0
- package/dist/commands/auth-logout.d.ts.map +1 -0
- package/dist/commands/auth-logout.js +21 -0
- package/dist/commands/auth-logout.js.map +1 -0
- package/dist/commands/auth-status.d.ts +6 -0
- package/dist/commands/auth-status.d.ts.map +1 -0
- package/dist/commands/auth-status.js +50 -0
- package/dist/commands/auth-status.js.map +1 -0
- package/dist/commands/complete.d.ts +5 -0
- package/dist/commands/complete.d.ts.map +1 -0
- package/dist/commands/complete.js +36 -0
- package/dist/commands/complete.js.map +1 -0
- package/dist/commands/create.d.ts +9 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +58 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/init.d.ts +9 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +45 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list.d.ts +5 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +22 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/send.d.ts +11 -0
- package/dist/commands/send.d.ts.map +1 -0
- package/dist/commands/send.js +55 -0
- package/dist/commands/send.js.map +1 -0
- package/dist/commands/task-complete.d.ts +12 -0
- package/dist/commands/task-complete.d.ts.map +1 -0
- package/dist/commands/task-complete.js +58 -0
- package/dist/commands/task-complete.js.map +1 -0
- package/dist/commands/wait-for-message.d.ts +11 -0
- package/dist/commands/wait-for-message.d.ts.map +1 -0
- package/dist/commands/wait-for-message.js +249 -0
- package/dist/commands/wait-for-message.js.map +1 -0
- package/dist/config/defaults.d.ts +16 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +78 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/loader.d.ts +52 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +204 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +56 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +106 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +18 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +132 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/auth/middleware.d.ts +20 -0
- package/dist/infrastructure/auth/middleware.d.ts.map +1 -0
- package/dist/infrastructure/auth/middleware.js +86 -0
- package/dist/infrastructure/auth/middleware.js.map +1 -0
- package/dist/infrastructure/auth/storage.d.ts +44 -0
- package/dist/infrastructure/auth/storage.d.ts.map +1 -0
- package/dist/infrastructure/auth/storage.js +113 -0
- package/dist/infrastructure/auth/storage.js.map +1 -0
- package/dist/infrastructure/convex/client.d.ts +16 -0
- package/dist/infrastructure/convex/client.d.ts.map +1 -0
- package/dist/infrastructure/convex/client.js +52 -0
- package/dist/infrastructure/convex/client.js.map +1 -0
- package/dist/infrastructure/history/storage.d.ts +21 -0
- package/dist/infrastructure/history/storage.d.ts.map +1 -0
- package/dist/infrastructure/history/storage.js +56 -0
- package/dist/infrastructure/history/storage.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { join, dirname, resolve } from 'node:path';
|
|
4
|
+
import { DEFAULT_CONFIG, DEFAULT_CONFIG_JSONC } from './defaults';
|
|
5
|
+
import { getConfigErrors } from './schema';
|
|
6
|
+
const CONFIG_DIR = '.chatroom';
|
|
7
|
+
const CONFIG_FILENAME = 'chatroom.jsonc';
|
|
8
|
+
/**
|
|
9
|
+
* Get the global config path in user's home directory
|
|
10
|
+
*/
|
|
11
|
+
export function getGlobalConfigPath() {
|
|
12
|
+
return join(homedir(), CONFIG_DIR, CONFIG_FILENAME);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get the global config directory in user's home directory
|
|
16
|
+
*/
|
|
17
|
+
export function getGlobalConfigDir() {
|
|
18
|
+
return join(homedir(), CONFIG_DIR);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get the full path to the config file in a directory
|
|
22
|
+
*/
|
|
23
|
+
function getConfigPath(dir) {
|
|
24
|
+
return join(dir, CONFIG_DIR, CONFIG_FILENAME);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Strip comments from JSONC content
|
|
28
|
+
* Handles strings correctly to avoid removing // inside URLs
|
|
29
|
+
*/
|
|
30
|
+
function stripJsoncComments(content) {
|
|
31
|
+
let result = '';
|
|
32
|
+
let i = 0;
|
|
33
|
+
let inString = false;
|
|
34
|
+
let escape = false;
|
|
35
|
+
while (i < content.length) {
|
|
36
|
+
const char = content[i];
|
|
37
|
+
const next = content[i + 1];
|
|
38
|
+
if (escape) {
|
|
39
|
+
result += char;
|
|
40
|
+
escape = false;
|
|
41
|
+
i++;
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (char === '\\') {
|
|
45
|
+
result += char;
|
|
46
|
+
escape = true;
|
|
47
|
+
i++;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (char === '"') {
|
|
51
|
+
inString = !inString;
|
|
52
|
+
result += char;
|
|
53
|
+
i++;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (inString) {
|
|
57
|
+
result += char;
|
|
58
|
+
i++;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
// Single-line comment
|
|
62
|
+
if (char === '/' && next === '/') {
|
|
63
|
+
// Skip to end of line
|
|
64
|
+
while (i < content.length && content[i] !== '\n') {
|
|
65
|
+
i++;
|
|
66
|
+
}
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
// Multi-line comment
|
|
70
|
+
if (char === '/' && next === '*') {
|
|
71
|
+
i += 2; // Skip /*
|
|
72
|
+
while (i < content.length - 1 && !(content[i] === '*' && content[i + 1] === '/')) {
|
|
73
|
+
i++;
|
|
74
|
+
}
|
|
75
|
+
i += 2; // Skip */
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
result += char;
|
|
79
|
+
i++;
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Find the config file by walking up the directory tree to home directory
|
|
85
|
+
* Then falls back to the global config in ~/.chatroom/chatroom.jsonc
|
|
86
|
+
*/
|
|
87
|
+
export function findConfigPath(startDir = process.cwd()) {
|
|
88
|
+
const homeDir = homedir();
|
|
89
|
+
let currentDir = startDir;
|
|
90
|
+
// Walk up from startDir to home directory
|
|
91
|
+
while (true) {
|
|
92
|
+
const configPath = getConfigPath(currentDir);
|
|
93
|
+
if (existsSync(configPath)) {
|
|
94
|
+
return configPath;
|
|
95
|
+
}
|
|
96
|
+
// Stop when we've checked the home directory
|
|
97
|
+
if (currentDir === homeDir) {
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
const parentDir = dirname(currentDir);
|
|
101
|
+
if (parentDir === currentDir) {
|
|
102
|
+
// Reached filesystem root without hitting home
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
currentDir = parentDir;
|
|
106
|
+
}
|
|
107
|
+
// Finally check global config path
|
|
108
|
+
const globalPath = getGlobalConfigPath();
|
|
109
|
+
if (existsSync(globalPath)) {
|
|
110
|
+
return globalPath;
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Create a global config file with the given Convex URL
|
|
116
|
+
*/
|
|
117
|
+
export function createGlobalConfig(convexUrl) {
|
|
118
|
+
const globalDir = getGlobalConfigDir();
|
|
119
|
+
// Create .chatroom directory if it doesn't exist
|
|
120
|
+
if (!existsSync(globalDir)) {
|
|
121
|
+
mkdirSync(globalDir, { recursive: true });
|
|
122
|
+
}
|
|
123
|
+
// Create the config file with the provided URL
|
|
124
|
+
const configContent = DEFAULT_CONFIG_JSONC.replace(/"convexUrl": "[^"]*"/, `"convexUrl": "${convexUrl}"`);
|
|
125
|
+
const configPath = getGlobalConfigPath();
|
|
126
|
+
writeFileSync(configPath, configContent, 'utf-8');
|
|
127
|
+
return configPath;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Load and parse the configuration file
|
|
131
|
+
* Returns null if file doesn't exist, throws on parse/validation errors
|
|
132
|
+
*/
|
|
133
|
+
export function loadConfigFromPath(configPath) {
|
|
134
|
+
const content = readFileSync(configPath, 'utf-8');
|
|
135
|
+
// Strip comments and parse JSON
|
|
136
|
+
const jsonContent = stripJsoncComments(content);
|
|
137
|
+
let parsed;
|
|
138
|
+
try {
|
|
139
|
+
parsed = JSON.parse(jsonContent);
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
const err = error;
|
|
143
|
+
throw new Error(`Failed to parse ${configPath}: ${err.message}`);
|
|
144
|
+
}
|
|
145
|
+
// Validate the configuration
|
|
146
|
+
const errors = getConfigErrors(parsed);
|
|
147
|
+
if (errors.length > 0) {
|
|
148
|
+
throw new Error(`Invalid configuration in ${configPath}:\n - ${errors.join('\n - ')}`);
|
|
149
|
+
}
|
|
150
|
+
return parsed;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Load configuration from the nearest .chatroom/chatroom.jsonc or return defaults
|
|
154
|
+
*/
|
|
155
|
+
export function loadConfig(startDir = process.cwd()) {
|
|
156
|
+
const configPath = findConfigPath(startDir);
|
|
157
|
+
if (!configPath) {
|
|
158
|
+
return { config: DEFAULT_CONFIG, configPath: null };
|
|
159
|
+
}
|
|
160
|
+
const config = loadConfigFromPath(configPath);
|
|
161
|
+
return { config, configPath };
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Get a specific team from the configuration
|
|
165
|
+
*/
|
|
166
|
+
export function getTeam(config, teamId) {
|
|
167
|
+
return config.teams[teamId] ?? null;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Get the default team from the configuration
|
|
171
|
+
*/
|
|
172
|
+
export function getDefaultTeam(config) {
|
|
173
|
+
const team = config.teams[config.defaultTeam];
|
|
174
|
+
if (!team) {
|
|
175
|
+
throw new Error(`Default team '${config.defaultTeam}' not found in configuration`);
|
|
176
|
+
}
|
|
177
|
+
return team;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* List all available team IDs
|
|
181
|
+
*/
|
|
182
|
+
export function getTeamIds(config) {
|
|
183
|
+
return Object.keys(config.teams);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Load a prompt override file from a path (relative to config file or absolute)
|
|
187
|
+
* Returns null if the file doesn't exist
|
|
188
|
+
*/
|
|
189
|
+
export function loadPromptOverride(promptPath, configPath) {
|
|
190
|
+
// Resolve the path relative to the config file directory (or cwd)
|
|
191
|
+
const baseDir = configPath ? dirname(configPath) : process.cwd();
|
|
192
|
+
const resolvedPath = resolve(baseDir, promptPath);
|
|
193
|
+
if (!existsSync(resolvedPath)) {
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
return readFileSync(resolvedPath, 'utf-8');
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Check if system reminders are enabled in the configuration
|
|
200
|
+
*/
|
|
201
|
+
export function areSystemRemindersEnabled(config) {
|
|
202
|
+
return config.prompts?.systemReminders?.enabled !== false;
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=loader.js.map
|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/**
|
|
7
|
+
* Definition of an agent team
|
|
8
|
+
*/
|
|
9
|
+
export interface TeamDefinition {
|
|
10
|
+
/** Display name for the team */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Human-readable description of the team's purpose */
|
|
13
|
+
description: string;
|
|
14
|
+
/** List of role IDs that make up this team (order defines workflow priority) */
|
|
15
|
+
roles: string[];
|
|
16
|
+
/** Role that receives all user messages (defaults to first role in roles array) */
|
|
17
|
+
entryPoint?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Configuration for prompt overrides
|
|
21
|
+
*/
|
|
22
|
+
export interface PromptsConfig {
|
|
23
|
+
/** Path to custom init prompt file (replaces entire init prompt) */
|
|
24
|
+
initPrompt?: string;
|
|
25
|
+
/** System reminder configuration */
|
|
26
|
+
systemReminders?: {
|
|
27
|
+
/** Whether system reminders are enabled (default: true) */
|
|
28
|
+
enabled?: boolean;
|
|
29
|
+
/** Path to custom wait reminder file */
|
|
30
|
+
waitReminder?: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Root configuration structure for .chatroom/chatroom.jsonc
|
|
35
|
+
*/
|
|
36
|
+
export interface ChatroomConfig {
|
|
37
|
+
/** Convex deployment URL (required) */
|
|
38
|
+
convexUrl: string;
|
|
39
|
+
/** Webapp URL for browser-based operations like auth (optional, defaults to http://localhost:3000) */
|
|
40
|
+
webappUrl?: string;
|
|
41
|
+
/** ID of the team to use when --team is not specified */
|
|
42
|
+
defaultTeam: string;
|
|
43
|
+
/** Map of team ID to team definition */
|
|
44
|
+
teams: Record<string, TeamDefinition>;
|
|
45
|
+
/** Optional prompt customization */
|
|
46
|
+
prompts?: PromptsConfig;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Validate that a configuration object is valid
|
|
50
|
+
*/
|
|
51
|
+
export declare function validateConfig(config: unknown): config is ChatroomConfig;
|
|
52
|
+
/**
|
|
53
|
+
* Get validation errors for a configuration (for better error messages)
|
|
54
|
+
*/
|
|
55
|
+
export declare function getConfigErrors(config: unknown): string[];
|
|
56
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,mFAAmF;IACnF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,eAAe,CAAC,EAAE;QAChB,2DAA2D;QAC3D,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,wCAAwC;QACxC,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,sGAAsG;IACtG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,WAAW,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACtC,oCAAoC;IACpC,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,cAAc,CAuDxE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,CAgEzD"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Schema
|
|
3
|
+
*
|
|
4
|
+
* Defines the structure of .chatroom/chatroom.jsonc configuration files.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Validate that a configuration object is valid
|
|
8
|
+
*/
|
|
9
|
+
export function validateConfig(config) {
|
|
10
|
+
if (!config || typeof config !== 'object') {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const c = config;
|
|
14
|
+
// Check convexUrl
|
|
15
|
+
if (typeof c.convexUrl !== 'string' || c.convexUrl.length === 0) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
// Check defaultTeam
|
|
19
|
+
if (typeof c.defaultTeam !== 'string' || c.defaultTeam.length === 0) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
// Check teams
|
|
23
|
+
if (!c.teams || typeof c.teams !== 'object') {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
const teams = c.teams;
|
|
27
|
+
// Validate each team
|
|
28
|
+
for (const [, team] of Object.entries(teams)) {
|
|
29
|
+
if (!team || typeof team !== 'object') {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const t = team;
|
|
33
|
+
if (typeof t.name !== 'string' || t.name.length === 0) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (typeof t.description !== 'string') {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
if (!Array.isArray(t.roles) || t.roles.length === 0) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
if (!t.roles.every((r) => typeof r === 'string' && r.length > 0)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Check that defaultTeam exists in teams
|
|
47
|
+
if (!(c.defaultTeam in teams)) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get validation errors for a configuration (for better error messages)
|
|
54
|
+
*/
|
|
55
|
+
export function getConfigErrors(config) {
|
|
56
|
+
const errors = [];
|
|
57
|
+
if (!config || typeof config !== 'object') {
|
|
58
|
+
errors.push('Configuration must be an object');
|
|
59
|
+
return errors;
|
|
60
|
+
}
|
|
61
|
+
const c = config;
|
|
62
|
+
if (typeof c.convexUrl !== 'string' || c.convexUrl.length === 0) {
|
|
63
|
+
errors.push("'convexUrl' must be a non-empty string");
|
|
64
|
+
}
|
|
65
|
+
if (typeof c.defaultTeam !== 'string' || c.defaultTeam.length === 0) {
|
|
66
|
+
errors.push("'defaultTeam' must be a non-empty string");
|
|
67
|
+
}
|
|
68
|
+
if (!c.teams || typeof c.teams !== 'object') {
|
|
69
|
+
errors.push("'teams' must be an object");
|
|
70
|
+
return errors;
|
|
71
|
+
}
|
|
72
|
+
const teams = c.teams;
|
|
73
|
+
if (Object.keys(teams).length === 0) {
|
|
74
|
+
errors.push("'teams' must contain at least one team");
|
|
75
|
+
}
|
|
76
|
+
for (const [teamId, team] of Object.entries(teams)) {
|
|
77
|
+
if (!team || typeof team !== 'object') {
|
|
78
|
+
errors.push(`Team '${teamId}' must be an object`);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const t = team;
|
|
82
|
+
if (typeof t.name !== 'string' || t.name.length === 0) {
|
|
83
|
+
errors.push(`Team '${teamId}' must have a non-empty 'name'`);
|
|
84
|
+
}
|
|
85
|
+
if (typeof t.description !== 'string') {
|
|
86
|
+
errors.push(`Team '${teamId}' must have a 'description'`);
|
|
87
|
+
}
|
|
88
|
+
if (!Array.isArray(t.roles)) {
|
|
89
|
+
errors.push(`Team '${teamId}' must have a 'roles' array`);
|
|
90
|
+
}
|
|
91
|
+
else if (t.roles.length === 0) {
|
|
92
|
+
errors.push(`Team '${teamId}' must have at least one role`);
|
|
93
|
+
}
|
|
94
|
+
else if (!t.roles.every((r) => typeof r === 'string' && r.length > 0)) {
|
|
95
|
+
errors.push(`Team '${teamId}' roles must all be non-empty strings`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (typeof c.defaultTeam === 'string' &&
|
|
99
|
+
c.teams &&
|
|
100
|
+
typeof c.teams === 'object' &&
|
|
101
|
+
!(c.defaultTeam in c.teams)) {
|
|
102
|
+
errors.push(`'defaultTeam' value '${c.defaultTeam}' does not exist in 'teams'`);
|
|
103
|
+
}
|
|
104
|
+
return errors;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA+CH;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,MAAe;IAC5C,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,GAAG,MAAiC,CAAC;IAE5C,kBAAkB;IAClB,IAAI,OAAO,CAAC,CAAC,SAAS,KAAK,QAAQ,IAAI,CAAC,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,oBAAoB;IACpB,IAAI,OAAO,CAAC,CAAC,WAAW,KAAK,QAAQ,IAAI,CAAC,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,cAAc;IACd,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,KAAK,GAAG,CAAC,CAAC,KAAgC,CAAC;IAEjD,qBAAqB;IACrB,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7C,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,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CAAC;QAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5B,MAAM,CAAC,IAAI,CAAC,SAAS,MAAM,6BAA6B,CAAC,CAAC;QAC5D,CAAC;aAAM,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAChC,MAAM,CAAC,IAAI,CAAC,SAAS,MAAM,+BAA+B,CAAC,CAAC;QAC9D,CAAC;aAAM,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;YACxE,MAAM,CAAC,IAAI,CAAC,SAAS,MAAM,uCAAuC,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;IAED,IACE,OAAO,CAAC,CAAC,WAAW,KAAK,QAAQ;QACjC,CAAC,CAAC,KAAK;QACP,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ;QAC3B,CAAC,CAAC,CAAC,CAAC,WAAW,IAAK,CAAC,CAAC,KAAgB,CAAC,EACvC,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,WAAW,6BAA6B,CAAC,CAAC;IAClF,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chatroom CLI Configuration
|
|
3
|
+
*
|
|
4
|
+
* Centralized configuration for CLI behavior, polling intervals, and timeouts.
|
|
5
|
+
*/
|
|
6
|
+
/** Polling interval for the create command (monitoring chatroom) */
|
|
7
|
+
export declare const CREATE_POLL_INTERVAL_MS = 1000;
|
|
8
|
+
/** Polling interval for wait-for-message command */
|
|
9
|
+
export declare const WAIT_POLL_INTERVAL_MS = 500;
|
|
10
|
+
/** Default timeout for wait-for-message (5 minutes) */
|
|
11
|
+
export declare const DEFAULT_WAIT_TIMEOUT_MS: number;
|
|
12
|
+
/** Maximum consecutive errors before logging a warning */
|
|
13
|
+
export declare const MAX_SILENT_ERRORS = 5;
|
|
14
|
+
/** Maximum messages to fetch for context lookup */
|
|
15
|
+
export declare const MAX_MESSAGES_FOR_CONTEXT = 100;
|
|
16
|
+
/** Web server port for dashboard UI */
|
|
17
|
+
export declare const WEB_SERVER_PORT: number;
|
|
18
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,oEAAoE;AACpE,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C,oDAAoD;AACpD,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC,uDAAuD;AACvD,eAAO,MAAM,uBAAuB,QAAgB,CAAC;AAErD,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC,mDAAmD;AACnD,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,uCAAuC;AACvC,eAAO,MAAM,eAAe,QAA+C,CAAC"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chatroom CLI Configuration
|
|
3
|
+
*
|
|
4
|
+
* Centralized configuration for CLI behavior, polling intervals, and timeouts.
|
|
5
|
+
*/
|
|
6
|
+
/** Polling interval for the create command (monitoring chatroom) */
|
|
7
|
+
export const CREATE_POLL_INTERVAL_MS = 1000;
|
|
8
|
+
/** Polling interval for wait-for-message command */
|
|
9
|
+
export const WAIT_POLL_INTERVAL_MS = 500;
|
|
10
|
+
/** Default timeout for wait-for-message (5 minutes) */
|
|
11
|
+
export const DEFAULT_WAIT_TIMEOUT_MS = 5 * 60 * 1000;
|
|
12
|
+
/** Maximum consecutive errors before logging a warning */
|
|
13
|
+
export const MAX_SILENT_ERRORS = 5;
|
|
14
|
+
/** Maximum messages to fetch for context lookup */
|
|
15
|
+
export const MAX_MESSAGES_FOR_CONTEXT = 100;
|
|
16
|
+
/** Web server port for dashboard UI */
|
|
17
|
+
export const WEB_SERVER_PORT = parseInt(process.env.WEB_PORT || '3456', 10);
|
|
18
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,oEAAoE;AACpE,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAE5C,oDAAoD;AACpD,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAEzC,uDAAuD;AACvD,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAErD,0DAA0D;AAC1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC,mDAAmD;AACnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C,uCAAuC;AACvC,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,MAAM,EAAE,EAAE,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* Chatroom CLI
|
|
4
|
+
*
|
|
5
|
+
* CLI for multi-agent chatroom collaboration.
|
|
6
|
+
* Run `chatroom --help` for usage information.
|
|
7
|
+
*/
|
|
8
|
+
import { Command } from 'commander';
|
|
9
|
+
const program = new Command();
|
|
10
|
+
program
|
|
11
|
+
.name('chatroom')
|
|
12
|
+
.description('CLI for multi-agent chatroom collaboration')
|
|
13
|
+
.version('1.0.0')
|
|
14
|
+
.option('--skip-auth', 'Skip authentication check (development only)');
|
|
15
|
+
// Helper to check if auth should be skipped
|
|
16
|
+
function shouldSkipAuth() {
|
|
17
|
+
// Check global options
|
|
18
|
+
const opts = program.opts();
|
|
19
|
+
return opts.skipAuth === true;
|
|
20
|
+
}
|
|
21
|
+
// Helper to conditionally require auth
|
|
22
|
+
async function maybeRequireAuth() {
|
|
23
|
+
if (shouldSkipAuth()) {
|
|
24
|
+
console.log('⚠️ Skipping authentication (--skip-auth flag)');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const { requireAuth } = await import('./infrastructure/auth/middleware.js');
|
|
28
|
+
await requireAuth();
|
|
29
|
+
}
|
|
30
|
+
// ============================================================================
|
|
31
|
+
// AUTH COMMANDS (no auth required)
|
|
32
|
+
// ============================================================================
|
|
33
|
+
const authCommand = program.command('auth').description('Manage CLI authentication');
|
|
34
|
+
authCommand
|
|
35
|
+
.command('login')
|
|
36
|
+
.description('Authenticate the CLI via browser')
|
|
37
|
+
.option('-f, --force', 'Re-authenticate even if already logged in')
|
|
38
|
+
.action(async (options) => {
|
|
39
|
+
const { authLogin } = await import('./commands/auth-login.js');
|
|
40
|
+
await authLogin(options);
|
|
41
|
+
});
|
|
42
|
+
authCommand
|
|
43
|
+
.command('logout')
|
|
44
|
+
.description('Clear CLI authentication')
|
|
45
|
+
.action(async () => {
|
|
46
|
+
const { authLogout } = await import('./commands/auth-logout.js');
|
|
47
|
+
await authLogout();
|
|
48
|
+
});
|
|
49
|
+
authCommand
|
|
50
|
+
.command('status')
|
|
51
|
+
.description('Show current authentication status')
|
|
52
|
+
.action(async () => {
|
|
53
|
+
const { authStatus } = await import('./commands/auth-status.js');
|
|
54
|
+
await authStatus();
|
|
55
|
+
});
|
|
56
|
+
// ============================================================================
|
|
57
|
+
// INIT COMMAND (no auth required)
|
|
58
|
+
// ============================================================================
|
|
59
|
+
program
|
|
60
|
+
.command('init')
|
|
61
|
+
.description('Initialize configuration file (.chatroom/chatroom.jsonc)')
|
|
62
|
+
.option('-f, --force', 'Overwrite existing configuration')
|
|
63
|
+
.action(async (options) => {
|
|
64
|
+
const { initConfig } = await import('./commands/init.js');
|
|
65
|
+
await initConfig(options);
|
|
66
|
+
});
|
|
67
|
+
// ============================================================================
|
|
68
|
+
// CHATROOM COMMANDS (auth required unless --skip-auth)
|
|
69
|
+
// ============================================================================
|
|
70
|
+
program
|
|
71
|
+
.command('create')
|
|
72
|
+
.description('Create a new chatroom')
|
|
73
|
+
.option('-t, --team <teamId>', 'Team to use (default: from config)')
|
|
74
|
+
.action(async (options) => {
|
|
75
|
+
await maybeRequireAuth();
|
|
76
|
+
const { createChatroom } = await import('./commands/create.js');
|
|
77
|
+
await createChatroom(options);
|
|
78
|
+
});
|
|
79
|
+
program
|
|
80
|
+
.command('list')
|
|
81
|
+
.description('List chatroom history')
|
|
82
|
+
.action(async () => {
|
|
83
|
+
await maybeRequireAuth();
|
|
84
|
+
const { listChatrooms } = await import('./commands/list.js');
|
|
85
|
+
await listChatrooms();
|
|
86
|
+
});
|
|
87
|
+
program
|
|
88
|
+
.command('complete <chatroomId>')
|
|
89
|
+
.description('Mark a chatroom as completed')
|
|
90
|
+
.action(async (chatroomId) => {
|
|
91
|
+
await maybeRequireAuth();
|
|
92
|
+
const { completeChatroom } = await import('./commands/complete.js');
|
|
93
|
+
await completeChatroom(chatroomId);
|
|
94
|
+
});
|
|
95
|
+
program
|
|
96
|
+
.command('wait-for-message <chatroomId>')
|
|
97
|
+
.description('Join a chatroom and wait for messages')
|
|
98
|
+
.requiredOption('--role <role>', 'Role to join as (e.g., builder, reviewer)')
|
|
99
|
+
.option('--timeout <ms>', 'Optional timeout in milliseconds')
|
|
100
|
+
.action(async (chatroomId, options) => {
|
|
101
|
+
await maybeRequireAuth();
|
|
102
|
+
const { waitForMessage } = await import('./commands/wait-for-message.js');
|
|
103
|
+
await waitForMessage(chatroomId, {
|
|
104
|
+
role: options.role,
|
|
105
|
+
timeout: options.timeout ? parseInt(options.timeout, 10) : undefined,
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
program
|
|
109
|
+
.command('send <chatroomId>')
|
|
110
|
+
.description('Send a message to a chatroom')
|
|
111
|
+
.requiredOption('--message <message>', 'Message content to send')
|
|
112
|
+
.option('--role <role>', 'Sender role', 'user')
|
|
113
|
+
.option('--skip-ready-check', 'Send even if team is not ready')
|
|
114
|
+
.action(async (chatroomId, options) => {
|
|
115
|
+
await maybeRequireAuth();
|
|
116
|
+
const { sendMessage } = await import('./commands/send.js');
|
|
117
|
+
await sendMessage(chatroomId, options);
|
|
118
|
+
});
|
|
119
|
+
program
|
|
120
|
+
.command('task-complete <chatroomId>')
|
|
121
|
+
.description('Complete a task and hand off to the next role')
|
|
122
|
+
.requiredOption('--role <role>', 'Your role')
|
|
123
|
+
.requiredOption('--message <message>', 'Completion message/summary')
|
|
124
|
+
.requiredOption('--next-role <nextRole>', 'Role to hand off to')
|
|
125
|
+
.option('--no-wait', 'Exit instead of waiting for next message')
|
|
126
|
+
.action(async (chatroomId, options) => {
|
|
127
|
+
await maybeRequireAuth();
|
|
128
|
+
const { taskComplete } = await import('./commands/task-complete.js');
|
|
129
|
+
await taskComplete(chatroomId, { ...options, noWait: options.wait === false });
|
|
130
|
+
});
|
|
131
|
+
program.parse();
|
|
132
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,UAAU,CAAC;KAChB,WAAW,CAAC,4CAA4C,CAAC;KACzD,OAAO,CAAC,OAAO,CAAC;KA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,CAAC,oBAAoB,CAAC,CAAC;IAC3D,MAAM,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC,CACF,CAAC;AAEJ,OAAO;KACJ,OAAO,CAAC,4BAA4B,CAAC;KACrC,WAAW,CAAC,+CAA+C,CAAC;KAC5D,cAAc,CAAC,eAAe,EAAE,WAAW,CAAC;KAC5C,cAAc,CAAC,qBAAqB,EAAE,4BAA4B,CAAC;KACnE,cAAc,CAAC,wBAAwB,EAAE,qBAAqB,CAAC;KAC/D,MAAM,CAAC,WAAW,EAAE,0CAA0C,CAAC;KAC/D,MAAM,CACL,KAAK,EACH,UAAkB,EAClB,OAA4E,EAC5E,EAAE;IACF,MAAM,gBAAgB,EAAE,CAAC;IACzB,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;IACrE,MAAM,YAAY,CAAC,UAAU,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC;AACjF,CAAC,CACF,CAAC;AAEJ,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication middleware
|
|
3
|
+
* Verifies CLI is authenticated before running commands
|
|
4
|
+
*/
|
|
5
|
+
export interface AuthContext {
|
|
6
|
+
sessionId: string;
|
|
7
|
+
userId: string;
|
|
8
|
+
userName?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Require authentication before running a command
|
|
12
|
+
* Exits with error if not authenticated
|
|
13
|
+
*/
|
|
14
|
+
export declare function requireAuth(): Promise<AuthContext>;
|
|
15
|
+
/**
|
|
16
|
+
* Check if authenticated without exiting
|
|
17
|
+
* Returns auth context if authenticated, null otherwise
|
|
18
|
+
*/
|
|
19
|
+
export declare function checkAuth(): Promise<AuthContext | null>;
|
|
20
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/auth/middleware.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,CA+CxD;AAED;;;GAGG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CA4B7D"}
|