@braingrid/cli 0.1.3 → 0.2.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/CHANGELOG.md +24 -0
- package/README.md +0 -1
- package/dist/cli.js +265 -317
- package/dist/cli.js.map +1 -1
- package/dist/handlers/auth.handlers.d.ts +1 -7
- package/dist/handlers/auth.handlers.d.ts.map +1 -1
- package/dist/handlers/auth.handlers.js +25 -91
- package/dist/handlers/auth.handlers.js.map +1 -1
- package/dist/handlers/index.d.ts +0 -1
- package/dist/handlers/index.d.ts.map +1 -1
- package/dist/handlers/index.js +0 -1
- package/dist/handlers/index.js.map +1 -1
- package/package.json +24 -5
- package/dist/handlers/agent.handlers.d.ts +0 -12
- package/dist/handlers/agent.handlers.d.ts.map +0 -1
- package/dist/handlers/agent.handlers.js +0 -130
- package/dist/handlers/agent.handlers.js.map +0 -1
- package/dist/rpc/registry.d.ts +0 -97
- package/dist/rpc/registry.d.ts.map +0 -1
- package/dist/rpc/registry.js +0 -119
- package/dist/rpc/registry.js.map +0 -1
- package/dist/rpc/server.d.ts +0 -78
- package/dist/rpc/server.d.ts.map +0 -1
- package/dist/rpc/server.js +0 -437
- package/dist/rpc/server.js.map +0 -1
- package/dist/rpc/transport.d.ts +0 -84
- package/dist/rpc/transport.d.ts.map +0 -1
- package/dist/rpc/transport.js +0 -296
- package/dist/rpc/transport.js.map +0 -1
- package/dist/services/__mocks__/utils.d.ts +0 -16
- package/dist/services/__mocks__/utils.d.ts.map +0 -1
- package/dist/services/__mocks__/utils.js +0 -21
- package/dist/services/__mocks__/utils.js.map +0 -1
- package/dist/services/agent-service.d.ts +0 -29
- package/dist/services/agent-service.d.ts.map +0 -1
- package/dist/services/agent-service.js +0 -273
- package/dist/services/agent-service.js.map +0 -1
package/dist/rpc/registry.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Method Registry for JSON-RPC
|
|
3
|
-
* Maps method names to handlers and provides request validation and routing
|
|
4
|
-
*/
|
|
5
|
-
import { createMethodNotFoundError, createInvalidParamsError, createInternalError, createAuthenticationRequiredError, } from '@braingrid/protocol';
|
|
6
|
-
/**
|
|
7
|
-
* Method Registry class
|
|
8
|
-
*/
|
|
9
|
-
export class MethodRegistry {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.methods = new Map();
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Register a method
|
|
15
|
-
*/
|
|
16
|
-
register(name, config) {
|
|
17
|
-
this.methods.set(name, config);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Check if a method exists
|
|
21
|
-
*/
|
|
22
|
-
hasMethod(name) {
|
|
23
|
-
return this.methods.has(name);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Get method configuration
|
|
27
|
-
*/
|
|
28
|
-
getMethod(name) {
|
|
29
|
-
return this.methods.get(name);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Execute a method with validation
|
|
33
|
-
*/
|
|
34
|
-
async execute(id, method, params, context) {
|
|
35
|
-
try {
|
|
36
|
-
// Check if method exists
|
|
37
|
-
const config = this.methods.get(method);
|
|
38
|
-
if (!config) {
|
|
39
|
-
return createMethodNotFoundError(id, method);
|
|
40
|
-
}
|
|
41
|
-
// Check authentication if required
|
|
42
|
-
if (config.metadata?.requiresAuth && !context?.isAuthenticated) {
|
|
43
|
-
return createAuthenticationRequiredError(id);
|
|
44
|
-
}
|
|
45
|
-
// Convert positional parameters to named parameters if needed
|
|
46
|
-
let convertedParams = params;
|
|
47
|
-
if (Array.isArray(params) && config.metadata?.positionalParams) {
|
|
48
|
-
// Map array values to named parameters
|
|
49
|
-
const namedParams = {};
|
|
50
|
-
config.metadata.positionalParams.forEach((name, index) => {
|
|
51
|
-
if (index < params.length) {
|
|
52
|
-
namedParams[name] = params[index];
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
convertedParams = namedParams;
|
|
56
|
-
}
|
|
57
|
-
// Validate parameters if schema provided
|
|
58
|
-
let validatedParams = convertedParams;
|
|
59
|
-
if (config.schema) {
|
|
60
|
-
// Default to empty object if params are undefined
|
|
61
|
-
const paramsToValidate = convertedParams === undefined ? {} : convertedParams;
|
|
62
|
-
const result = config.schema.safeParse(paramsToValidate);
|
|
63
|
-
if (!result.success) {
|
|
64
|
-
// Format validation errors
|
|
65
|
-
const errors = result.error.issues.map(err => ({
|
|
66
|
-
path: err.path.join('.'),
|
|
67
|
-
message: err.message,
|
|
68
|
-
}));
|
|
69
|
-
return createInvalidParamsError(id, 'Validation failed', errors);
|
|
70
|
-
}
|
|
71
|
-
validatedParams = result.data;
|
|
72
|
-
}
|
|
73
|
-
// Execute handler
|
|
74
|
-
const handlerResult = await config.handler(validatedParams, context);
|
|
75
|
-
// Return success response
|
|
76
|
-
return {
|
|
77
|
-
jsonrpc: '2.0',
|
|
78
|
-
id,
|
|
79
|
-
result: handlerResult,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
// Handle execution errors
|
|
84
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
85
|
-
return createInternalError(id, `Method execution failed: ${errorMessage}`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Get all registered methods for discovery
|
|
90
|
-
*/
|
|
91
|
-
getMethods() {
|
|
92
|
-
const methodList = [];
|
|
93
|
-
for (const [name, config] of this.methods) {
|
|
94
|
-
methodList.push({
|
|
95
|
-
name,
|
|
96
|
-
description: config.metadata?.description,
|
|
97
|
-
requiresAuth: config.metadata?.requiresAuth,
|
|
98
|
-
supportsStreaming: config.metadata?.supportsStreaming,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
return methodList.sort((a, b) => a.name.localeCompare(b.name));
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Clear all registered methods
|
|
105
|
-
*/
|
|
106
|
-
clear() {
|
|
107
|
-
this.methods.clear();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Create and configure the default method registry
|
|
112
|
-
*/
|
|
113
|
-
export function createMethodRegistry() {
|
|
114
|
-
const registry = new MethodRegistry();
|
|
115
|
-
// Methods will be registered here when integrating with handlers
|
|
116
|
-
// This will be done in the server implementation
|
|
117
|
-
return registry;
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=registry.js.map
|
package/dist/rpc/registry.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/rpc/registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,yBAAyB,EACzB,wBAAwB,EACxB,mBAAmB,EACnB,iCAAiC,GACjC,MAAM,qBAAqB,CAAC;AAkE7B;;GAEG;AACH,MAAM,OAAO,cAAc;IAA3B;QACS,YAAO,GAA8B,IAAI,GAAG,EAAE,CAAC;IAmHxD,CAAC;IAjHA;;OAEG;IACH,QAAQ,CACP,IAAY,EACZ,MAAsC;QAEtC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAsB,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CACZ,EAAa,EACb,MAAc,EACd,MAAe,EACf,OAAuB;QAEvB,IAAI,CAAC;YACJ,yBAAyB;YACzB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACxC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACb,OAAO,yBAA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;OAEG;IACH,KAAK;QACJ,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACD;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IACnC,MAAM,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;IAEtC,iEAAiE;IACjE,iDAAiD;IAEjD,OAAO,QAAQ,CAAC;AACjB,CAAC"}
|
package/dist/rpc/server.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JSON-RPC Server implementation
|
|
3
|
-
* Coordinates transport, registry, and provides dual-mode operation
|
|
4
|
-
*/
|
|
5
|
-
import type { Readable, Writable } from 'stream';
|
|
6
|
-
import { type MethodContext } from './registry.js';
|
|
7
|
-
import { type JsonRpcId } from '@braingrid/protocol';
|
|
8
|
-
/**
|
|
9
|
-
* JSON-RPC Server options
|
|
10
|
-
*/
|
|
11
|
-
export interface JsonRpcServerOptions {
|
|
12
|
-
input?: Readable;
|
|
13
|
-
output?: Writable;
|
|
14
|
-
context?: MethodContext;
|
|
15
|
-
useContentLength?: boolean;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* JSON-RPC Server
|
|
19
|
-
*/
|
|
20
|
-
export declare class JsonRpcServer {
|
|
21
|
-
private transport;
|
|
22
|
-
private registry;
|
|
23
|
-
private context;
|
|
24
|
-
private isRunning;
|
|
25
|
-
private auth;
|
|
26
|
-
private stableContext;
|
|
27
|
-
constructor(options?: JsonRpcServerOptions);
|
|
28
|
-
/**
|
|
29
|
-
* Get current authentication context
|
|
30
|
-
* Returns the stable context object with updated auth state
|
|
31
|
-
*/
|
|
32
|
-
private getAuthContext;
|
|
33
|
-
/**
|
|
34
|
-
* Helper to register a method with braingrid. prefix
|
|
35
|
-
*/
|
|
36
|
-
private registerMethod;
|
|
37
|
-
/**
|
|
38
|
-
* Register all RPC methods
|
|
39
|
-
*/
|
|
40
|
-
private registerMethods;
|
|
41
|
-
/**
|
|
42
|
-
* Handle incoming JSON-RPC message
|
|
43
|
-
*/
|
|
44
|
-
private handleMessage;
|
|
45
|
-
/**
|
|
46
|
-
* Handle JSON-RPC request
|
|
47
|
-
*/
|
|
48
|
-
private handleRequest;
|
|
49
|
-
/**
|
|
50
|
-
* Handle JSON-RPC notification
|
|
51
|
-
*/
|
|
52
|
-
private handleNotification;
|
|
53
|
-
/**
|
|
54
|
-
* Send a progress notification for long-running operations
|
|
55
|
-
*/
|
|
56
|
-
sendProgress(id: JsonRpcId, message: string, progress?: number): Promise<void>;
|
|
57
|
-
/**
|
|
58
|
-
* Handle batch request
|
|
59
|
-
*/
|
|
60
|
-
private handleBatch;
|
|
61
|
-
/**
|
|
62
|
-
* Handle transport errors
|
|
63
|
-
*/
|
|
64
|
-
private handleTransportError;
|
|
65
|
-
/**
|
|
66
|
-
* Start the server
|
|
67
|
-
*/
|
|
68
|
-
start(): void;
|
|
69
|
-
/**
|
|
70
|
-
* Stop the server
|
|
71
|
-
*/
|
|
72
|
-
stop(): Promise<void>;
|
|
73
|
-
/**
|
|
74
|
-
* Get registered methods for discovery
|
|
75
|
-
*/
|
|
76
|
-
getMethods(): string[];
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=server.d.ts.map
|
package/dist/rpc/server.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/rpc/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEjD,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAQN,KAAK,SAAS,EAKd,MAAM,qBAAqB,CAAC;AAK7B;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACpC,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,qBAAa,aAAa;IACzB,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,IAAI,CAAgB;IAC5B,OAAO,CAAC,aAAa,CAAgB;gBAEzB,OAAO,GAAE,oBAAyB;IAwB9C;;;OAGG;YACW,cAAc;IAkB5B;;OAEG;IACH,OAAO,CAAC,cAAc;IAKtB;;OAEG;IACH,OAAO,CAAC,eAAe;IA8SvB;;OAEG;YACW,aAAa;IAe3B;;OAEG;YACW,aAAa;IAc3B;;OAEG;YACW,kBAAkB;IAchC;;OAEG;IACU,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAc3F;;OAEG;YACW,WAAW;IAmCzB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAI5B;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAM3B;;OAEG;IACH,UAAU,IAAI,MAAM,EAAE;CAGtB"}
|
package/dist/rpc/server.js
DELETED
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JSON-RPC Server implementation
|
|
3
|
-
* Coordinates transport, registry, and provides dual-mode operation
|
|
4
|
-
*/
|
|
5
|
-
import { StdioTransport } from './transport.js';
|
|
6
|
-
import { MethodRegistry } from './registry.js';
|
|
7
|
-
import { methodSchemas, isJsonRpcRequest, isJsonRpcNotification, isJsonRpcResponse, } from '@braingrid/protocol';
|
|
8
|
-
import * as handlers from '../handlers/index.js';
|
|
9
|
-
import { BraingridAuth } from '../services/auth.js';
|
|
10
|
-
import { getConfig } from '../utils/config.js';
|
|
11
|
-
/**
|
|
12
|
-
* JSON-RPC Server
|
|
13
|
-
*/
|
|
14
|
-
export class JsonRpcServer {
|
|
15
|
-
constructor(options = {}) {
|
|
16
|
-
this.isRunning = false;
|
|
17
|
-
this.transport = new StdioTransport(options.input, options.output, {
|
|
18
|
-
useContentLength: options.useContentLength || false,
|
|
19
|
-
});
|
|
20
|
-
this.registry = new MethodRegistry();
|
|
21
|
-
this.context = options.context || {};
|
|
22
|
-
// Initialize auth service
|
|
23
|
-
const config = getConfig();
|
|
24
|
-
this.auth = new BraingridAuth(config.apiUrl);
|
|
25
|
-
// Create a stable context object that persists across requests
|
|
26
|
-
// This is used for auth state persistence via WeakMap in handlers
|
|
27
|
-
this.stableContext = { ...this.context };
|
|
28
|
-
// Register all methods
|
|
29
|
-
this.registerMethods();
|
|
30
|
-
// Set up message handling
|
|
31
|
-
this.transport.onMessage(this.handleMessage.bind(this));
|
|
32
|
-
this.transport.onBatch(this.handleBatch.bind(this));
|
|
33
|
-
this.transport.onError(this.handleTransportError.bind(this));
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Get current authentication context
|
|
37
|
-
* Returns the stable context object with updated auth state
|
|
38
|
-
*/
|
|
39
|
-
async getAuthContext() {
|
|
40
|
-
try {
|
|
41
|
-
const isAuthenticated = await this.auth.isAuthenticated();
|
|
42
|
-
const session = await this.auth.getStoredSession();
|
|
43
|
-
// Update the stable context with current auth state
|
|
44
|
-
this.stableContext.isAuthenticated = isAuthenticated;
|
|
45
|
-
this.stableContext.session = session;
|
|
46
|
-
return this.stableContext;
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
// If auth check fails, return unauthenticated context
|
|
50
|
-
this.stableContext.isAuthenticated = false;
|
|
51
|
-
this.stableContext.session = undefined;
|
|
52
|
-
return this.stableContext;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Helper to register a method with braingrid. prefix
|
|
57
|
-
*/
|
|
58
|
-
registerMethod(name, config) {
|
|
59
|
-
// Register with braingrid. prefix as per REQ-899
|
|
60
|
-
this.registry.register(`braingrid.${name}`, config);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Register all RPC methods
|
|
64
|
-
*/
|
|
65
|
-
registerMethods() {
|
|
66
|
-
// ============================================
|
|
67
|
-
// AUTH METHODS
|
|
68
|
-
// ============================================
|
|
69
|
-
this.registerMethod('auth.login', {
|
|
70
|
-
schema: methodSchemas['auth.login'],
|
|
71
|
-
handler: async (_params, context) => {
|
|
72
|
-
const result = await handlers.handleLogin(context);
|
|
73
|
-
return result;
|
|
74
|
-
},
|
|
75
|
-
metadata: { description: 'Authenticate with BrainGrid (returns auth URL in RPC mode)' },
|
|
76
|
-
});
|
|
77
|
-
this.registerMethod('auth.complete', {
|
|
78
|
-
schema: methodSchemas['auth.logout'], // Same schema as logout (no params)
|
|
79
|
-
handler: async (_params, context) => {
|
|
80
|
-
const result = await handlers.handleCompleteLogin(context);
|
|
81
|
-
return result;
|
|
82
|
-
},
|
|
83
|
-
metadata: { description: 'Complete authentication after opening browser (RPC mode only)' },
|
|
84
|
-
});
|
|
85
|
-
this.registerMethod('auth.logout', {
|
|
86
|
-
schema: methodSchemas['auth.logout'],
|
|
87
|
-
handler: async () => {
|
|
88
|
-
const result = await handlers.handleLogout();
|
|
89
|
-
return result;
|
|
90
|
-
},
|
|
91
|
-
metadata: { description: 'Sign out from BrainGrid' },
|
|
92
|
-
});
|
|
93
|
-
this.registerMethod('auth.whoami', {
|
|
94
|
-
schema: methodSchemas['auth.whoami'],
|
|
95
|
-
handler: async () => {
|
|
96
|
-
const result = await handlers.handleWhoami();
|
|
97
|
-
return result;
|
|
98
|
-
},
|
|
99
|
-
metadata: { description: 'Show current user information', requiresAuth: true },
|
|
100
|
-
});
|
|
101
|
-
// ============================================
|
|
102
|
-
// AGENT CONVERSATION METHODS
|
|
103
|
-
// ============================================
|
|
104
|
-
this.registerMethod('agent.conversation.stream', {
|
|
105
|
-
schema: methodSchemas['braingrid.agent.conversation.stream'],
|
|
106
|
-
handler: async (params) => {
|
|
107
|
-
const typedParams = params;
|
|
108
|
-
const result = await handlers.handleAgentConversationStream(typedParams);
|
|
109
|
-
return result;
|
|
110
|
-
},
|
|
111
|
-
metadata: {
|
|
112
|
-
description: 'Stream a conversation with the AI agent',
|
|
113
|
-
requiresAuth: true,
|
|
114
|
-
supportsStreaming: true,
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
// ============================================
|
|
118
|
-
// INIT & UPDATE METHODS
|
|
119
|
-
// ============================================
|
|
120
|
-
this.registerMethod('init', {
|
|
121
|
-
schema: methodSchemas['braingrid.init'],
|
|
122
|
-
handler: async (params) => {
|
|
123
|
-
const typedParams = params;
|
|
124
|
-
const result = await handlers.handleInit(typedParams || {});
|
|
125
|
-
return result;
|
|
126
|
-
},
|
|
127
|
-
metadata: {
|
|
128
|
-
description: 'Initialize BrainGrid project in current repository',
|
|
129
|
-
requiresAuth: true,
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
this.registerMethod('update', {
|
|
133
|
-
schema: methodSchemas['braingrid.update'],
|
|
134
|
-
handler: async (params) => {
|
|
135
|
-
const typedParams = params;
|
|
136
|
-
const result = await handlers.handleUpdate(typedParams || {});
|
|
137
|
-
return result;
|
|
138
|
-
},
|
|
139
|
-
metadata: {
|
|
140
|
-
description: 'Update BrainGrid CLI to the latest version (use --check in RPC mode)',
|
|
141
|
-
requiresAuth: false,
|
|
142
|
-
},
|
|
143
|
-
});
|
|
144
|
-
// ============================================
|
|
145
|
-
// PROJECT METHODS
|
|
146
|
-
// ============================================
|
|
147
|
-
this.registerMethod('project.list', {
|
|
148
|
-
schema: methodSchemas['project.list'],
|
|
149
|
-
handler: async (params) => {
|
|
150
|
-
const typedParams = params;
|
|
151
|
-
const result = await handlers.handleProjectList(typedParams || {});
|
|
152
|
-
return result;
|
|
153
|
-
},
|
|
154
|
-
metadata: { description: 'List all projects', requiresAuth: true },
|
|
155
|
-
});
|
|
156
|
-
this.registerMethod('project.create', {
|
|
157
|
-
schema: methodSchemas['project.create'],
|
|
158
|
-
handler: async (params) => {
|
|
159
|
-
const typedParams = params;
|
|
160
|
-
const result = await handlers.handleProjectCreate(typedParams);
|
|
161
|
-
return result;
|
|
162
|
-
},
|
|
163
|
-
metadata: {
|
|
164
|
-
description: 'Create a new project',
|
|
165
|
-
requiresAuth: true,
|
|
166
|
-
positionalParams: ['name', 'description'], // Support ["my-project", "description"] format
|
|
167
|
-
},
|
|
168
|
-
});
|
|
169
|
-
this.registerMethod('project.get', {
|
|
170
|
-
schema: methodSchemas['project.get'],
|
|
171
|
-
handler: async (params) => {
|
|
172
|
-
const typedParams = params;
|
|
173
|
-
const result = await handlers.handleProjectShow({ id: typedParams.project });
|
|
174
|
-
return result;
|
|
175
|
-
},
|
|
176
|
-
metadata: {
|
|
177
|
-
description: 'Get a specific project by ID',
|
|
178
|
-
requiresAuth: true,
|
|
179
|
-
positionalParams: ['project'], // Support ["project-id"] format
|
|
180
|
-
},
|
|
181
|
-
});
|
|
182
|
-
this.registerMethod('project.show', {
|
|
183
|
-
schema: methodSchemas['project.show'],
|
|
184
|
-
handler: async (params) => {
|
|
185
|
-
const typedParams = params;
|
|
186
|
-
const result = await handlers.handleProjectShow({
|
|
187
|
-
repo: typedParams.project, // project parameter contains the repository
|
|
188
|
-
format: typedParams.format,
|
|
189
|
-
});
|
|
190
|
-
return result;
|
|
191
|
-
},
|
|
192
|
-
metadata: { description: 'Show projects for a repository', requiresAuth: true },
|
|
193
|
-
});
|
|
194
|
-
this.registerMethod('project.update', {
|
|
195
|
-
schema: methodSchemas['project.update'],
|
|
196
|
-
handler: async (params) => {
|
|
197
|
-
const typedParams = params;
|
|
198
|
-
const result = await handlers.handleProjectUpdate(typedParams.project, {
|
|
199
|
-
name: typedParams.name,
|
|
200
|
-
description: typedParams.description,
|
|
201
|
-
});
|
|
202
|
-
return result;
|
|
203
|
-
},
|
|
204
|
-
metadata: { description: 'Update a project', requiresAuth: true },
|
|
205
|
-
});
|
|
206
|
-
this.registerMethod('project.delete', {
|
|
207
|
-
schema: methodSchemas['project.delete'],
|
|
208
|
-
handler: async (params) => {
|
|
209
|
-
const typedParams = params;
|
|
210
|
-
const result = await handlers.handleProjectDelete(typedParams.project, { force: typedParams.confirm } // Map confirm to force parameter
|
|
211
|
-
);
|
|
212
|
-
return result;
|
|
213
|
-
},
|
|
214
|
-
metadata: { description: 'Delete a project', requiresAuth: true },
|
|
215
|
-
});
|
|
216
|
-
// ============================================
|
|
217
|
-
// REQUIREMENT METHODS
|
|
218
|
-
// ============================================
|
|
219
|
-
this.registerMethod('requirement.list', {
|
|
220
|
-
schema: methodSchemas['requirement.list'],
|
|
221
|
-
handler: async (params) => {
|
|
222
|
-
const typedParams = params;
|
|
223
|
-
const result = await handlers.handleRequirementList(typedParams);
|
|
224
|
-
return result;
|
|
225
|
-
},
|
|
226
|
-
metadata: { description: 'List requirements for a project', requiresAuth: true },
|
|
227
|
-
});
|
|
228
|
-
this.registerMethod('requirement.show', {
|
|
229
|
-
schema: methodSchemas['requirement.show'],
|
|
230
|
-
handler: async (params) => {
|
|
231
|
-
const typedParams = params;
|
|
232
|
-
const result = await handlers.handleRequirementShow(typedParams.requirement);
|
|
233
|
-
return result;
|
|
234
|
-
},
|
|
235
|
-
metadata: { description: 'Show requirement details', requiresAuth: true },
|
|
236
|
-
});
|
|
237
|
-
this.registerMethod('requirement.create', {
|
|
238
|
-
schema: methodSchemas['requirement.create'],
|
|
239
|
-
handler: async (params) => {
|
|
240
|
-
const typedParams = params;
|
|
241
|
-
const result = await handlers.handleRequirementCreate(typedParams);
|
|
242
|
-
return result;
|
|
243
|
-
},
|
|
244
|
-
metadata: {
|
|
245
|
-
description: 'Create a new requirement',
|
|
246
|
-
requiresAuth: true,
|
|
247
|
-
supportsStreaming: true, // Requirement creation supports streaming
|
|
248
|
-
},
|
|
249
|
-
});
|
|
250
|
-
this.registerMethod('requirement.update', {
|
|
251
|
-
schema: methodSchemas['requirement.update'],
|
|
252
|
-
handler: async (params) => {
|
|
253
|
-
const typedParams = params;
|
|
254
|
-
const result = await handlers.handleRequirementUpdate(typedParams.requirement, {
|
|
255
|
-
status: typedParams.status,
|
|
256
|
-
name: typedParams.name,
|
|
257
|
-
});
|
|
258
|
-
return result;
|
|
259
|
-
},
|
|
260
|
-
metadata: { description: 'Update a requirement', requiresAuth: true },
|
|
261
|
-
});
|
|
262
|
-
this.registerMethod('requirement.delete', {
|
|
263
|
-
schema: methodSchemas['requirement.delete'],
|
|
264
|
-
handler: async (params) => {
|
|
265
|
-
const typedParams = params;
|
|
266
|
-
const result = await handlers.handleRequirementDelete(typedParams.requirement, { force: typedParams.confirm } // Map confirm to force parameter
|
|
267
|
-
);
|
|
268
|
-
return result;
|
|
269
|
-
},
|
|
270
|
-
metadata: { description: 'Delete a requirement', requiresAuth: true },
|
|
271
|
-
});
|
|
272
|
-
// ============================================
|
|
273
|
-
// TASK METHODS
|
|
274
|
-
// ============================================
|
|
275
|
-
this.registerMethod('task.list', {
|
|
276
|
-
schema: methodSchemas['task.list'],
|
|
277
|
-
handler: async (params) => {
|
|
278
|
-
const typedParams = params;
|
|
279
|
-
const result = await handlers.handleTaskList(typedParams);
|
|
280
|
-
return result;
|
|
281
|
-
},
|
|
282
|
-
metadata: { description: 'List tasks for a requirement', requiresAuth: true },
|
|
283
|
-
});
|
|
284
|
-
this.registerMethod('task.show', {
|
|
285
|
-
schema: methodSchemas['task.show'],
|
|
286
|
-
handler: async (params) => {
|
|
287
|
-
const typedParams = params;
|
|
288
|
-
const result = await handlers.handleTaskShow(typedParams.task);
|
|
289
|
-
return result;
|
|
290
|
-
},
|
|
291
|
-
metadata: { description: 'Show task details', requiresAuth: true },
|
|
292
|
-
});
|
|
293
|
-
this.registerMethod('task.create', {
|
|
294
|
-
schema: methodSchemas['task.create'],
|
|
295
|
-
handler: async (params) => {
|
|
296
|
-
const typedParams = params;
|
|
297
|
-
const result = await handlers.handleTaskCreate(typedParams);
|
|
298
|
-
return result;
|
|
299
|
-
},
|
|
300
|
-
metadata: { description: 'Create a new task', requiresAuth: true },
|
|
301
|
-
});
|
|
302
|
-
this.registerMethod('task.update', {
|
|
303
|
-
schema: methodSchemas['task.update'],
|
|
304
|
-
handler: async (params) => {
|
|
305
|
-
const typedParams = params;
|
|
306
|
-
const result = await handlers.handleTaskUpdate(typedParams.task, {
|
|
307
|
-
status: typedParams.status,
|
|
308
|
-
title: typedParams.title,
|
|
309
|
-
});
|
|
310
|
-
return result;
|
|
311
|
-
},
|
|
312
|
-
metadata: { description: 'Update a task', requiresAuth: true },
|
|
313
|
-
});
|
|
314
|
-
this.registerMethod('task.delete', {
|
|
315
|
-
schema: methodSchemas['task.delete'],
|
|
316
|
-
handler: async (params) => {
|
|
317
|
-
const typedParams = params;
|
|
318
|
-
const result = await handlers.handleTaskDelete(typedParams.task, { force: typedParams.confirm } // Map confirm to force parameter
|
|
319
|
-
);
|
|
320
|
-
return result;
|
|
321
|
-
},
|
|
322
|
-
metadata: { description: 'Delete a task', requiresAuth: true },
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Handle incoming JSON-RPC message
|
|
327
|
-
*/
|
|
328
|
-
async handleMessage(message) {
|
|
329
|
-
try {
|
|
330
|
-
if (isJsonRpcRequest(message)) {
|
|
331
|
-
await this.handleRequest(message);
|
|
332
|
-
}
|
|
333
|
-
else if (isJsonRpcNotification(message)) {
|
|
334
|
-
await this.handleNotification(message);
|
|
335
|
-
}
|
|
336
|
-
else if (isJsonRpcResponse(message)) {
|
|
337
|
-
// Server doesn't handle responses
|
|
338
|
-
console.error('Unexpected response message received');
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
catch (error) {
|
|
342
|
-
console.error('Error handling message:', error);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Handle JSON-RPC request
|
|
347
|
-
*/
|
|
348
|
-
async handleRequest(request) {
|
|
349
|
-
// Get fresh auth context for this request
|
|
350
|
-
const authContext = await this.getAuthContext();
|
|
351
|
-
const response = await this.registry.execute(request.id, request.method, request.params, authContext);
|
|
352
|
-
await this.transport.send(response);
|
|
353
|
-
}
|
|
354
|
-
/**
|
|
355
|
-
* Handle JSON-RPC notification
|
|
356
|
-
*/
|
|
357
|
-
async handleNotification(notification) {
|
|
358
|
-
// Get fresh auth context for this notification
|
|
359
|
-
const authContext = await this.getAuthContext();
|
|
360
|
-
// Notifications don't expect responses
|
|
361
|
-
// Execute the method but don't send response
|
|
362
|
-
await this.registry.execute('', // Notifications don't have IDs
|
|
363
|
-
notification.method, notification.params, authContext);
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Send a progress notification for long-running operations
|
|
367
|
-
*/
|
|
368
|
-
async sendProgress(id, message, progress) {
|
|
369
|
-
const notification = {
|
|
370
|
-
jsonrpc: '2.0',
|
|
371
|
-
method: 'braingrid.progress',
|
|
372
|
-
params: {
|
|
373
|
-
id,
|
|
374
|
-
message,
|
|
375
|
-
progress,
|
|
376
|
-
timestamp: new Date().toISOString(),
|
|
377
|
-
},
|
|
378
|
-
};
|
|
379
|
-
await this.transport.send(notification);
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Handle batch request
|
|
383
|
-
*/
|
|
384
|
-
async handleBatch(batch) {
|
|
385
|
-
const responses = [];
|
|
386
|
-
// Get fresh auth context for this batch
|
|
387
|
-
const authContext = await this.getAuthContext();
|
|
388
|
-
// Process each message in the batch
|
|
389
|
-
for (const message of batch) {
|
|
390
|
-
if (isJsonRpcRequest(message)) {
|
|
391
|
-
// Requests expect responses
|
|
392
|
-
const response = await this.registry.execute(message.id, message.method, message.params, authContext);
|
|
393
|
-
responses.push(response);
|
|
394
|
-
}
|
|
395
|
-
else if (isJsonRpcNotification(message)) {
|
|
396
|
-
// Notifications don't expect responses
|
|
397
|
-
await this.registry.execute('', // Notifications don't have IDs
|
|
398
|
-
message.method, message.params, authContext);
|
|
399
|
-
// Don't add to responses array
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
// Send batch response if there are any responses
|
|
403
|
-
if (responses.length > 0) {
|
|
404
|
-
await this.transport.send(responses);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Handle transport errors
|
|
409
|
-
*/
|
|
410
|
-
handleTransportError(error) {
|
|
411
|
-
console.error('Transport error:', error);
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Start the server
|
|
415
|
-
*/
|
|
416
|
-
start() {
|
|
417
|
-
if (this.isRunning)
|
|
418
|
-
return;
|
|
419
|
-
this.isRunning = true;
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* Stop the server
|
|
423
|
-
*/
|
|
424
|
-
async stop() {
|
|
425
|
-
if (!this.isRunning)
|
|
426
|
-
return;
|
|
427
|
-
this.isRunning = false;
|
|
428
|
-
await this.transport.close();
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Get registered methods for discovery
|
|
432
|
-
*/
|
|
433
|
-
getMethods() {
|
|
434
|
-
return this.registry.getMethods().map(m => m.name);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
//# sourceMappingURL=server.js.map
|
package/dist/rpc/server.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/rpc/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAsB,MAAM,eAAe,CAAC;AACnE,OAAO,EACN,aAAa,EASb,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS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