wave-agent-sdk 0.16.5 → 0.16.6
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/services/authService.d.ts +8 -0
- package/dist/services/authService.d.ts.map +1 -1
- package/dist/services/authService.js +9 -2
- package/dist/utils/containerSetup.d.ts.map +1 -1
- package/dist/utils/containerSetup.js +3 -0
- package/package.json +1 -1
- package/src/services/authService.ts +13 -2
- package/src/utils/containerSetup.ts +3 -0
|
@@ -7,7 +7,13 @@
|
|
|
7
7
|
import type { AuthConfig, AuthUser } from "../types/auth.js";
|
|
8
8
|
export declare class AuthService {
|
|
9
9
|
private static instance;
|
|
10
|
+
private _serverUrl;
|
|
10
11
|
static getInstance(): AuthService;
|
|
12
|
+
/**
|
|
13
|
+
* Set server URL programmatically (e.g. from AgentOptions.serverUrl).
|
|
14
|
+
* Takes priority over WAVE_SERVER_URL environment variable.
|
|
15
|
+
*/
|
|
16
|
+
setServerUrl(url: string): void;
|
|
11
17
|
getAuthPath(): string;
|
|
12
18
|
loadAuth(): AuthConfig;
|
|
13
19
|
saveAuth(config: AuthConfig): void;
|
|
@@ -19,6 +25,8 @@ export declare class AuthService {
|
|
|
19
25
|
onAuthUrl?: (url: string) => void;
|
|
20
26
|
/** Read authorization code manually (e.g. from stdin). Resolves with code or rejects on cancel. */
|
|
21
27
|
readToken?: () => Promise<string>;
|
|
28
|
+
/** Server URL override. Falls back to setServerUrl() or WAVE_SERVER_URL env var. */
|
|
29
|
+
serverUrl?: string;
|
|
22
30
|
}): Promise<string>;
|
|
23
31
|
/**
|
|
24
32
|
* Exchange a short-lived authorization code for a JWT token.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authService.d.ts","sourceRoot":"","sources":["../../src/services/authService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI7D,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAc;
|
|
1
|
+
{"version":3,"file":"authService.d.ts","sourceRoot":"","sources":["../../src/services/authService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI7D,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAc;IACrC,OAAO,CAAC,UAAU,CAAqB;IAEvC,MAAM,CAAC,WAAW,IAAI,WAAW;IAOjC;;;OAGG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI/B,WAAW,IAAI,MAAM;IAKrB,QAAQ,IAAI,UAAU;IAatB,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAUlC,SAAS,IAAI,IAAI;IAajB,WAAW,IAAI,MAAM,GAAG,SAAS;IAKjC,YAAY,IAAI,MAAM;IAUhB,KAAK,CAAC,OAAO,CAAC,EAAE;QACpB,6DAA6D;QAC7D,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;QAClC,mGAAmG;QACnG,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;QAClC,oFAAoF;QACpF,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,OAAO,CAAC,MAAM,CAAC;IAmBnB;;;OAGG;YACW,YAAY;IA0B1B,OAAO,CAAC,oBAAoB;YAoGd,WAAW;IAmBzB,kBAAkB,IAAI,OAAO;IAI7B,WAAW,IAAI,QAAQ,GAAG,SAAS;CAIpC;AAED,eAAO,MAAM,WAAW,aAA4B,CAAC"}
|
|
@@ -19,6 +19,13 @@ export class AuthService {
|
|
|
19
19
|
}
|
|
20
20
|
return AuthService.instance;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Set server URL programmatically (e.g. from AgentOptions.serverUrl).
|
|
24
|
+
* Takes priority over WAVE_SERVER_URL environment variable.
|
|
25
|
+
*/
|
|
26
|
+
setServerUrl(url) {
|
|
27
|
+
this._serverUrl = url;
|
|
28
|
+
}
|
|
22
29
|
getAuthPath() {
|
|
23
30
|
const homeDir = os.homedir();
|
|
24
31
|
return path.join(homeDir, ".wave", "auth.json");
|
|
@@ -63,14 +70,14 @@ export class AuthService {
|
|
|
63
70
|
return config.SSO_TOKEN;
|
|
64
71
|
}
|
|
65
72
|
getServerUrl() {
|
|
66
|
-
const url = process.env.WAVE_SERVER_URL;
|
|
73
|
+
const url = this._serverUrl || process.env.WAVE_SERVER_URL;
|
|
67
74
|
if (!url) {
|
|
68
75
|
throw new Error("WAVE_SERVER_URL environment variable is not set. SSO authentication requires this to be configured.");
|
|
69
76
|
}
|
|
70
77
|
return url;
|
|
71
78
|
}
|
|
72
79
|
async login(options) {
|
|
73
|
-
const serverUrl = this.getServerUrl();
|
|
80
|
+
const serverUrl = options?.serverUrl || this.getServerUrl();
|
|
74
81
|
// Start local server, open browser, wait for callback or manual input
|
|
75
82
|
const { code } = await this.startLocalAuthServer(serverUrl, {
|
|
76
83
|
onAuthUrl: options?.onAuthUrl,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerSetup.d.ts","sourceRoot":"","sources":["../../src/utils/containerSetup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAwB3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAM3E,OAAO,KAAK,EAAE,YAAY,EAAmB,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EACV,cAAc,EACd,KAAK,EACL,IAAI,EACJ,cAAc,EAEf,MAAM,mBAAmB,CAAC;AAK3B,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,YAAY,CAAC,EAAE,M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AAI,CAAC;IACvC,sBAAsB,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACvD,wBAAwB,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IACzD,iBAAiB,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,IAAI,CAAC;IAClD,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,0BAA0B,GACvC,SAAS,CAoRX"}
|
|
@@ -91,6 +91,9 @@ export function setupAgentContainer(setupOptions) {
|
|
|
91
91
|
container.register("BackgroundTaskManager", backgroundTaskManager);
|
|
92
92
|
const ssoToken = authService.getSSOToken();
|
|
93
93
|
const serverUrl = options.serverUrl || process.env.WAVE_SERVER_URL;
|
|
94
|
+
if (options.serverUrl) {
|
|
95
|
+
authService.setServerUrl(options.serverUrl);
|
|
96
|
+
}
|
|
94
97
|
const mcpManager = new McpManager(container, {
|
|
95
98
|
callbacks,
|
|
96
99
|
mcpServers: options.mcpServers,
|
package/package.json
CHANGED
|
@@ -25,6 +25,7 @@ const execFileAsync = promisify(execFile);
|
|
|
25
25
|
|
|
26
26
|
export class AuthService {
|
|
27
27
|
private static instance: AuthService;
|
|
28
|
+
private _serverUrl: string | undefined;
|
|
28
29
|
|
|
29
30
|
static getInstance(): AuthService {
|
|
30
31
|
if (!AuthService.instance) {
|
|
@@ -33,6 +34,14 @@ export class AuthService {
|
|
|
33
34
|
return AuthService.instance;
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Set server URL programmatically (e.g. from AgentOptions.serverUrl).
|
|
39
|
+
* Takes priority over WAVE_SERVER_URL environment variable.
|
|
40
|
+
*/
|
|
41
|
+
setServerUrl(url: string): void {
|
|
42
|
+
this._serverUrl = url;
|
|
43
|
+
}
|
|
44
|
+
|
|
36
45
|
getAuthPath(): string {
|
|
37
46
|
const homeDir = os.homedir();
|
|
38
47
|
return path.join(homeDir, ".wave", "auth.json");
|
|
@@ -80,7 +89,7 @@ export class AuthService {
|
|
|
80
89
|
}
|
|
81
90
|
|
|
82
91
|
getServerUrl(): string {
|
|
83
|
-
const url = process.env.WAVE_SERVER_URL;
|
|
92
|
+
const url = this._serverUrl || process.env.WAVE_SERVER_URL;
|
|
84
93
|
if (!url) {
|
|
85
94
|
throw new Error(
|
|
86
95
|
"WAVE_SERVER_URL environment variable is not set. SSO authentication requires this to be configured.",
|
|
@@ -94,8 +103,10 @@ export class AuthService {
|
|
|
94
103
|
onAuthUrl?: (url: string) => void;
|
|
95
104
|
/** Read authorization code manually (e.g. from stdin). Resolves with code or rejects on cancel. */
|
|
96
105
|
readToken?: () => Promise<string>;
|
|
106
|
+
/** Server URL override. Falls back to setServerUrl() or WAVE_SERVER_URL env var. */
|
|
107
|
+
serverUrl?: string;
|
|
97
108
|
}): Promise<string> {
|
|
98
|
-
const serverUrl = this.getServerUrl();
|
|
109
|
+
const serverUrl = options?.serverUrl || this.getServerUrl();
|
|
99
110
|
|
|
100
111
|
// Start local server, open browser, wait for callback or manual input
|
|
101
112
|
const { code } = await this.startLocalAuthServer(serverUrl, {
|
|
@@ -148,6 +148,9 @@ export function setupAgentContainer(
|
|
|
148
148
|
|
|
149
149
|
const ssoToken = authService.getSSOToken();
|
|
150
150
|
const serverUrl = options.serverUrl || process.env.WAVE_SERVER_URL;
|
|
151
|
+
if (options.serverUrl) {
|
|
152
|
+
authService.setServerUrl(options.serverUrl);
|
|
153
|
+
}
|
|
151
154
|
const mcpManager = new McpManager(container, {
|
|
152
155
|
callbacks,
|
|
153
156
|
mcpServers: options.mcpServers as
|