@shin1ohno/sage 0.3.0 → 0.5.5
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/cli/http-server-with-config.d.ts +38 -0
- package/dist/cli/http-server-with-config.d.ts.map +1 -0
- package/dist/cli/http-server-with-config.js +477 -0
- package/dist/cli/http-server-with-config.js.map +1 -0
- package/dist/cli/http-server.d.ts +74 -0
- package/dist/cli/http-server.d.ts.map +1 -0
- package/dist/cli/http-server.js +407 -0
- package/dist/cli/http-server.js.map +1 -0
- package/dist/cli/jwt-middleware.d.ts +36 -0
- package/dist/cli/jwt-middleware.d.ts.map +1 -0
- package/dist/cli/jwt-middleware.js +99 -0
- package/dist/cli/jwt-middleware.js.map +1 -0
- package/dist/cli/main-entry.d.ts +45 -0
- package/dist/cli/main-entry.d.ts.map +1 -0
- package/dist/cli/main-entry.js +192 -0
- package/dist/cli/main-entry.js.map +1 -0
- package/dist/cli/mcp-handler.d.ts +56 -0
- package/dist/cli/mcp-handler.d.ts.map +1 -0
- package/dist/cli/mcp-handler.js +2189 -0
- package/dist/cli/mcp-handler.js.map +1 -0
- package/dist/cli/parser.d.ts +45 -0
- package/dist/cli/parser.d.ts.map +1 -0
- package/dist/cli/parser.js +172 -0
- package/dist/cli/parser.js.map +1 -0
- package/dist/cli/remote-config-loader.d.ts +89 -0
- package/dist/cli/remote-config-loader.d.ts.map +1 -0
- package/dist/cli/remote-config-loader.js +129 -0
- package/dist/cli/remote-config-loader.js.map +1 -0
- package/dist/cli/secret-auth.d.ts +47 -0
- package/dist/cli/secret-auth.d.ts.map +1 -0
- package/dist/cli/secret-auth.js +165 -0
- package/dist/cli/secret-auth.js.map +1 -0
- package/dist/cli/sse-stream-handler.d.ts +45 -0
- package/dist/cli/sse-stream-handler.d.ts.map +1 -0
- package/dist/cli/sse-stream-handler.js +125 -0
- package/dist/cli/sse-stream-handler.js.map +1 -0
- package/dist/index.js +897 -209
- package/dist/index.js.map +1 -1
- package/dist/integrations/calendar-event-creator.d.ts +152 -0
- package/dist/integrations/calendar-event-creator.d.ts.map +1 -0
- package/dist/integrations/calendar-event-creator.js +507 -0
- package/dist/integrations/calendar-event-creator.js.map +1 -0
- package/dist/integrations/calendar-event-deleter.d.ts +137 -0
- package/dist/integrations/calendar-event-deleter.d.ts.map +1 -0
- package/dist/integrations/calendar-event-deleter.js +378 -0
- package/dist/integrations/calendar-event-deleter.js.map +1 -0
- package/dist/integrations/calendar-event-response.d.ts +213 -0
- package/dist/integrations/calendar-event-response.d.ts.map +1 -0
- package/dist/integrations/calendar-event-response.js +560 -0
- package/dist/integrations/calendar-event-response.js.map +1 -0
- package/dist/integrations/calendar-service.d.ts +66 -1
- package/dist/integrations/calendar-service.d.ts.map +1 -1
- package/dist/integrations/calendar-service.js +223 -0
- package/dist/integrations/calendar-service.js.map +1 -1
- package/dist/oauth/client-store.d.ts +36 -0
- package/dist/oauth/client-store.d.ts.map +1 -0
- package/dist/oauth/client-store.js +119 -0
- package/dist/oauth/client-store.js.map +1 -0
- package/dist/oauth/code-store.d.ts +48 -0
- package/dist/oauth/code-store.d.ts.map +1 -0
- package/dist/oauth/code-store.js +89 -0
- package/dist/oauth/code-store.js.map +1 -0
- package/dist/oauth/index.d.ts +13 -0
- package/dist/oauth/index.d.ts.map +1 -0
- package/dist/oauth/index.js +21 -0
- package/dist/oauth/index.js.map +1 -0
- package/dist/oauth/oauth-handler.d.ts +101 -0
- package/dist/oauth/oauth-handler.d.ts.map +1 -0
- package/dist/oauth/oauth-handler.js +577 -0
- package/dist/oauth/oauth-handler.js.map +1 -0
- package/dist/oauth/oauth-server.d.ts +165 -0
- package/dist/oauth/oauth-server.d.ts.map +1 -0
- package/dist/oauth/oauth-server.js +489 -0
- package/dist/oauth/oauth-server.js.map +1 -0
- package/dist/oauth/pkce.d.ts +48 -0
- package/dist/oauth/pkce.d.ts.map +1 -0
- package/dist/oauth/pkce.js +106 -0
- package/dist/oauth/pkce.js.map +1 -0
- package/dist/oauth/refresh-token-store.d.ts +45 -0
- package/dist/oauth/refresh-token-store.d.ts.map +1 -0
- package/dist/oauth/refresh-token-store.js +98 -0
- package/dist/oauth/refresh-token-store.js.map +1 -0
- package/dist/oauth/token-service.d.ts +46 -0
- package/dist/oauth/token-service.d.ts.map +1 -0
- package/dist/oauth/token-service.js +199 -0
- package/dist/oauth/token-service.js.map +1 -0
- package/dist/oauth/types.d.ts +269 -0
- package/dist/oauth/types.d.ts.map +1 -0
- package/dist/oauth/types.js +53 -0
- package/dist/oauth/types.js.map +1 -0
- package/dist/version.d.ts +9 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +11 -0
- package/dist/version.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main Entry Point for sage
|
|
3
|
+
* Requirements: 14.1, 14.2, 14.3
|
|
4
|
+
*
|
|
5
|
+
* Handles server startup based on CLI options.
|
|
6
|
+
*/
|
|
7
|
+
import { getHelpMessage, getVersion } from './parser.js';
|
|
8
|
+
import { createHTTPServerWithConfig } from './http-server-with-config.js';
|
|
9
|
+
import { loadRemoteConfig, DEFAULT_REMOTE_CONFIG_PATH } from './remote-config-loader.js';
|
|
10
|
+
import { createSecretAuthenticator } from './secret-auth.js';
|
|
11
|
+
/**
|
|
12
|
+
* Start the server based on CLI options
|
|
13
|
+
* @param options - Parsed CLI options
|
|
14
|
+
* @returns Server start result
|
|
15
|
+
*/
|
|
16
|
+
export async function startServer(options) {
|
|
17
|
+
// Handle help
|
|
18
|
+
if (options.help) {
|
|
19
|
+
return {
|
|
20
|
+
mode: 'help',
|
|
21
|
+
success: true,
|
|
22
|
+
message: getHelpMessage(),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// Handle version
|
|
26
|
+
if (options.version) {
|
|
27
|
+
return {
|
|
28
|
+
mode: 'version',
|
|
29
|
+
success: true,
|
|
30
|
+
message: getVersion(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// Handle token generation
|
|
34
|
+
if (options.generateToken) {
|
|
35
|
+
try {
|
|
36
|
+
const configPath = options.config ?? DEFAULT_REMOTE_CONFIG_PATH;
|
|
37
|
+
const config = await loadRemoteConfig(configPath);
|
|
38
|
+
if (config.remote.auth.type === 'jwt') {
|
|
39
|
+
// JWT mode: generate token using secret
|
|
40
|
+
const secret = options.authSecret ?? config.remote.auth.secret;
|
|
41
|
+
if (!secret) {
|
|
42
|
+
return {
|
|
43
|
+
mode: 'token-gen',
|
|
44
|
+
success: false,
|
|
45
|
+
error: 'JWT secret not configured. Set auth.secret in remote-config.json or use SAGE_AUTH_SECRET environment variable',
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const expiresIn = config.remote.auth.expiresIn ?? '24h';
|
|
49
|
+
const authenticator = createSecretAuthenticator({ secret, expiresIn });
|
|
50
|
+
const result = await authenticator.authenticate(secret);
|
|
51
|
+
if (!result.success || !result.token) {
|
|
52
|
+
return {
|
|
53
|
+
mode: 'token-gen',
|
|
54
|
+
success: false,
|
|
55
|
+
error: result.error ?? 'Failed to generate token',
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
mode: 'token-gen',
|
|
60
|
+
success: true,
|
|
61
|
+
token: result.token,
|
|
62
|
+
expiresIn: result.expiresIn,
|
|
63
|
+
message: `Bearer token generated successfully.
|
|
64
|
+
|
|
65
|
+
Token: ${result.token}
|
|
66
|
+
Expires in: ${result.expiresIn ?? 86400} seconds
|
|
67
|
+
|
|
68
|
+
Usage with Claude Code:
|
|
69
|
+
claude mcp add --transport http sage "http://your-server:${config.remote.port}/mcp" --header "Authorization: Bearer ${result.token}"`,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
else if (config.remote.auth.type === 'oauth2') {
|
|
73
|
+
// OAuth2 mode: check if static tokens are enabled
|
|
74
|
+
const oauthConfig = config.remote.auth;
|
|
75
|
+
const issuer = oauthConfig.issuer || `http://localhost:${config.remote.port}`;
|
|
76
|
+
if (!oauthConfig.allowStaticTokens || !oauthConfig.staticTokenSecret) {
|
|
77
|
+
return {
|
|
78
|
+
mode: 'token-gen',
|
|
79
|
+
success: false,
|
|
80
|
+
error: `Static token generation is not enabled for OAuth2 mode.
|
|
81
|
+
|
|
82
|
+
To enable it, add the following to your remote-config.json:
|
|
83
|
+
{
|
|
84
|
+
"remote": {
|
|
85
|
+
"auth": {
|
|
86
|
+
"type": "oauth2",
|
|
87
|
+
...
|
|
88
|
+
"allowStaticTokens": true,
|
|
89
|
+
"staticTokenSecret": "your-secret-key-at-least-32-characters-long"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
Alternatively, use the OAuth2 flow with SSH port forwarding.`,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// Generate static JWT token using the configured secret
|
|
98
|
+
const authenticator = createSecretAuthenticator({
|
|
99
|
+
secret: oauthConfig.staticTokenSecret,
|
|
100
|
+
expiresIn: oauthConfig.accessTokenExpiry ?? '1h',
|
|
101
|
+
});
|
|
102
|
+
const result = await authenticator.authenticate(oauthConfig.staticTokenSecret);
|
|
103
|
+
if (!result.success || !result.token) {
|
|
104
|
+
return {
|
|
105
|
+
mode: 'token-gen',
|
|
106
|
+
success: false,
|
|
107
|
+
error: result.error ?? 'Failed to generate token',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
mode: 'token-gen',
|
|
112
|
+
success: true,
|
|
113
|
+
token: result.token,
|
|
114
|
+
expiresIn: result.expiresIn,
|
|
115
|
+
message: `Bearer token generated successfully (OAuth2 + Static Token mode).
|
|
116
|
+
|
|
117
|
+
Token: ${result.token}
|
|
118
|
+
Expires in: ${result.expiresIn ?? 3600} seconds
|
|
119
|
+
|
|
120
|
+
This token can be used alongside the OAuth2 flow for CLI access.
|
|
121
|
+
|
|
122
|
+
Usage with Claude Code:
|
|
123
|
+
claude mcp add --transport http sage "${issuer}/mcp" --header "Authorization: Bearer ${result.token}"`,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
// No auth mode
|
|
128
|
+
return {
|
|
129
|
+
mode: 'token-gen',
|
|
130
|
+
success: false,
|
|
131
|
+
error: 'Authentication is disabled. Set auth.type to "jwt" or "oauth2" in remote-config.json',
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
return {
|
|
137
|
+
mode: 'token-gen',
|
|
138
|
+
success: false,
|
|
139
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Start in HTTP mode if remote flag is set
|
|
144
|
+
if (options.remote) {
|
|
145
|
+
try {
|
|
146
|
+
// createHTTPServerWithConfig already starts the server
|
|
147
|
+
const server = await createHTTPServerWithConfig({
|
|
148
|
+
configPath: options.config,
|
|
149
|
+
port: options.port,
|
|
150
|
+
host: options.host,
|
|
151
|
+
authSecret: options.authSecret,
|
|
152
|
+
});
|
|
153
|
+
return {
|
|
154
|
+
mode: 'http',
|
|
155
|
+
success: true,
|
|
156
|
+
port: server.getPort(),
|
|
157
|
+
host: server.getHost(),
|
|
158
|
+
configPath: options.config,
|
|
159
|
+
authEnabled: server.isAuthEnabled(),
|
|
160
|
+
stop: async () => {
|
|
161
|
+
await server.stop();
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
return {
|
|
167
|
+
mode: 'http',
|
|
168
|
+
success: false,
|
|
169
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Start in Stdio mode (default)
|
|
174
|
+
try {
|
|
175
|
+
// In Stdio mode, we don't actually start the server here
|
|
176
|
+
// The MCP server will be connected via StdioServerTransport
|
|
177
|
+
// This is handled in the main index.ts
|
|
178
|
+
return {
|
|
179
|
+
mode: 'stdio',
|
|
180
|
+
success: true,
|
|
181
|
+
configPath: options.config,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
return {
|
|
186
|
+
mode: 'stdio',
|
|
187
|
+
success: false,
|
|
188
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=main-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main-entry.js","sourceRoot":"","sources":["../../src/cli/main-entry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAc,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAmC7D;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAmB;IACnD,cAAc;IACd,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,OAAO;YACL,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,cAAc,EAAE;SAC1B,CAAC;IACJ,CAAC;IAED,iBAAiB;IACjB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO;YACL,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,UAAU,EAAE;SACtB,CAAC;IACJ,CAAC;IAED,0BAA0B;IAC1B,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;QAC1B,IAAI,CAAC;YACH,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,IAAI,0BAA0B,CAAC;YAChE,MAAM,MAAM,GAAG,MAAM,gBAAgB,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C;QACvC,OAAO;YACL,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,OAAO,CAAC,MAAM;SAC3B,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;SAChE,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Handler for HTTP Server
|
|
3
|
+
* Requirements: 13.1, 13.4, 13.5
|
|
4
|
+
*
|
|
5
|
+
* Handles MCP JSON-RPC requests over HTTP, providing access to all sage tools.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* MCP JSON-RPC Request
|
|
9
|
+
*/
|
|
10
|
+
export interface MCPRequest {
|
|
11
|
+
jsonrpc: '2.0';
|
|
12
|
+
id: number | string | null;
|
|
13
|
+
method: string;
|
|
14
|
+
params?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* MCP JSON-RPC Response
|
|
18
|
+
*/
|
|
19
|
+
export interface MCPResponse {
|
|
20
|
+
jsonrpc: '2.0';
|
|
21
|
+
id: number | string | null;
|
|
22
|
+
result?: unknown;
|
|
23
|
+
error?: MCPError;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* MCP Error
|
|
27
|
+
*/
|
|
28
|
+
export interface MCPError {
|
|
29
|
+
code: number;
|
|
30
|
+
message: string;
|
|
31
|
+
data?: unknown;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Tool definition
|
|
35
|
+
*/
|
|
36
|
+
export interface ToolDefinition {
|
|
37
|
+
name: string;
|
|
38
|
+
description: string;
|
|
39
|
+
inputSchema: {
|
|
40
|
+
type: 'object';
|
|
41
|
+
properties: Record<string, unknown>;
|
|
42
|
+
required?: string[];
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* MCP Handler interface
|
|
47
|
+
*/
|
|
48
|
+
export interface MCPHandler {
|
|
49
|
+
handleRequest(request: MCPRequest): Promise<MCPResponse>;
|
|
50
|
+
listTools(): ToolDefinition[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Create an MCP handler
|
|
54
|
+
*/
|
|
55
|
+
export declare function createMCPHandler(): Promise<MCPHandler>;
|
|
56
|
+
//# sourceMappingURL=mcp-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-handler.d.ts","sourceRoot":"","sources":["../../src/cli/mcp-handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmBH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,QAAQ,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;CACH;AASD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,aAAa,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACzD,SAAS,IAAI,cAAc,EAAE,CAAC;CAC/B;AAgrFD;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,UAAU,CAAC,CAI5D"}
|