@kongyo2/mcp-request-context 1.0.1 → 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.
@@ -5,27 +5,54 @@ export declare class StorageError extends Error {
5
5
  readonly code: StorageErrorCode;
6
6
  constructor(message: string, code: StorageErrorCode);
7
7
  }
8
- export type StorageErrorCode = 'NOT_FOUND' | 'VALIDATION_ERROR' | 'IO_ERROR' | 'ALREADY_ANSWERED' | 'INVALID_STATUS';
8
+ export type StorageErrorCode = 'NOT_FOUND' | 'VALIDATION_ERROR' | 'ALREADY_ANSWERED' | 'INVALID_STATUS';
9
9
  export type StorageResult<T> = Result<T, StorageError>;
10
+ /**
11
+ * インメモリストレージ
12
+ * リクエストデータをメモリ上に保持し、プロセス終了時に破棄される
13
+ */
10
14
  export declare class ContextStorage extends EventEmitter {
11
- private storagePath;
12
- private watcher?;
13
- private pendingEmit;
14
- private readonly DEBOUNCE_MS;
15
- constructor(basePath: string);
16
- initialize(): Promise<StorageResult<void>>;
17
- start(): Promise<StorageResult<void>>;
18
- stop(): Promise<void>;
19
- private scheduleChangeEmit;
20
- createRequest(input: CreateContextRequestInput): Promise<StorageResult<ContextRequest>>;
21
- getRequest(id: string): Promise<StorageResult<ContextRequest>>;
22
- answerRequest(input: ContextResponseInput): Promise<StorageResult<ContextRequest>>;
23
- cancelRequest(id: string): Promise<StorageResult<ContextRequest>>;
24
- getAllRequests(): Promise<StorageResult<ContextRequest[]>>;
25
- getPendingRequests(): Promise<StorageResult<ContextRequest[]>>;
26
- deleteRequest(id: string): Promise<StorageResult<void>>;
27
- cleanupExpired(): Promise<StorageResult<number>>;
28
- private updateStatus;
29
- getStoragePath(): string;
15
+ private requests;
16
+ constructor();
17
+ /**
18
+ * リクエストを作成
19
+ */
20
+ createRequest(input: CreateContextRequestInput): StorageResult<ContextRequest>;
21
+ /**
22
+ * IDでリクエストを取得
23
+ */
24
+ getRequest(id: string): StorageResult<ContextRequest>;
25
+ /**
26
+ * リクエストに回答
27
+ */
28
+ answerRequest(input: ContextResponseInput): StorageResult<ContextRequest>;
29
+ /**
30
+ * リクエストをキャンセル
31
+ */
32
+ cancelRequest(id: string): StorageResult<ContextRequest>;
33
+ /**
34
+ * 全リクエストを取得(新しい順)
35
+ */
36
+ getAllRequests(): ContextRequest[];
37
+ /**
38
+ * 保留中のリクエストを取得
39
+ */
40
+ getPendingRequests(): ContextRequest[];
41
+ /**
42
+ * リクエストを削除
43
+ */
44
+ deleteRequest(id: string): StorageResult<void>;
45
+ /**
46
+ * 期限切れリクエストをクリーンアップ
47
+ */
48
+ cleanupExpired(): number;
49
+ /**
50
+ * ストレージをクリア
51
+ */
52
+ clear(): void;
53
+ /**
54
+ * リソース解放
55
+ */
56
+ stop(): void;
30
57
  }
