sylas-ai 0.2.21
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.
Potentially problematic release.
This version of sylas-ai might be problematic. Click here for more details.
- package/README.md +52 -0
- package/dist/Application.d.ts +75 -0
- package/dist/Application.d.ts.map +1 -0
- package/dist/Application.js +289 -0
- package/dist/Application.js.map +1 -0
- package/dist/app.d.ts +3 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +93 -0
- package/dist/app.js.map +1 -0
- package/dist/commands/AuthCommand.d.ts +8 -0
- package/dist/commands/AuthCommand.d.ts.map +1 -0
- package/dist/commands/AuthCommand.js +70 -0
- package/dist/commands/AuthCommand.js.map +1 -0
- package/dist/commands/CheckTokensCommand.d.ts +8 -0
- package/dist/commands/CheckTokensCommand.d.ts.map +1 -0
- package/dist/commands/CheckTokensCommand.js +53 -0
- package/dist/commands/CheckTokensCommand.js.map +1 -0
- package/dist/commands/ICommand.d.ts +38 -0
- package/dist/commands/ICommand.d.ts.map +1 -0
- package/dist/commands/ICommand.js +37 -0
- package/dist/commands/ICommand.js.map +1 -0
- package/dist/commands/RefreshTokenCommand.d.ts +8 -0
- package/dist/commands/RefreshTokenCommand.d.ts.map +1 -0
- package/dist/commands/RefreshTokenCommand.js +152 -0
- package/dist/commands/RefreshTokenCommand.js.map +1 -0
- package/dist/commands/SelfAddRepoCommand.d.ts +17 -0
- package/dist/commands/SelfAddRepoCommand.d.ts.map +1 -0
- package/dist/commands/SelfAddRepoCommand.js +164 -0
- package/dist/commands/SelfAddRepoCommand.js.map +1 -0
- package/dist/commands/SelfAuthCommand.d.ts +16 -0
- package/dist/commands/SelfAuthCommand.d.ts.map +1 -0
- package/dist/commands/SelfAuthCommand.js +213 -0
- package/dist/commands/SelfAuthCommand.js.map +1 -0
- package/dist/commands/StartCommand.d.ts +8 -0
- package/dist/commands/StartCommand.d.ts.map +1 -0
- package/dist/commands/StartCommand.js +76 -0
- package/dist/commands/StartCommand.js.map +1 -0
- package/dist/config/constants.d.ts +12 -0
- package/dist/config/constants.d.ts.map +1 -0
- package/dist/config/constants.js +19 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/config/types.d.ts +21 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +2 -0
- package/dist/config/types.js.map +1 -0
- package/dist/services/ConfigService.d.ts +37 -0
- package/dist/services/ConfigService.d.ts.map +1 -0
- package/dist/services/ConfigService.js +121 -0
- package/dist/services/ConfigService.js.map +1 -0
- package/dist/services/Logger.d.ts +77 -0
- package/dist/services/Logger.d.ts.map +1 -0
- package/dist/services/Logger.js +100 -0
- package/dist/services/Logger.js.map +1 -0
- package/dist/services/WorkerService.d.ts +59 -0
- package/dist/services/WorkerService.d.ts.map +1 -0
- package/dist/services/WorkerService.js +220 -0
- package/dist/services/WorkerService.js.map +1 -0
- package/dist/src/Application.d.ts +75 -0
- package/dist/src/Application.d.ts.map +1 -0
- package/dist/src/Application.js +289 -0
- package/dist/src/Application.js.map +1 -0
- package/dist/src/app.d.ts +3 -0
- package/dist/src/app.d.ts.map +1 -0
- package/dist/src/app.js +93 -0
- package/dist/src/app.js.map +1 -0
- package/dist/src/commands/AuthCommand.d.ts +8 -0
- package/dist/src/commands/AuthCommand.d.ts.map +1 -0
- package/dist/src/commands/AuthCommand.js +70 -0
- package/dist/src/commands/AuthCommand.js.map +1 -0
- package/dist/src/commands/CheckTokensCommand.d.ts +8 -0
- package/dist/src/commands/CheckTokensCommand.d.ts.map +1 -0
- package/dist/src/commands/CheckTokensCommand.js +53 -0
- package/dist/src/commands/CheckTokensCommand.js.map +1 -0
- package/dist/src/commands/ICommand.d.ts +38 -0
- package/dist/src/commands/ICommand.d.ts.map +1 -0
- package/dist/src/commands/ICommand.js +37 -0
- package/dist/src/commands/ICommand.js.map +1 -0
- package/dist/src/commands/RefreshTokenCommand.d.ts +8 -0
- package/dist/src/commands/RefreshTokenCommand.d.ts.map +1 -0
- package/dist/src/commands/RefreshTokenCommand.js +152 -0
- package/dist/src/commands/RefreshTokenCommand.js.map +1 -0
- package/dist/src/commands/SelfAddRepoCommand.d.ts +17 -0
- package/dist/src/commands/SelfAddRepoCommand.d.ts.map +1 -0
- package/dist/src/commands/SelfAddRepoCommand.js +164 -0
- package/dist/src/commands/SelfAddRepoCommand.js.map +1 -0
- package/dist/src/commands/SelfAuthCommand.d.ts +16 -0
- package/dist/src/commands/SelfAuthCommand.d.ts.map +1 -0
- package/dist/src/commands/SelfAuthCommand.js +213 -0
- package/dist/src/commands/SelfAuthCommand.js.map +1 -0
- package/dist/src/commands/StartCommand.d.ts +8 -0
- package/dist/src/commands/StartCommand.d.ts.map +1 -0
- package/dist/src/commands/StartCommand.js +76 -0
- package/dist/src/commands/StartCommand.js.map +1 -0
- package/dist/src/config/constants.d.ts +12 -0
- package/dist/src/config/constants.d.ts.map +1 -0
- package/dist/src/config/constants.js +19 -0
- package/dist/src/config/constants.js.map +1 -0
- package/dist/src/config/types.d.ts +21 -0
- package/dist/src/config/types.d.ts.map +1 -0
- package/dist/src/config/types.js +2 -0
- package/dist/src/config/types.js.map +1 -0
- package/dist/src/services/ConfigService.d.ts +37 -0
- package/dist/src/services/ConfigService.d.ts.map +1 -0
- package/dist/src/services/ConfigService.js +121 -0
- package/dist/src/services/ConfigService.js.map +1 -0
- package/dist/src/services/Logger.d.ts +77 -0
- package/dist/src/services/Logger.d.ts.map +1 -0
- package/dist/src/services/Logger.js +100 -0
- package/dist/src/services/Logger.js.map +1 -0
- package/dist/src/services/WorkerService.d.ts +59 -0
- package/dist/src/services/WorkerService.d.ts.map +1 -0
- package/dist/src/services/WorkerService.js +220 -0
- package/dist/src/services/WorkerService.js.map +1 -0
- package/dist/src/ui/CLIPrompts.d.ts +18 -0
- package/dist/src/ui/CLIPrompts.d.ts.map +1 -0
- package/dist/src/ui/CLIPrompts.js +53 -0
- package/dist/src/ui/CLIPrompts.js.map +1 -0
- package/dist/ui/CLIPrompts.d.ts +18 -0
- package/dist/ui/CLIPrompts.d.ts.map +1 -0
- package/dist/ui/CLIPrompts.js +53 -0
- package/dist/ui/CLIPrompts.js.map +1 -0
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/dist/vitest.config.js +13 -0
- package/dist/vitest.config.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { getSylasAppUrl } from "sylas-cloudflare-tunnel-client";
|
|
2
|
+
import { BaseCommand } from "./ICommand.js";
|
|
3
|
+
/**
|
|
4
|
+
* Start command - main entry point for starting the edge worker
|
|
5
|
+
*/
|
|
6
|
+
export class StartCommand extends BaseCommand {
|
|
7
|
+
async execute(_args) {
|
|
8
|
+
try {
|
|
9
|
+
// Load edge configuration
|
|
10
|
+
const edgeConfig = this.app.config.load();
|
|
11
|
+
const repositories = edgeConfig.repositories || [];
|
|
12
|
+
// Check if we're in setup waiting mode (no repositories + SYLAS_SETUP_PENDING flag)
|
|
13
|
+
if (repositories.length === 0 &&
|
|
14
|
+
process.env.SYLAS_SETUP_PENDING === "true") {
|
|
15
|
+
// Enable setup waiting mode and start config watcher
|
|
16
|
+
this.app.enableSetupWaitingMode();
|
|
17
|
+
// Start setup waiting mode - server only, no EdgeWorker
|
|
18
|
+
await this.app.worker.startSetupWaitingMode();
|
|
19
|
+
// Setup signal handlers for graceful shutdown
|
|
20
|
+
this.app.setupSignalHandlers();
|
|
21
|
+
// Keep process alive and wait for configuration
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
// Check if we're in idle mode (no repositories, post-onboarding)
|
|
25
|
+
if (repositories.length === 0) {
|
|
26
|
+
// Enable idle mode and start config watcher
|
|
27
|
+
this.app.enableIdleMode();
|
|
28
|
+
// Start idle mode - server infrastructure only, no EdgeWorker
|
|
29
|
+
await this.app.worker.startIdleMode();
|
|
30
|
+
// Setup signal handlers for graceful shutdown
|
|
31
|
+
this.app.setupSignalHandlers();
|
|
32
|
+
// Keep process alive and wait for configuration
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
// Start the edge worker (SharedApplicationServer will start Cloudflare tunnel if CLOUDFLARE_TOKEN is set)
|
|
36
|
+
await this.app.worker.startEdgeWorker({
|
|
37
|
+
repositories,
|
|
38
|
+
});
|
|
39
|
+
// Display server information
|
|
40
|
+
const serverPort = this.app.worker.getServerPort();
|
|
41
|
+
this.logger.raw("");
|
|
42
|
+
this.logger.divider(70);
|
|
43
|
+
this.logger.success("Edge worker started successfully");
|
|
44
|
+
this.logger.info(`📌 Version: ${this.app.version}`);
|
|
45
|
+
this.logger.info(`🔗 Server running on port ${serverPort}`);
|
|
46
|
+
if (process.env.CLOUDFLARE_TOKEN) {
|
|
47
|
+
this.logger.info("🌩️ Cloudflare tunnel: Active");
|
|
48
|
+
}
|
|
49
|
+
this.logger.info(`\n📦 Managing ${repositories.length} repositories:`);
|
|
50
|
+
repositories.forEach((repo) => {
|
|
51
|
+
this.logger.info(` • ${repo.name} (${repo.repositoryPath})`);
|
|
52
|
+
});
|
|
53
|
+
this.logger.divider(70);
|
|
54
|
+
// Setup signal handlers for graceful shutdown
|
|
55
|
+
this.app.setupSignalHandlers();
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
this.logger.error(`Failed to start edge application: ${error.message}`);
|
|
59
|
+
// Provide helpful error guidance
|
|
60
|
+
if (error.message?.includes("CLOUDFLARE_TOKEN")) {
|
|
61
|
+
this.logger.info("\n💡 Cloudflare tunnel requires:");
|
|
62
|
+
this.logger.info(" - CLOUDFLARE_TOKEN environment variable");
|
|
63
|
+
this.logger.info(` - Get your token from: ${getSylasAppUrl()}/onboarding`);
|
|
64
|
+
}
|
|
65
|
+
else if (error.message?.includes("Failed to connect")) {
|
|
66
|
+
this.logger.info("\n💡 Connection issues can occur when:");
|
|
67
|
+
this.logger.info(" - Linear OAuth tokens have expired");
|
|
68
|
+
this.logger.info(" - The Linear API is temporarily unavailable");
|
|
69
|
+
this.logger.info(" - Your network connection is having issues");
|
|
70
|
+
}
|
|
71
|
+
await this.app.shutdown();
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=StartCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StartCommand.js","sourceRoot":"","sources":["../../../src/commands/StartCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC5C,KAAK,CAAC,OAAO,CAAC,KAAe;QAC5B,IAAI,CAAC;YACJ,0BAA0B;YAC1B,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YAC1C,MAAM,YAAY,GAAG,UAAU,CAAC,YAAY,IAAI,EAAE,CAAC;YAEnD,oFAAoF;YACpF,IACC,YAAY,CAAC,MAAM,KAAK,CAAC;gBACzB,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK,MAAM,EACzC,CAAC;gBACF,qDAAqD;gBACrD,IAAI,CAAC,GAAG,CAAC,sBAAsB,EAAE,CAAC;gBAElC,wDAAwD;gBACxD,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC;gBAE9C,8CAA8C;gBAC9C,IAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC;gBAE/B,gDAAgD;gBAChD,OAAO;YACR,CAAC;YAED,iEAAiE;YACjE,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC/B,4CAA4C;gBAC5C,IAAI,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;gBAE1B,8DAA8D;gBAC9D,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;gBAEtC,8CAA8C;gB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AAI,CAAC,MAAM,CAAC,KAAK,CAAC,qCAAqC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAExE,iCAAiC;YACjC,IAAI,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;gBACjD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;gBACrD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;gBAC/D,IAAI,CAAC,MAAM,CAAC,IAAI,CACf,6BAA6B,cAAc,EAAE,aAAa,CAC1D,CAAC;YACH,CAAC;iBAAM,IAAI,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;gBACzD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;gBAC3D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;gBAC1D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;gBACnE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;YACnE,CAAC;YAED,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;YAC1B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Application constants
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Default server port for OAuth callbacks and webhooks
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_SERVER_PORT = 3456;
|
|
8
|
+
/**
|
|
9
|
+
* Parse a port number from string with validation
|
|
10
|
+
*/
|
|
11
|
+
export declare function parsePort(value: string | undefined, defaultPort: number): number;
|
|
12
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/config/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC;;GAEG;AACH,wBAAgB,SAAS,CACxB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,WAAW,EAAE,MAAM,GACjB,MAAM,CAMR"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Application constants
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Default server port for OAuth callbacks and webhooks
|
|
6
|
+
*/
|
|
7
|
+
export const DEFAULT_SERVER_PORT = 3456;
|
|
8
|
+
/**
|
|
9
|
+
* Parse a port number from string with validation
|
|
10
|
+
*/
|
|
11
|
+
export function parsePort(value, defaultPort) {
|
|
12
|
+
if (!value)
|
|
13
|
+
return defaultPort;
|
|
14
|
+
const parsed = parseInt(value, 10);
|
|
15
|
+
return Number.isNaN(parsed) || parsed < 1 || parsed > 65535
|
|
16
|
+
? defaultPort
|
|
17
|
+
: parsed;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/config/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,SAAS,CACxB,KAAyB,EACzB,WAAmB;IAEnB,IAAI,CAAC,KAAK;QAAE,OAAO,WAAW,CAAC;IAC/B,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACnC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,KAAK;QAC1D,CAAC,CAAC,WAAW;QACb,CAAC,CAAC,MAAM,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { EdgeConfig } from "sylas-core";
|
|
2
|
+
/**
|
|
3
|
+
* Linear credentials obtained from OAuth flow
|
|
4
|
+
*/
|
|
5
|
+
export interface LinearCredentials {
|
|
6
|
+
linearToken: string;
|
|
7
|
+
linearWorkspaceId: string;
|
|
8
|
+
linearWorkspaceName: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Workspace information for issue processing
|
|
12
|
+
*/
|
|
13
|
+
export interface Workspace {
|
|
14
|
+
path: string;
|
|
15
|
+
isGitWorktree: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Re-export EdgeConfig from sylas-core for convenience
|
|
19
|
+
*/
|
|
20
|
+
export type { EdgeConfig };
|
|
21
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,YAAY,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/config/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { EdgeConfig } from "../config/types.js";
|
|
2
|
+
import type { Logger } from "./Logger.js";
|
|
3
|
+
/**
|
|
4
|
+
* Service responsible for configuration management
|
|
5
|
+
* Handles loading, saving, and validation of edge configuration
|
|
6
|
+
*/
|
|
7
|
+
export declare class ConfigService {
|
|
8
|
+
private logger;
|
|
9
|
+
private configPath;
|
|
10
|
+
constructor(sylasHome: string, logger: Logger);
|
|
11
|
+
/**
|
|
12
|
+
* Get the configuration file path
|
|
13
|
+
*/
|
|
14
|
+
getConfigPath(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Load edge configuration from disk
|
|
17
|
+
*/
|
|
18
|
+
load(): EdgeConfig;
|
|
19
|
+
/**
|
|
20
|
+
* Run migrations on config to ensure it's up to date
|
|
21
|
+
* Persists changes to disk if any migrations were applied
|
|
22
|
+
*/
|
|
23
|
+
private migrateConfig;
|
|
24
|
+
/**
|
|
25
|
+
* Save edge configuration to disk
|
|
26
|
+
*/
|
|
27
|
+
save(config: EdgeConfig): void;
|
|
28
|
+
/**
|
|
29
|
+
* Update a specific field in the configuration
|
|
30
|
+
*/
|
|
31
|
+
update(updater: (config: EdgeConfig) => EdgeConfig): void;
|
|
32
|
+
/**
|
|
33
|
+
* Check if configuration exists
|
|
34
|
+
*/
|
|
35
|
+
exists(): boolean;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=ConfigService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigService.d.ts","sourceRoot":"","sources":["../../../src/services/ConfigService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;GAGG;AACH,qBAAa,aAAa;IAKxB,OAAO,CAAC,MAAM;IAJf,OAAO,CAAC,UAAU,CAAS;gBAG1B,SAAS,EAAE,MAAM,EACT,MAAM,EAAE,MAAM;IAKvB;;OAEG;IACH,aAAa,IAAI,MAAM;IAIvB;;OAEG;IACH,IAAI,IAAI,UAAU;IAmClB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAuDrB;;OAEG;IACH,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAW9B;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,UAAU,GAAG,IAAI;IAMzD;;OAEG;IACH,MAAM,IAAI,OAAO;CAGjB"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname, resolve } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Service responsible for configuration management
|
|
5
|
+
* Handles loading, saving, and validation of edge configuration
|
|
6
|
+
*/
|
|
7
|
+
export class ConfigService {
|
|
8
|
+
logger;
|
|
9
|
+
configPath;
|
|
10
|
+
constructor(sylasHome, logger) {
|
|
11
|
+
this.logger = logger;
|
|
12
|
+
this.configPath = resolve(sylasHome, "config.json");
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get the configuration file path
|
|
16
|
+
*/
|
|
17
|
+
getConfigPath() {
|
|
18
|
+
return this.configPath;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Load edge configuration from disk
|
|
22
|
+
*/
|
|
23
|
+
load() {
|
|
24
|
+
let config = { repositories: [] };
|
|
25
|
+
if (existsSync(this.configPath)) {
|
|
26
|
+
try {
|
|
27
|
+
const content = readFileSync(this.configPath, "utf-8");
|
|
28
|
+
config = JSON.parse(content);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
this.logger.error(`Failed to load edge config: ${e.message}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Strip promptTemplatePath from all repositories to ensure built-in template is used
|
|
35
|
+
if (config.repositories) {
|
|
36
|
+
config.repositories = config.repositories.map((repo) => {
|
|
37
|
+
const { promptTemplatePath, ...repoWithoutTemplate } = repo;
|
|
38
|
+
if (promptTemplatePath) {
|
|
39
|
+
this.logger.info(`Ignoring custom prompt template for repository: ${repo.name} (using built-in template)`);
|
|
40
|
+
}
|
|
41
|
+
return repoWithoutTemplate;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
// Run migrations on loaded config
|
|
45
|
+
config = this.migrateConfig(config);
|
|
46
|
+
return config;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Run migrations on config to ensure it's up to date
|
|
50
|
+
* Persists changes to disk if any migrations were applied
|
|
51
|
+
*/
|
|
52
|
+
migrateConfig(config) {
|
|
53
|
+
let configModified = false;
|
|
54
|
+
// Migration: Rename legacy global model fields to Claude-specific names
|
|
55
|
+
// Keep old values but move them to the new keys and remove deprecated fields.
|
|
56
|
+
if (config.defaultModel !== undefined) {
|
|
57
|
+
if (!config.claudeDefaultModel) {
|
|
58
|
+
config.claudeDefaultModel = config.defaultModel;
|
|
59
|
+
this.logger.info(`[Migration] Moved "defaultModel" to "claudeDefaultModel"`);
|
|
60
|
+
}
|
|
61
|
+
delete config.defaultModel;
|
|
62
|
+
configModified = true;
|
|
63
|
+
}
|
|
64
|
+
if (config.defaultFallbackModel !== undefined) {
|
|
65
|
+
if (!config.claudeDefaultFallbackModel) {
|
|
66
|
+
config.claudeDefaultFallbackModel = config.defaultFallbackModel;
|
|
67
|
+
this.logger.info(`[Migration] Moved "defaultFallbackModel" to "claudeDefaultFallbackModel"`);
|
|
68
|
+
}
|
|
69
|
+
delete config
|
|
70
|
+
.defaultFallbackModel;
|
|
71
|
+
configModified = true;
|
|
72
|
+
}
|
|
73
|
+
// Migration: Add "Skill" to allowedTools arrays that don't have it
|
|
74
|
+
// This enables Claude Skills functionality for existing configurations
|
|
75
|
+
// See: https://code.claude.com/docs/en/skills
|
|
76
|
+
// See: https://platform.claude.com/docs/en/agent-sdk/skills
|
|
77
|
+
if (config.repositories) {
|
|
78
|
+
for (const repo of config.repositories) {
|
|
79
|
+
if (repo.allowedTools && Array.isArray(repo.allowedTools)) {
|
|
80
|
+
if (!repo.allowedTools.includes("Skill")) {
|
|
81
|
+
repo.allowedTools.push("Skill");
|
|
82
|
+
configModified = true;
|
|
83
|
+
this.logger.info(`[Migration] Added "Skill" to allowedTools for repository: ${repo.name}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Persist changes if any migrations were applied
|
|
89
|
+
if (configModified) {
|
|
90
|
+
this.save(config);
|
|
91
|
+
this.logger.info("[Migration] Configuration updated and saved to disk");
|
|
92
|
+
}
|
|
93
|
+
return config;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Save edge configuration to disk
|
|
97
|
+
*/
|
|
98
|
+
save(config) {
|
|
99
|
+
const configDir = dirname(this.configPath);
|
|
100
|
+
// Ensure the ~/.sylas directory exists
|
|
101
|
+
if (!existsSync(configDir)) {
|
|
102
|
+
mkdirSync(configDir, { recursive: true });
|
|
103
|
+
}
|
|
104
|
+
writeFileSync(this.configPath, JSON.stringify(config, null, 2));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Update a specific field in the configuration
|
|
108
|
+
*/
|
|
109
|
+
update(updater) {
|
|
110
|
+
const config = this.load();
|
|
111
|
+
const updated = updater(config);
|
|
112
|
+
this.save(updated);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Check if configuration exists
|
|
116
|
+
*/
|
|
117
|
+
exists() {
|
|
118
|
+
return existsSync(this.configPath);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=ConfigService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigService.js","sourceRoot":"","sources":["../../../src/services/ConfigService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAI7C;;;GAGG;AACH,MAAM,OAAO,aAAa;IAKhB;IAJD,UA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E,CACxE,CAAC;oBACH,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC;QAED,iDAAiD;QACjD,IAAI,cAAc,EAAE,CAAC;YACpB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAClB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qDAAqD,CAAC,CAAC;QACzE,CAAC;QAED,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,MAAkB;QACtB,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAE3C,uCAAuC;QACvC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5B,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3C,CAAC;QAED,aAAa,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,OAA2C;QACjD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,MAAM;QACL,OAAO,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpC,CAAC;CACD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type ILogger, type LogContext, type LogLevel } from "sylas-core";
|
|
2
|
+
export { LogLevel } from "sylas-core";
|
|
3
|
+
/**
|
|
4
|
+
* Logger configuration options
|
|
5
|
+
*/
|
|
6
|
+
export interface LoggerOptions {
|
|
7
|
+
/** Minimum log level to output */
|
|
8
|
+
level?: LogLevel;
|
|
9
|
+
/** Prefix to add to all log messages (used as component name) */
|
|
10
|
+
prefix?: string;
|
|
11
|
+
/** Whether to include timestamps */
|
|
12
|
+
timestamps?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* CLI-specific logger that wraps the core ILogger.
|
|
16
|
+
*
|
|
17
|
+
* Provides CLI-presentation features (emoji formatting, raw output,
|
|
18
|
+
* dividers, child loggers) on top of the standard core logging interface.
|
|
19
|
+
*
|
|
20
|
+
* Implements ILogger so it can be passed to packages that expect the core interface.
|
|
21
|
+
*/
|
|
22
|
+
export declare class Logger implements ILogger {
|
|
23
|
+
private coreLogger;
|
|
24
|
+
private prefix;
|
|
25
|
+
private timestamps;
|
|
26
|
+
constructor(options?: LoggerOptions);
|
|
27
|
+
/**
|
|
28
|
+
* Debug log (lowest priority)
|
|
29
|
+
*/
|
|
30
|
+
debug(message: string, ...args: any[]): void;
|
|
31
|
+
/**
|
|
32
|
+
* Info log (normal priority)
|
|
33
|
+
*/
|
|
34
|
+
info(message: string, ...args: any[]): void;
|
|
35
|
+
/**
|
|
36
|
+
* Success log - maps to info level with check mark prefix
|
|
37
|
+
*/
|
|
38
|
+
success(message: string, ...args: any[]): void;
|
|
39
|
+
/**
|
|
40
|
+
* Warning log
|
|
41
|
+
*/
|
|
42
|
+
warn(message: string, ...args: any[]): void;
|
|
43
|
+
/**
|
|
44
|
+
* Error log (highest priority)
|
|
45
|
+
*/
|
|
46
|
+
error(message: string, ...args: any[]): void;
|
|
47
|
+
/**
|
|
48
|
+
* Raw output without formatting (always outputs regardless of level)
|
|
49
|
+
*/
|
|
50
|
+
raw(message: string, ...args: any[]): void;
|
|
51
|
+
/**
|
|
52
|
+
* Create a child logger with a prefix
|
|
53
|
+
*/
|
|
54
|
+
child(prefix: string): Logger;
|
|
55
|
+
/**
|
|
56
|
+
* Print a divider line
|
|
57
|
+
*/
|
|
58
|
+
divider(length?: number): void;
|
|
59
|
+
/**
|
|
60
|
+
* Create a new logger with additional context.
|
|
61
|
+
* Delegates to the core logger's withContext.
|
|
62
|
+
*/
|
|
63
|
+
withContext(context: LogContext): ILogger;
|
|
64
|
+
/**
|
|
65
|
+
* Set log level dynamically
|
|
66
|
+
*/
|
|
67
|
+
setLevel(level: LogLevel): void;
|
|
68
|
+
/**
|
|
69
|
+
* Get current log level
|
|
70
|
+
*/
|
|
71
|
+
getLevel(): LogLevel;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Default logger instance
|
|
75
|
+
*/
|
|
76
|
+
export declare const logger: Logger;
|
|
77
|
+
//# sourceMappingURL=Logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../../src/services/Logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC7B,kCAAkC;IAClC,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,qBAAa,MAAO,YAAW,OAAO;IACrC,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,UAAU,CAAU;gBAEhB,OAAO,GAAE,aAAkB;IASvC;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI5C;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI3C;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI9C;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI3C;;OAEG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI5C;;OAEG;IACH,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAI1C;;OAEG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAQ7B;;OAEG;IACH,OAAO,CAAC,MAAM,SAAK,GAAG,IAAI;IAI1B;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO;IAIzC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAI/B;;OAEG;IACH,QAAQ,IAAI,QAAQ;CAGpB;AAED;;GAEG;AACH,eAAO,MAAM,MAAM,QAAe,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { createLogger, } from "sylas-core";
|
|
2
|
+
// Re-export LogLevel from sylas-core so existing consumers don't break
|
|
3
|
+
export { LogLevel } from "sylas-core";
|
|
4
|
+
/**
|
|
5
|
+
* CLI-specific logger that wraps the core ILogger.
|
|
6
|
+
*
|
|
7
|
+
* Provides CLI-presentation features (emoji formatting, raw output,
|
|
8
|
+
* dividers, child loggers) on top of the standard core logging interface.
|
|
9
|
+
*
|
|
10
|
+
* Implements ILogger so it can be passed to packages that expect the core interface.
|
|
11
|
+
*/
|
|
12
|
+
export class Logger {
|
|
13
|
+
coreLogger;
|
|
14
|
+
prefix;
|
|
15
|
+
timestamps;
|
|
16
|
+
constructor(options = {}) {
|
|
17
|
+
this.prefix = options.prefix ?? "";
|
|
18
|
+
this.timestamps = options.timestamps ?? false;
|
|
19
|
+
this.coreLogger = createLogger({
|
|
20
|
+
component: this.prefix || "CLI",
|
|
21
|
+
level: options.level,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Debug log (lowest priority)
|
|
26
|
+
*/
|
|
27
|
+
debug(message, ...args) {
|
|
28
|
+
this.coreLogger.debug(message, ...args);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Info log (normal priority)
|
|
32
|
+
*/
|
|
33
|
+
info(message, ...args) {
|
|
34
|
+
this.coreLogger.info(message, ...args);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Success log - maps to info level with check mark prefix
|
|
38
|
+
*/
|
|
39
|
+
success(message, ...args) {
|
|
40
|
+
this.coreLogger.info(message, ...args);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Warning log
|
|
44
|
+
*/
|
|
45
|
+
warn(message, ...args) {
|
|
46
|
+
this.coreLogger.warn(message, ...args);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Error log (highest priority)
|
|
50
|
+
*/
|
|
51
|
+
error(message, ...args) {
|
|
52
|
+
this.coreLogger.error(message, ...args);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Raw output without formatting (always outputs regardless of level)
|
|
56
|
+
*/
|
|
57
|
+
raw(message, ...args) {
|
|
58
|
+
console.log(message, ...args);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Create a child logger with a prefix
|
|
62
|
+
*/
|
|
63
|
+
child(prefix) {
|
|
64
|
+
return new Logger({
|
|
65
|
+
level: this.coreLogger.getLevel(),
|
|
66
|
+
prefix: this.prefix ? `${this.prefix}:${prefix}` : prefix,
|
|
67
|
+
timestamps: this.timestamps,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Print a divider line
|
|
72
|
+
*/
|
|
73
|
+
divider(length = 70) {
|
|
74
|
+
this.raw("\u2500".repeat(length));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create a new logger with additional context.
|
|
78
|
+
* Delegates to the core logger's withContext.
|
|
79
|
+
*/
|
|
80
|
+
withContext(context) {
|
|
81
|
+
return this.coreLogger.withContext(context);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Set log level dynamically
|
|
85
|
+
*/
|
|
86
|
+
setLevel(level) {
|
|
87
|
+
this.coreLogger.setLevel(level);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get current log level
|
|
91
|
+
*/
|
|
92
|
+
getLevel() {
|
|
93
|
+
return this.coreLogger.getLevel();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Default logger instance
|
|
98
|
+
*/
|
|
99
|
+
export const logger = new Logger();
|
|
100
|
+
//# sourceMappingURL=Logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../../src/services/Logger.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,GAIZ,MAAM,YAAY,CAAC;AAEpB,uEAAuE;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AActC;;;;;;;GAOG;AACH,MAAM,OAAO,MAAM;IACV,UAAU,CAAU;IACpB,MAAM,CAAS;IACf,UAAU,CAAU;IAE5B,YAAY,UAAyB,EAAE;QACtC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC;QACnC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC;QAC9C,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC;YAC9B,SAAS,EAAE,IAAI,CAAC,MAAM,IAAI,KAAK;YAC/B,KAAK,EAAE,OAAO,CAAC,KAAK;SACpB,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAe,EAAE,GAAG,IAAW;QACpC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC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,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,KAAe;QACvB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,QAAQ;QACP,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;CACD;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { RepositoryConfig } from "sylas-core";
|
|
2
|
+
import type { GitService } from "sylas-edge-worker";
|
|
3
|
+
import { EdgeWorker } from "sylas-edge-worker";
|
|
4
|
+
import type { ConfigService } from "./ConfigService.js";
|
|
5
|
+
import type { Logger } from "./Logger.js";
|
|
6
|
+
/**
|
|
7
|
+
* Service responsible for EdgeWorker and Cloudflare tunnel management
|
|
8
|
+
*/
|
|
9
|
+
export declare class WorkerService {
|
|
10
|
+
private configService;
|
|
11
|
+
private gitService;
|
|
12
|
+
private sylasHome;
|
|
13
|
+
private logger;
|
|
14
|
+
private version?;
|
|
15
|
+
private edgeWorker;
|
|
16
|
+
private setupWaitingServer;
|
|
17
|
+
private isShuttingDown;
|
|
18
|
+
constructor(configService: ConfigService, gitService: GitService, sylasHome: string, logger: Logger, version?: string | undefined);
|
|
19
|
+
/**
|
|
20
|
+
* Get the EdgeWorker instance
|
|
21
|
+
*/
|
|
22
|
+
getEdgeWorker(): EdgeWorker | null;
|
|
23
|
+
/**
|
|
24
|
+
* Get the server port from EdgeWorker
|
|
25
|
+
*/
|
|
26
|
+
getServerPort(): number;
|
|
27
|
+
/**
|
|
28
|
+
* Start setup waiting mode - server infrastructure only, no EdgeWorker
|
|
29
|
+
* Used after initial authentication while waiting for server configuration
|
|
30
|
+
*/
|
|
31
|
+
startSetupWaitingMode(): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Start idle mode - server infrastructure only, no EdgeWorker
|
|
34
|
+
* Used after onboarding when no repositories are configured
|
|
35
|
+
*/
|
|
36
|
+
startIdleMode(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Stop the setup waiting mode or idle mode server
|
|
39
|
+
* Must be called before starting EdgeWorker to avoid port conflicts
|
|
40
|
+
*/
|
|
41
|
+
stopWaitingServer(): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Start the EdgeWorker with given configuration
|
|
44
|
+
*/
|
|
45
|
+
startEdgeWorker(params: {
|
|
46
|
+
repositories: RepositoryConfig[];
|
|
47
|
+
ngrokAuthToken?: string;
|
|
48
|
+
onOAuthCallback?: (token: string, workspaceId: string, workspaceName: string) => Promise<void>;
|
|
49
|
+
}): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Set up event handlers for EdgeWorker
|
|
52
|
+
*/
|
|
53
|
+
private setupEventHandlers;
|
|
54
|
+
/**
|
|
55
|
+
* Stop the EdgeWorker
|
|
56
|
+
*/
|
|
57
|
+
stop(): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=WorkerService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkerService.d.ts","sourceRoot":"","sources":["../../../src/services/WorkerService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA2B,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;GAEG;AACH,qBAAa,aAAa;IAMxB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,MAAM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