31
58
  //# sourceMappingURL=storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/core/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,EAAE,MAAM,EAAW,MAAM,YAAY,CAAC;AAE7C,OAAO,EACL,cAAc,EAEd,yBAAyB,EAEzB,oBAAoB,EAErB,MAAM,YAAY,CAAC;AAGpB,qBAAa,YAAa,SAAQ,KAAK;aAGnB,IAAI,EAAE,gBAAgB;gBADtC,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,gBAAgB;CAKzC;AAED,MAAM,MAAM,gBAAgB,GACxB,WAAW,GACX,kBAAkB,GAClB,UAAU,GACV,kBAAkB,GAClB,gBAAgB,CAAC;AAErB,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;AAEvD,qBAAa,cAAe,SAAQ,YAAY;IAC9C,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAC,CAAqB;IACrC,OAAO,CAAC,WAAW,CAA+B;IAClD,OAAO,C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,EAAE,gBAAgB;gBADtC,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,gBAAgB;CAKzC;AAED,MAAM,MAAM,gBAAgB,GACxB,WAAW,GACX,kBAAkB,GAClB,kBAAkB,GAClB,gBAAgB,CAAC;AAErB,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;AAEvD;;;GAGG;AACH,qBAAa,cAAe,SAAQ,YAAY;IAC9C,OAAO,CAAC,QAAQ,CAA0C;;IAM1D;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,yBAAyB,GAAG,aAAa,CAAC,cAAc,CAAC;IA4C9E;;OAEG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,CAAC,cAAc,CAAC;IAQrD;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,oBAAoB,GAAG,aAAa,CAAC,cAAc,CAAC;IAyBzE;;OAEG;IACH,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,CAAC,cAAc,CAAC;IAuBxD;;OAEG;IACH,cAAc,IAAI,cAAc,EAAE;IAQlC;;OAEG;IACH,kBAAkB,IAAI,cAAc,EAAE;IAItC;;OAEG;IACH,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC;IAQ9C;;OAEG;IACH,cAAc,IAAI,MAAM;IAuBxB;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,IAAI,IAAI,IAAI;CAGb"}
@@ -0,0 +1,166 @@
1
+ import { EventEmitter } from 'events';
2
+ import { ok, err } from 'neverthrow';
3
+ import { ContextRequestSchema, CreateContextRequestSchema, generateId } from './types.js';
4
+ // Error types
5
+ export class StorageError extends Error {
6
+ code;
7
+ constructor(message, code) {
8
+ super(message);
9
+ this.code = code;
10
+ this.name = 'StorageError';
11
+ }
12
+ }
13
+ /**
14
+ * インメモリストレージ
15
+ * リクエストデータをメモリ上に保持し、プロセス終了時に破棄される
16
+ */
17
+ export class ContextStorage extends EventEmitter {
18
+ requests = new Map();
19
+ constructor() {
20
+ super();
21
+ }
22
+ /**
23
+ * リクエストを作成
24
+ */
25
+ createRequest(input) {
26
+ // Validate input
27
+ const parseResult = CreateContextRequestSchema.safeParse(input);
28
+ if (!parseResult.success) {
29
+ return err(new StorageError(`Validation error: ${parseResult.error.message}`, 'VALIDATION_ERROR'));
30
+ }
31
+ const now = new Date();
32
+ const id = generateId('ctx');
33
+ const request = {
34
+ id,
35
+ type: parseResult.data.type,
36
+ priority: parseResult.data.priority,
37
+ status: 'pending',
38
+ title: parseResult.data.title,
39
+ description: parseResult.data.description,
40
+ url: parseResult.data.url,
41
+ hints: parseResult.data.hints,
42
+ expectedFormat: parseResult.data.expectedFormat,
43
+ tags: parseResult.data.tags,
44
+ createdAt: now.toISOString(),
45
+ expiresAt: parseResult.data.expiresInMinutes
46
+ ? new Date(now.getTime() + parseResult.data.expiresInMinutes * 60000).toISOString()
47
+ : undefined
48
+ };
49
+ // Validate the complete request
50
+ const validationResult = ContextRequestSchema.safeParse(request);
51
+ if (!validationResult.success) {
52
+ return err(new StorageError(`Request validation error: ${validationResult.error.message}`, 'VALIDATION_ERROR'));
53
+ }
54
+ this.requests.set(id, request);
55
+ this.emit('request-created', request);
56
+ return ok(request);
57
+ }
58
+ /**
59
+ * IDでリクエストを取得
60
+ */
61
+ getRequest(id) {
62
+ const request = this.requests.get(id);
63
+ if (!request) {
64
+ return err(new StorageError(`Request not found: ${id}`, 'NOT_FOUND'));
65
+ }
66
+ return ok(request);
67
+ }
68
+ /**
69
+ * リクエストに回答
70
+ */
71
+ answerRequest(input) {
72
+ const request = this.requests.get(input.requestId);
73
+ if (!request) {
74
+ return err(new StorageError(`Request not found: ${input.requestId}`, 'NOT_FOUND'));
75
+ }
76
+ if (request.status !== 'pending') {
77
+ return err(new StorageError(`Cannot answer request with status: ${request.status}`, 'ALREADY_ANSWERED'));
78
+ }
79
+ const updatedRequest = {
80
+ ...request,
81
+ status: 'answered',
82
+ response: input.response,
83
+ answeredAt: new Date().toISOString()
84
+ };
85
+ this.requests.set(input.requestId, updatedRequest);
86
+ this.emit('request-answered', updatedRequest);
87
+ return ok(updatedRequest);
88
+ }
89
+ /**
90
+ * リクエストをキャンセル
91
+ */
92
+ cancelRequest(id) {
93
+ const request = this.requests.get(id);
94
+ if (!request) {
95
+ return err(new StorageError(`Request not found: ${id}`, 'NOT_FOUND'));
96
+ }
97
+ if (request.status !== 'pending') {
98
+ return err(new StorageError(`Cannot cancel request with status: ${request.status}`, 'INVALID_STATUS'));
99
+ }
100
+ const updatedRequest = {
101
+ ...request,
102
+ status: 'cancelled'
103
+ };
104
+ this.requests.set(id, updatedRequest);
105
+ this.emit('request-cancelled', updatedRequest);
106
+ return ok(updatedRequest);
107
+ }
108
+ /**
109
+ * 全リクエストを取得(新しい順)
110
+ */
111
+ getAllRequests() {
112
+ const requests = Array.from(this.requests.values());
113
+ requests.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
114
+ return requests;
115
+ }
116
+ /**
117
+ * 保留中のリクエストを取得
118
+ */
119
+ getPendingRequests() {
120
+ return this.getAllRequests().filter(r => r.status === 'pending');
121
+ }
122
+ /**
123
+ * リクエストを削除
124
+ */
125
+ deleteRequest(id) {
126
+ if (!this.requests.has(id)) {
127
+ return err(new StorageError(`Request not found: ${id}`, 'NOT_FOUND'));
128
+ }
129
+ this.requests.delete(id);
130
+ return ok(undefined);
131
+ }
132
+ /**
133
+ * 期限切れリクエストをクリーンアップ
134
+ */
135
+ cleanupExpired() {
136
+ const now = new Date();
137
+ let cleaned = 0;
138
+ for (const request of this.requests.values()) {
139
+ if (request.status === 'pending' &&
140
+ request.expiresAt &&
141
+ new Date(request.expiresAt) < now) {
142
+ const updatedRequest = {
143
+ ...request,
144
+ status: 'expired'
145
+ };
146
+ this.requests.set(request.id, updatedRequest);
147
+ this.emit('request-updated', updatedRequest);
148
+ cleaned++;
149
+ }
150
+ }
151
+ return cleaned;
152
+ }
153
+ /**
154
+ * ストレージをクリア
155
+ */
156
+ clear() {
157
+ this.requests.clear();
158
+ }
159
+ /**
160
+ * リソース解放
161
+ */
162
+ stop() {
163
+ this.removeAllListeners();
164
+ }
165
+ }
166
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/core/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAU,EAAE,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAEL,oBAAoB,EAEpB,0BAA0B,EAE1B,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,cAAc;AACd,MAAM,OAAO,YAAa,SAAQ,KAAK;IAGnB;IAFlB,YACE,OAAe,EACC,IAAsB;QAEtC,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,SAAI,GAAJ,IAAI,CAAkB;QAGtC,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAUD;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,YAAY;IACtC,QAAQ,GAAgC,IAAI,GAAG,EAAE,CAAC;IAE1D;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,KAAgC;QAC5C,iBAAiB;QACjB,MAAM,WAAW,GAAG,0BAA0B,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAChE,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO,GAAG,CAAC,IAAI,YAAY,CACzB,qBAAqB,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,EAChD,kBAAkB,CACnB,CAAC,CAAC;QACL,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QAE7B,MAAM,OAAO,GAAmB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AAW,CAAC,CAAC,CAAC;QACxE,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACzB,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,OAAO,GAAG,CAAC,CAAC;QAEhB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;YAC7C,IACE,OAAO,CAAC,MAAM,KAAK,SAAS;gBAC5B,OAAO,CAAC,SAAS;gBACjB,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,GAAG,EACjC,CAAC;gBACD,MAAM,cAAc,GAAmB;oBACrC,GAAG,OAAO;oBACV,MAAM,EAAE,SAAS;iBAClB,CAAC;gBACF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;gBAC9C,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC;gBAC7C,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAI;QACF,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC5B,CAAC;CACF"}
@@ -0,0 +1,88 @@
1
+ import { z } from 'zod';
2
+ // Context Request Types
3
+ export const ContextTypeSchema = z.enum([
4
+ 'url_content', // エージェントがアクセスできないURLの内容
5
+ 'documentation', // APIや依存関係のドキュメント
6
+ 'dependency_info', // 依存関係の情報
7
+ 'code_snippet', // 特定のコードスニペット
8
+ 'configuration', // 設定ファイルの内容
9
+ 'api_response', // APIレスポンスの例
10
+ 'error_context', // エラーの追加コンテキスト
11
+ 'custom' // その他のカスタムリクエスト
12
+ ]);
13
+ export const ContextPrioritySchema = z.enum([
14
+ 'critical', // ブロッキング - これがないと続行不可
15
+ 'high', // 重要 - 早急に必要
16
+ 'normal', // 通常の優先度
17
+ 'low' // あれば助かる程度
18
+ ]);
19
+ export const ContextRequestStatusSchema = z.enum([
20
+ 'pending', // 回答待ち
21
+ 'answered', // 回答済み
22
+ 'cancelled', // キャンセル
23
+ 'expired' // 期限切れ
24
+ ]);
25
+ // Context Request Schema
26
+ export const ContextRequestSchema = z.object({
27
+ id: z.string(),
28
+ type: ContextTypeSchema,
29
+ priority: ContextPrioritySchema,
30
+ status: ContextRequestStatusSchema,
31
+ // リクエスト内容
32
+ title: z.string().min(1).max(200),
33
+ description: z.string().min(1).max(2000),
34
+ // オプショナルフィールド
35
+ url: z.string().url().optional(), // URL関連の場合
36
+ hints: z.array(z.string()).optional(), // 回答のヒント
37
+ expectedFormat: z.string().optional(), // 期待される回答形式
38
+ // メタデータ
39
+ createdAt: z.string().datetime(),
40
+ answeredAt: z.string().datetime().optional(),
41
+ expiresAt: z.string().datetime().optional(),
42
+ // 回答
43
+ response: z.string().optional(),
44
+ // タグ
45
+ tags: z.array(z.string()).optional()
46
+ });
47
+ // Create Request Input Schema
48
+ export const CreateContextRequestSchema = z.object({
49
+ type: ContextTypeSchema,
50
+ priority: ContextPrioritySchema.default('normal'),
51
+ title: z.string().min(1).max(200),
52
+ description: z.string().min(1).max(2000),
53
+ url: z.string().url().optional(),
54
+ hints: z.array(z.string()).optional(),
55
+ expectedFormat: z.string().optional(),
56
+ expiresInMinutes: z.number().positive().optional(),
57
+ tags: z.array(z.string()).optional()
58
+ });
59
+ // Response Input Schema
60
+ export const ContextResponseSchema = z.object({
61
+ requestId: z.string(),
62
+ response: z.string().min(1)
63
+ });
64
+ // WebSocket Message Types
65
+ export const WSMessageTypeSchema = z.enum([
66
+ 'initial',
67
+ 'request-created',
68
+ 'request-updated',
69
+ 'request-answered',
70
+ 'request-cancelled',
71
+ 'ping',
72
+ 'pong'
73
+ ]);
74
+ // Helper function to convert ToolResponse to MCP format
75
+ export function toMCPResponse(response, isError = false) {
76
+ return {
77
+ content: [{
78
+ type: 'text',
79
+ text: JSON.stringify(response, null, 2)
80
+ }],
81
+ isError
82
+ };
83
+ }
84
+ // Generate unique ID
85
+ export function generateId(prefix = 'ctx') {
86
+ return `${prefix}_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
87
+ }
88
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,wBAAwB;AACxB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC;IACtC,aAAa,EAAY,wBAAwB;IACjD,eAAe,EAAU,kBAAkB;IAC3C,iBAAiB,EAAQ,UAAU;IACnC,cAAc,EAAW,cAAc;IACvC,eAAe,EAAU,YAAY;IACrC,cAAc,EAAW,aAAa;IACtC,eAAe,EAAU,eAAe;IACxC,QAAQ,CAAiB,gBAAgB;CAC1C,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,IAAI,CAAC;IAC1C,UAAU,EAAI,sBAAsB;IACpC,MAAM,EAAQ,aAAa;IAC3B,QAAQ,EAAM,SAAS;IACvB,KAAK,CAAS,WAAW;CAC1B,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,IAAI,CAAC;IAC/C,SAAS,EAAM,OAAO;IACtB,UAAU,EAAK,OAAO;IACtB,WAAW,EAAI,QAAQ;IACvB,SAAS,CAAM,OAAO;CACvB,CAAC,CAAC;AAIH,yBAAyB;AACzB,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,EAAE,EAAE,CAAC,CAAC,MAAM,EAA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AAED,qBAAqB;AACrB,MAAM,UAAU,UAAU,CAAC,MAAM,GAAG,KAAK;IACvC,OAAO,GAAG,MAAM,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;AAClF,CAAC"}
@@ -2,23 +2,23 @@ import { ContextStorage } from '../core/storage.js';
2
2
  export interface DashboardOptions {
3
3
  autoOpen?: boolean;
4
4
  port?: number;
5
+ storage?: ContextStorage;
5
6
  }
6
7
  export declare class DashboardServer {
7
8
  private app;
8
9
  private storage;
9
- private projectPath;
10
10
  private options;
11
+ private ownsStorage;
11
12
  private clients;
12
13
  private heartbeatInterval?;
13
14
  private readonly HEARTBEAT_INTERVAL_MS;
14
- constructor(projectPath: string, options?: DashboardOptions);
15
+ constructor(options?: DashboardOptions);
15
16
  start(): Promise<string>;
16
17
  private setupStorageEvents;
17
18
  private sendInitialData;
18
19
  private registerApiRoutes;
19
20
  private broadcast;
20
21
  private startHeartbeat;
21
- private saveSession;
22
22
  stop(): Promise<void>;
23
23
  getStorage(): ContextStorage;
24
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/dashboard/server.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAUpD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,GAAG,CAAkB;IAC7B,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,OAAO,CAAuC;IACtD,OAAO,CAAC,iBAAiB,CAAC,CAAiB;IAC3C,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAS;gBAEnC,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB;IAOzD,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAuE9B,OAAO,CAAC,kBAAkB;YAqCZ,eAAe;IAY7B,OAAO,CAAC,iBAAiB;IAwFzB,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,cAAc;YAcR,WAAW;IAiBnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA0B3B,UAAU,IAAI,cAAc;CAG7B"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/dashboard/server.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAUpD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,GAAG,CAAkB;IAC7B,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,WAAW,CAAU;IAC7B,OAAO,CAAC,OAAO,CAAuC;IACtD,OAAO,CAAC,iBAAiB,CAAC,CAAiB;IAC3C,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAS;gBAEnC,OAAO,GAAE,gBAAqB;IAQpC,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IA+D9B,OAAO,CAAC,kBAAkB;IAmC1B,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,iBAAiB;IAwEzB,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,cAAc;IAchB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAsB3B,UAAU,IAAI,cAAc;CAG7B"}
@@ -0,0 +1,222 @@
1
+ import fastify from 'fastify';
2
+ import fastifyStatic from '@fastify/static';
3
+ import fastifyWebsocket from '@fastify/websocket';
4
+ import fastifyCors from '@fastify/cors';
5
+ import { join, dirname } from 'path';
6
+ import { fileURLToPath } from 'url';
7
+ import open from 'open';
8
+ import { WebSocket } from 'ws';
9
+ import { ContextStorage } from '../core/storage.js';
10
+ const __dirname = dirname(fileURLToPath(import.meta.url));
11
+ export class DashboardServer {
12
+ app;
13
+ storage;
14
+ options;
15
+ ownsStorage;
16
+ clients = new Set();
17
+ heartbeatInterval;
18
+ HEARTBEAT_INTERVAL_MS = 30000;
19
+ constructor(options = {}) {
20
+ this.options = options;
21
+ // 外部からストレージが渡された場合はそれを使用、なければ新規作成
22
+ this.storage = options.storage ?? new ContextStorage();
23
+ this.ownsStorage = !options.storage;
24
+ this.app = fastify({ logger: false });
25
+ }
26
+ async start() {
27
+ // Setup storage event listeners
28
+ this.setupStorageEvents();
29
+ // Register plugins
30
+ await this.app.register(fastifyCors, {
31
+ origin: true,
32
+ methods: ['GET', 'POST', 'PUT', 'DELETE']
33
+ });
34
+ await this.app.register(fastifyStatic, {
35
+ root: join(__dirname, 'public'),
36
+ prefix: '/'
37
+ });
38
+ await this.app.register(fastifyWebsocket);
39
+ // WebSocket endpoint
40
+ await this.app.register(async (fastify) => {
41
+ fastify.get('/ws', { websocket: true }, (socket) => {
42
+ const connection = {
43
+ socket: socket,
44
+ isAlive: true
45
+ };
46
+ this.clients.add(connection);
47
+ socket.on('pong', () => {
48
+ connection.isAlive = true;
49
+ });
50
+ // Send initial data
51
+ this.sendInitialData(socket);
52
+ const cleanup = () => {
53
+ this.clients.delete(connection);
54
+ };
55
+ socket.on('close', cleanup);
56
+ socket.on('error', cleanup);
57
+ });
58
+ });
59
+ // Register API routes
60
+ this.registerApiRoutes();
61
+ // Start server
62
+ const port = this.options.port ?? 5100;
63
+ await this.app.listen({ port, host: '127.0.0.1' });
64
+ // Start heartbeat
65
+ this.startHeartbeat();
66
+ const dashboardUrl = `http://localhost:${port}`;
67
+ // Open browser if requested
68
+ if (this.options.autoOpen) {
69
+ await open(dashboardUrl);
70
+ }
71
+ console.error(`Dashboard running at: ${dashboardUrl}`);
72
+ return dashboardUrl;
73
+ }
74
+ setupStorageEvents() {
75
+ this.storage.on('request-created', (request) => {
76
+ this.broadcast({
77
+ type: 'request-created',
78
+ data: request,
79
+ timestamp: new Date().toISOString()
80
+ });
81
+ });
82
+ this.storage.on('request-answered', (request) => {
83
+ this.broadcast({
84
+ type: 'request-answered',
85
+ data: request,
86
+ timestamp: new Date().toISOString()
87
+ });
88
+ });
89
+ this.storage.on('request-cancelled', (request) => {
90
+ this.broadcast({
91
+ type: 'request-cancelled',
92
+ data: request,
93
+ timestamp: new Date().toISOString()
94
+ });
95
+ });
96
+ this.storage.on('request-updated', () => {
97
+ const requests = this.storage.getAllRequests();
98
+ this.broadcast({
99
+ type: 'request-updated',
100
+ data: requests,
101
+ timestamp: new Date().toISOString()
102
+ });
103
+ });
104
+ }
105
+ sendInitialData(socket) {
106
+ const requests = this.storage.getAllRequests();
107
+ const message = {
108
+ type: 'initial',
109
+ data: requests,
110
+ timestamp: new Date().toISOString()
111
+ };
112
+ socket.send(JSON.stringify(message));
113
+ }
114
+ registerApiRoutes() {
115
+ // Health check
116
+ this.app.get('/api/health', async () => {
117
+ return { status: 'ok', timestamp: new Date().toISOString() };
118
+ });
119
+ // Get all requests
120
+ this.app.get('/api/requests', async () => {
121
+ return this.storage.getAllRequests();
122
+ });
123
+ // Get pending requests
124
+ this.app.get('/api/requests/pending', async () => {
125
+ return this.storage.getPendingRequests();
126
+ });
127
+ // Get single request
128
+ this.app.get('/api/requests/:id', async (request, reply) => {
129
+ const result = this.storage.getRequest(request.params.id);
130
+ if (result.isErr()) {
131
+ const code = result.error.code === 'NOT_FOUND' ? 404 : 500;
132
+ return reply.code(code).send({ error: result.error.message });
133
+ }
134
+ return result.value;
135
+ });
136
+ // Answer a request
137
+ this.app.post('/api/requests/:id/answer', async (request, reply) => {
138
+ const { id } = request.params;
139
+ const { response } = request.body;
140
+ if (!response || typeof response !== 'string') {
141
+ return reply.code(400).send({ error: 'Response is required' });
142
+ }
143
+ const result = this.storage.answerRequest({
144
+ requestId: id,
145
+ response
146
+ });
147
+ if (result.isErr()) {
148
+ const code = result.error.code === 'NOT_FOUND' ? 404 : 500;
149
+ return reply.code(code).send({ error: result.error.message });
150
+ }
151
+ return { success: true, request: result.value };
152
+ });
153
+ // Cancel a request
154
+ this.app.post('/api/requests/:id/cancel', async (request, reply) => {
155
+ const result = this.storage.cancelRequest(request.params.id);
156
+ if (result.isErr()) {
157
+ const code = result.error.code === 'NOT_FOUND' ? 404 : 500;
158
+ return reply.code(code).send({ error: result.error.message });
159
+ }
160
+ return { success: true, request: result.value };
161
+ });
162
+ // Delete a request
163
+ this.app.delete('/api/requests/:id', async (request, reply) => {
164
+ const result = this.storage.deleteRequest(request.params.id);
165
+ if (result.isErr()) {
166
+ const code = result.error.code === 'NOT_FOUND' ? 404 : 500;
167
+ return reply.code(code).send({ error: result.error.message });
168
+ }
169
+ return { success: true };
170
+ });
171
+ }
172
+ broadcast(message) {
173
+ const messageStr = JSON.stringify(message);
174
+ for (const connection of this.clients) {
175
+ try {
176
+ if (connection.socket.readyState === WebSocket.OPEN) {
177
+ connection.socket.send(messageStr);
178
+ }
179
+ }
180
+ catch (error) {
181
+ console.error('Error broadcasting:', error);
182
+ this.clients.delete(connection);
183
+ }
184
+ }
185
+ }
186
+ startHeartbeat() {
187
+ this.heartbeatInterval = setInterval(() => {
188
+ for (const connection of this.clients) {
189
+ if (!connection.isAlive) {
190
+ connection.socket.terminate();
191
+ this.clients.delete(connection);
192
+ continue;
193
+ }
194
+ connection.isAlive = false;
195
+ connection.socket.ping();
196
+ }
197
+ }, this.HEARTBEAT_INTERVAL_MS);
198
+ }
199
+ async stop() {
200
+ if (this.heartbeatInterval) {
201
+ clearInterval(this.heartbeatInterval);
202
+ }
203
+ for (const connection of this.clients) {
204
+ try {
205
+ connection.socket.close();
206
+ }
207
+ catch {
208
+ // Ignore
209
+ }
210
+ }
211
+ this.clients.clear();
212
+ // 自分が作成したストレージのみ停止
213
+ if (this.ownsStorage) {
214
+ this.storage.stop();
215
+ }
216
+ await this.app.close();
217
+ }
218
+ getStorage() {
219
+ return this.storage;
220
+ }
221
+ }
222
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/dashboard/server.ts"],"names":[],"mappings":"AAAA,OAAO,OAA4B,MAAM,SAAS,CAAC;AACnD,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAa1D,MAAM,OAAO,eAAe;IAClB,GAAG,CAAkB;IACrB,OAAO,CAAiB;IACxB,OAAO,CAAmB;IAC1B,WAAW,CAAU;IACrB,OAAO,GAA6B,IAAI,GAAG,EAAE,CAAC;IAC9C,iBAAiB,CAAkB;IAC1B,qBAAqB,GAAG,KAAK,CAAC;IAE/C,YAAY,UAA4B,EAAE;QACxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,kCAAkC;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,cAAc,EAAE,CAAC;QACvD,IAAI,CAAC,WAAW,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC;QACpC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK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