@getpaseo/server 0.1.88 → 0.1.90
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/server/server/agent/agent-manager.js +4 -1
- package/dist/server/server/agent/agent-prompt.js +4 -1
- package/dist/server/server/agent/agent-sdk-types.d.ts +1 -0
- package/dist/server/server/agent/agent-storage.d.ts +22 -22
- package/dist/server/server/agent/agent-storage.js +2 -9
- package/dist/server/server/agent/create-agent/create.d.ts +2 -0
- package/dist/server/server/agent/create-agent/create.js +26 -7
- package/dist/server/server/agent/create-agent-lifecycle-dispatch.d.ts +1 -0
- package/dist/server/server/agent/create-agent-lifecycle-dispatch.js +4 -0
- package/dist/server/server/agent/create-agent-mode.d.ts +3 -8
- package/dist/server/server/agent/create-agent-mode.js +16 -2
- package/dist/server/server/agent/import-sessions.js +1 -1
- package/dist/server/server/agent/mcp-server.d.ts +1 -0
- package/dist/server/server/agent/mcp-server.js +113 -70
- package/dist/server/server/agent/provider-snapshot-manager.d.ts +2 -1
- package/dist/server/server/agent/provider-snapshot-manager.js +18 -2
- package/dist/server/server/agent/providers/acp-agent.d.ts +3 -3
- package/dist/server/server/agent/providers/acp-agent.js +18 -13
- package/dist/server/server/agent/providers/codex-app-server-agent.js +16 -22
- package/dist/server/server/agent/providers/mock-load-test-agent.d.ts +2 -0
- package/dist/server/server/agent/providers/mock-load-test-agent.js +69 -2
- package/dist/server/server/agent/providers/opencode-agent.js +19 -8
- package/dist/server/server/agent/providers/pi/agent.js +13 -0
- package/dist/server/server/agent/providers/pi/rpc-types.d.ts +3 -0
- package/dist/server/server/agent/timeline-projection.js +30 -1
- package/dist/server/server/atomic-file.d.ts +3 -0
- package/dist/server/server/atomic-file.js +19 -0
- package/dist/server/server/auto-archive-on-merge/archive-if-safe.d.ts +1 -0
- package/dist/server/server/auto-archive-on-merge/archive-if-safe.js +10 -2
- package/dist/server/server/bootstrap.d.ts +7 -2
- package/dist/server/server/bootstrap.js +154 -115
- package/dist/server/server/chat/chat-service.js +2 -4
- package/dist/server/server/config.js +41 -0
- package/dist/server/server/daemon-keypair.js +2 -2
- package/dist/server/server/loop-service.d.ts +26 -22
- package/dist/server/server/loop-service.js +27 -9
- package/dist/server/server/package-version.d.ts +2 -2
- package/dist/server/server/paseo-worktree-archive-service.d.ts +2 -0
- package/dist/server/server/paseo-worktree-archive-service.js +28 -9
- package/dist/server/server/persisted-config.d.ts +84 -28
- package/dist/server/server/persisted-config.js +20 -3
- package/dist/server/server/pid-lock.d.ts +2 -2
- package/dist/server/server/private-files.d.ts +0 -1
- package/dist/server/server/private-files.js +0 -5
- package/dist/server/server/schedule/service.d.ts +6 -0
- package/dist/server/server/schedule/service.js +41 -18
- package/dist/server/server/schedule/store.js +3 -2
- package/dist/server/server/script-health-monitor.d.ts +4 -4
- package/dist/server/server/script-health-monitor.js +6 -6
- package/dist/server/server/script-proxy.d.ts +2 -39
- package/dist/server/server/script-proxy.js +1 -244
- package/dist/server/server/script-route-branch-handler.d.ts +2 -2
- package/dist/server/server/script-route-branch-handler.js +3 -37
- package/dist/server/server/script-status-projection.d.ts +6 -4
- package/dist/server/server/script-status-projection.js +85 -37
- package/dist/server/server/server-id.js +3 -3
- package/dist/server/server/service-proxy.d.ts +237 -0
- package/dist/server/server/service-proxy.js +714 -0
- package/dist/server/server/session.d.ts +12 -18
- package/dist/server/server/session.js +206 -117
- package/dist/server/server/speech/providers/local/worker-client.js +1 -11
- package/dist/server/server/websocket-server.d.ts +7 -4
- package/dist/server/server/websocket-server.js +9 -4
- package/dist/server/server/workspace-bootstrap-dedupe.d.ts +34 -0
- package/dist/server/server/workspace-bootstrap-dedupe.js +23 -0
- package/dist/server/server/workspace-directory.d.ts +8 -0
- package/dist/server/server/workspace-directory.js +141 -11
- package/dist/server/server/workspace-git-service.d.ts +3 -0
- package/dist/server/server/workspace-git-service.js +53 -12
- package/dist/server/server/workspace-registry.d.ts +2 -2
- package/dist/server/server/workspace-registry.js +2 -6
- package/dist/server/server/workspace-service-env.d.ts +1 -0
- package/dist/server/server/workspace-service-env.js +23 -18
- package/dist/server/server/worktree/commands.d.ts +2 -0
- package/dist/server/server/worktree/commands.js +4 -1
- package/dist/server/server/worktree-bootstrap.d.ts +4 -3
- package/dist/server/server/worktree-bootstrap.js +14 -13
- package/dist/server/server/worktree-core.d.ts +1 -0
- package/dist/server/server/worktree-core.js +2 -0
- package/dist/server/server/worktree-session.d.ts +6 -2
- package/dist/server/server/worktree-session.js +3 -0
- package/dist/server/services/github-service.d.ts +1 -0
- package/dist/server/services/github-service.js +7 -1
- package/dist/server/utils/checkout-git.d.ts +6 -3
- package/dist/server/utils/checkout-git.js +40 -38
- package/dist/server/utils/worktree.d.ts +17 -12
- package/dist/server/utils/worktree.js +39 -22
- package/dist/src/server/persisted-config.js +20 -3
- package/dist/src/server/private-files.js +0 -5
- package/package.json +9 -7
- package/dist/server/server/editor-targets.d.ts +0 -18
- package/dist/server/server/editor-targets.js +0 -109
- package/dist/server/utils/script-hostname.d.ts +0 -8
- package/dist/server/utils/script-hostname.js +0 -14
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { buildScriptHostname } from "../utils/script-hostname.js";
|
|
2
1
|
import { getScriptConfigs, isServiceScript, readPaseoConfig } from "../utils/worktree.js";
|
|
3
2
|
import { deriveProjectSlug } from "./workspace-git-metadata.js";
|
|
4
3
|
export function readPaseoConfigForProjection(workspaceDirectory, logger) {
|
|
@@ -15,12 +14,6 @@ function resolveDaemonPort(daemonPort) {
|
|
|
15
14
|
}
|
|
16
15
|
return daemonPort;
|
|
17
16
|
}
|
|
18
|
-
function toServiceProxyUrl(hostname, daemonPort) {
|
|
19
|
-
if (daemonPort === null) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
return `http://${hostname}:${daemonPort}`;
|
|
23
|
-
}
|
|
24
17
|
function toWireHealth(health) {
|
|
25
18
|
if (health === "pending" || health === null) {
|
|
26
19
|
return null;
|
|
@@ -33,48 +26,99 @@ function sortPayloads(payloads) {
|
|
|
33
26
|
sensitivity: "base",
|
|
34
27
|
}));
|
|
35
28
|
}
|
|
36
|
-
function
|
|
29
|
+
function projectWorkspaceServiceState(params) {
|
|
30
|
+
return params.ctx.serviceProxy.projectWorkspaceServiceState({
|
|
31
|
+
workspaceId: params.workspaceId,
|
|
32
|
+
projectSlug: params.ctx.projectSlug,
|
|
33
|
+
branchName: params.ctx.branchName,
|
|
34
|
+
scriptName: params.scriptName,
|
|
35
|
+
daemonPort: params.ctx.daemonPort,
|
|
36
|
+
publicBaseUrl: params.ctx.serviceProxyPublicBaseUrl,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function buildConfiguredPlainScriptPayload(scriptName, runtimeEntry) {
|
|
40
|
+
return {
|
|
41
|
+
scriptName,
|
|
42
|
+
type: "script",
|
|
43
|
+
hostname: scriptName,
|
|
44
|
+
port: null,
|
|
45
|
+
proxyUrl: null,
|
|
46
|
+
lifecycle: runtimeEntry?.lifecycle ?? "stopped",
|
|
47
|
+
health: null,
|
|
48
|
+
exitCode: runtimeEntry?.exitCode ?? null,
|
|
49
|
+
terminalId: runtimeEntry?.terminalId ?? null,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function buildConfiguredScriptPayload(scriptName, config, runtimeEntry, serviceState, ctx) {
|
|
37
53
|
const configIsService = isServiceScript(config);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
if (!configIsService) {
|
|
55
|
+
return buildConfiguredPlainScriptPayload(scriptName, runtimeEntry);
|
|
56
|
+
}
|
|
57
|
+
const type = "service";
|
|
58
|
+
const configuredPort = config.port ?? null;
|
|
59
|
+
const hostname = (serviceState ??
|
|
60
|
+
ctx.serviceProxy.projectWorkspaceService({
|
|
61
|
+
projectSlug: ctx.projectSlug,
|
|
62
|
+
branchName: ctx.branchName,
|
|
63
|
+
scriptName,
|
|
64
|
+
daemonPort: ctx.daemonPort,
|
|
65
|
+
publicBaseUrl: ctx.serviceProxyPublicBaseUrl,
|
|
66
|
+
})).hostname;
|
|
67
|
+
const urls = serviceState ??
|
|
68
|
+
ctx.serviceProxy.projectUrls({
|
|
69
|
+
projectSlug: ctx.projectSlug,
|
|
70
|
+
branchName: ctx.branchName,
|
|
71
|
+
scriptName,
|
|
72
|
+
daemonPort: ctx.daemonPort,
|
|
73
|
+
publicBaseUrl: ctx.serviceProxyPublicBaseUrl,
|
|
74
|
+
});
|
|
48
75
|
return {
|
|
49
76
|
scriptName,
|
|
50
77
|
type,
|
|
51
78
|
hostname,
|
|
52
|
-
port:
|
|
53
|
-
|
|
79
|
+
port: serviceState?.port ?? configuredPort,
|
|
80
|
+
localProxyUrl: urls.localProxyUrl,
|
|
81
|
+
publicProxyUrl: urls.publicProxyUrl,
|
|
82
|
+
proxyUrl: urls.proxyUrl,
|
|
54
83
|
lifecycle: runtimeEntry?.lifecycle ?? "stopped",
|
|
55
|
-
health:
|
|
84
|
+
health: toWireHealth(ctx.resolveHealth?.(hostname) ?? null),
|
|
56
85
|
exitCode: runtimeEntry?.exitCode ?? null,
|
|
57
86
|
terminalId: runtimeEntry?.terminalId ?? null,
|
|
58
87
|
};
|
|
59
88
|
}
|
|
60
|
-
function buildOrphanRuntimePayload(runtimeEntry,
|
|
89
|
+
function buildOrphanRuntimePayload(runtimeEntry, serviceState, ctx) {
|
|
61
90
|
const type = runtimeEntry.type;
|
|
62
91
|
const hostname = type === "service"
|
|
63
|
-
? (
|
|
64
|
-
|
|
92
|
+
? (serviceState ??
|
|
93
|
+
ctx.serviceProxy.projectWorkspaceService({
|
|
65
94
|
projectSlug: ctx.projectSlug,
|
|
66
95
|
branchName: ctx.branchName,
|
|
67
96
|
scriptName: runtimeEntry.scriptName,
|
|
68
|
-
|
|
97
|
+
daemonPort: ctx.daemonPort,
|
|
98
|
+
publicBaseUrl: ctx.serviceProxyPublicBaseUrl,
|
|
99
|
+
})).hostname
|
|
69
100
|
: runtimeEntry.scriptName;
|
|
101
|
+
const urls = serviceState ??
|
|
102
|
+
ctx.serviceProxy.projectUrls({
|
|
103
|
+
projectSlug: ctx.projectSlug,
|
|
104
|
+
branchName: ctx.branchName,
|
|
105
|
+
scriptName: runtimeEntry.scriptName,
|
|
106
|
+
daemonPort: ctx.daemonPort,
|
|
107
|
+
publicBaseUrl: ctx.serviceProxyPublicBaseUrl,
|
|
108
|
+
});
|
|
70
109
|
return {
|
|
71
110
|
scriptName: runtimeEntry.scriptName,
|
|
72
111
|
type,
|
|
73
112
|
hostname,
|
|
74
|
-
port: type === "service" ? (
|
|
75
|
-
|
|
113
|
+
port: type === "service" ? (serviceState?.port ?? null) : null,
|
|
114
|
+
...(type === "service"
|
|
115
|
+
? { localProxyUrl: urls.localProxyUrl, publicProxyUrl: urls.publicProxyUrl }
|
|
116
|
+
: {}),
|
|
117
|
+
proxyUrl: type === "service" ? urls.proxyUrl : null,
|
|
76
118
|
lifecycle: runtimeEntry.lifecycle,
|
|
77
|
-
health: type === "service" &&
|
|
119
|
+
health: type === "service" && serviceState?.port !== null
|
|
120
|
+
? toWireHealth(ctx.resolveHealth?.(hostname) ?? null)
|
|
121
|
+
: null,
|
|
78
122
|
exitCode: runtimeEntry.exitCode,
|
|
79
123
|
terminalId: runtimeEntry.terminalId,
|
|
80
124
|
};
|
|
@@ -88,27 +132,30 @@ export function buildWorkspaceScriptPayloads(options) {
|
|
|
88
132
|
const runtimeEntries = new Map(options.runtimeStore
|
|
89
133
|
.listForWorkspace(workspaceId)
|
|
90
134
|
.map((entry) => [entry.scriptName, entry]));
|
|
91
|
-
const routesByScriptName = new Map(options.routeStore
|
|
92
|
-
.listRoutesForWorkspace(workspaceId)
|
|
93
|
-
.map((entry) => [entry.scriptName, entry]));
|
|
94
135
|
const ctx = {
|
|
95
136
|
projectSlug,
|
|
96
137
|
branchName,
|
|
97
138
|
daemonPort: options.daemonPort,
|
|
139
|
+
serviceProxyPublicBaseUrl: options.serviceProxyPublicBaseUrl,
|
|
140
|
+
serviceProxy: options.serviceProxy,
|
|
98
141
|
resolveHealth: options.resolveHealth,
|
|
99
142
|
};
|
|
100
143
|
const payloads = [];
|
|
101
144
|
for (const [scriptName, config] of scriptConfigs.entries()) {
|
|
102
145
|
const runtimeEntry = runtimeEntries.get(scriptName) ?? null;
|
|
103
|
-
const
|
|
104
|
-
|
|
146
|
+
const serviceState = isServiceScript(config)
|
|
147
|
+
? projectWorkspaceServiceState({ workspaceId, scriptName, ctx })
|
|
148
|
+
: null;
|
|
149
|
+
payloads.push(buildConfiguredScriptPayload(scriptName, config, runtimeEntry, serviceState, ctx));
|
|
105
150
|
}
|
|
106
151
|
for (const runtimeEntry of runtimeEntries.values()) {
|
|
107
152
|
if (scriptConfigs.has(runtimeEntry.scriptName) || runtimeEntry.lifecycle !== "running") {
|
|
108
153
|
continue;
|
|
109
154
|
}
|
|
110
|
-
const
|
|
111
|
-
|
|
155
|
+
const serviceState = runtimeEntry.type === "service"
|
|
156
|
+
? projectWorkspaceServiceState({ workspaceId, scriptName: runtimeEntry.scriptName, ctx })
|
|
157
|
+
: null;
|
|
158
|
+
payloads.push(buildOrphanRuntimePayload(runtimeEntry, serviceState, ctx));
|
|
112
159
|
}
|
|
113
160
|
return sortPayloads(payloads);
|
|
114
161
|
}
|
|
@@ -121,7 +168,7 @@ function buildScriptStatusUpdateMessage(params) {
|
|
|
121
168
|
},
|
|
122
169
|
};
|
|
123
170
|
}
|
|
124
|
-
export function createScriptStatusEmitter({ sessions,
|
|
171
|
+
export function createScriptStatusEmitter({ sessions, serviceProxy, runtimeStore, daemonPort, serviceProxyPublicBaseUrl, resolveWorkspaceDirectory, logger, }) {
|
|
125
172
|
return (workspaceId, scripts) => {
|
|
126
173
|
void (async () => {
|
|
127
174
|
const workspaceDirectory = await resolveWorkspaceDirectory(workspaceId);
|
|
@@ -134,9 +181,10 @@ export function createScriptStatusEmitter({ sessions, routeStore, runtimeStore,
|
|
|
134
181
|
workspaceId,
|
|
135
182
|
workspaceDirectory,
|
|
136
183
|
paseoConfig: readPaseoConfigForProjection(workspaceDirectory, logger),
|
|
137
|
-
|
|
184
|
+
serviceProxy,
|
|
138
185
|
runtimeStore,
|
|
139
186
|
daemonPort: resolvedDaemonPort,
|
|
187
|
+
serviceProxyPublicBaseUrl,
|
|
140
188
|
resolveHealth: (hostname) => scriptHealthByHostname.get(hostname) ?? null,
|
|
141
189
|
});
|
|
142
190
|
const message = buildScriptStatusUpdateMessage({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import { randomBytes } from "node:crypto";
|
|
4
|
-
import { ensurePrivateFile,
|
|
4
|
+
import { ensurePrivateFile, writePrivateFileAtomicSync } from "./private-files.js";
|
|
5
5
|
const SERVER_ID_FILENAME = "server-id";
|
|
6
6
|
function getLogger(logger) {
|
|
7
7
|
return logger?.child({ module: "server-id" });
|
|
@@ -31,7 +31,7 @@ export function getOrCreateServerId(paseoHome, options) {
|
|
|
31
31
|
// Persist the override for consistent identity across restarts.
|
|
32
32
|
if (!existsSync(serverIdPath)) {
|
|
33
33
|
try {
|
|
34
|
-
|
|
34
|
+
writePrivateFileAtomicSync(serverIdPath, `${envOverride}\n`);
|
|
35
35
|
log?.info({ serverId: envOverride }, "Persisted PASEO_SERVER_ID override");
|
|
36
36
|
}
|
|
37
37
|
catch (error) {
|
|
@@ -58,7 +58,7 @@ export function getOrCreateServerId(paseoHome, options) {
|
|
|
58
58
|
}
|
|
59
59
|
const created = generateServerId();
|
|
60
60
|
try {
|
|
61
|
-
|
|
61
|
+
writePrivateFileAtomicSync(serverIdPath, `${created}\n`);
|
|
62
62
|
}
|
|
63
63
|
catch (error) {
|
|
64
64
|
log?.warn({ error }, "Failed to persist serverId (continuing with in-memory id)");
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import net from "node:net";
|
|
2
|
+
import type { IncomingMessage } from "node:http";
|
|
3
|
+
import { type RequestHandler } from "express";
|
|
4
|
+
import type { Logger } from "pino";
|
|
5
|
+
export type ServiceProxyListenTarget = {
|
|
6
|
+
type: "tcp";
|
|
7
|
+
host: string;
|
|
8
|
+
port: number;
|
|
9
|
+
} | {
|
|
10
|
+
type: "socket";
|
|
11
|
+
path: string;
|
|
12
|
+
} | {
|
|
13
|
+
type: "pipe";
|
|
14
|
+
path: string;
|
|
15
|
+
};
|
|
16
|
+
export interface ServiceProxyRoute {
|
|
17
|
+
hostname: string;
|
|
18
|
+
port: number;
|
|
19
|
+
}
|
|
20
|
+
export interface ServiceProxyRouteEntry extends ServiceProxyRoute {
|
|
21
|
+
workspaceId: string;
|
|
22
|
+
projectSlug: string;
|
|
23
|
+
scriptName: string;
|
|
24
|
+
localHostname?: string;
|
|
25
|
+
publicHostname?: string | null;
|
|
26
|
+
publicBaseUrl?: string | null;
|
|
27
|
+
}
|
|
28
|
+
export interface ServiceProxyUrlProjection {
|
|
29
|
+
localProxyUrl: string | null;
|
|
30
|
+
publicProxyUrl: string | null;
|
|
31
|
+
proxyUrl: string | null;
|
|
32
|
+
}
|
|
33
|
+
export interface ServiceProxyScriptProjection extends ServiceProxyUrlProjection {
|
|
34
|
+
hostname: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ServiceProxyWorkspaceScriptProjection extends ServiceProxyScriptProjection {
|
|
37
|
+
port: number | null;
|
|
38
|
+
}
|
|
39
|
+
export interface ServiceProxyHealthTarget {
|
|
40
|
+
workspaceId: string;
|
|
41
|
+
scriptName: string;
|
|
42
|
+
hostname: string;
|
|
43
|
+
port: number;
|
|
44
|
+
}
|
|
45
|
+
export interface WorkspaceServiceIdentity {
|
|
46
|
+
workspaceId: string;
|
|
47
|
+
projectSlug: string;
|
|
48
|
+
branchName: string | null;
|
|
49
|
+
scriptName: string;
|
|
50
|
+
}
|
|
51
|
+
export interface RegisterWorkspaceServiceInput extends WorkspaceServiceIdentity {
|
|
52
|
+
port: number;
|
|
53
|
+
publicBaseUrl?: string | null;
|
|
54
|
+
}
|
|
55
|
+
interface HostClassificationRegistered {
|
|
56
|
+
type: "registered-service";
|
|
57
|
+
route: ServiceProxyRoute;
|
|
58
|
+
}
|
|
59
|
+
interface HostClassificationKnownMiss {
|
|
60
|
+
type: "known-service-miss";
|
|
61
|
+
}
|
|
62
|
+
interface HostClassificationDaemon {
|
|
63
|
+
type: "daemon";
|
|
64
|
+
}
|
|
65
|
+
type HostClassification = HostClassificationRegistered | HostClassificationKnownMiss | HostClassificationDaemon;
|
|
66
|
+
export declare function buildServiceProxyLabel({ projectSlug, branchName, scriptName, }: {
|
|
67
|
+
projectSlug: string;
|
|
68
|
+
branchName: string | null;
|
|
69
|
+
scriptName: string;
|
|
70
|
+
}): string;
|
|
71
|
+
export declare function buildLocalServiceHostname(input: {
|
|
72
|
+
projectSlug: string;
|
|
73
|
+
branchName: string | null;
|
|
74
|
+
scriptName: string;
|
|
75
|
+
}): string;
|
|
76
|
+
export declare function buildPublicServiceHostname({ publicBaseUrl, ...service }: {
|
|
77
|
+
publicBaseUrl: string;
|
|
78
|
+
projectSlug: string;
|
|
79
|
+
branchName: string | null;
|
|
80
|
+
scriptName: string;
|
|
81
|
+
}): string;
|
|
82
|
+
export declare function buildPublicServiceProxyUrl(options: {
|
|
83
|
+
publicBaseUrl: string;
|
|
84
|
+
projectSlug: string;
|
|
85
|
+
branchName: string | null;
|
|
86
|
+
scriptName: string;
|
|
87
|
+
}): string;
|
|
88
|
+
export declare function projectServiceProxyUrls(options: {
|
|
89
|
+
projectSlug: string;
|
|
90
|
+
branchName: string | null;
|
|
91
|
+
scriptName: string;
|
|
92
|
+
daemonPort: number | null | undefined;
|
|
93
|
+
publicBaseUrl?: string | null;
|
|
94
|
+
}): ServiceProxyUrlProjection;
|
|
95
|
+
export declare function projectWorkspaceService(input: {
|
|
96
|
+
projectSlug: string;
|
|
97
|
+
branchName: string | null;
|
|
98
|
+
scriptName: string;
|
|
99
|
+
daemonPort: number | null | undefined;
|
|
100
|
+
publicBaseUrl?: string | null;
|
|
101
|
+
}): ServiceProxyScriptProjection;
|
|
102
|
+
export declare function projectRegisteredServiceProxyUrls(options: {
|
|
103
|
+
route: Pick<ServiceProxyRouteEntry, "hostname" | "publicHostname" | "publicBaseUrl" | "projectSlug" | "scriptName">;
|
|
104
|
+
daemonPort: number | null | undefined;
|
|
105
|
+
}): ServiceProxyUrlProjection;
|
|
106
|
+
export declare class ServiceProxyRouteCollisionError extends Error {
|
|
107
|
+
readonly hostname: string;
|
|
108
|
+
readonly existing: Pick<ServiceProxyRouteEntry, "workspaceId" | "scriptName">;
|
|
109
|
+
readonly incoming: Pick<ServiceProxyRouteEntry, "workspaceId" | "scriptName">;
|
|
110
|
+
constructor(hostname: string, existing: Pick<ServiceProxyRouteEntry, "workspaceId" | "scriptName">, incoming: Pick<ServiceProxyRouteEntry, "workspaceId" | "scriptName">);
|
|
111
|
+
}
|
|
112
|
+
export declare class ServiceProxyRouteRegistry {
|
|
113
|
+
private routes;
|
|
114
|
+
private hostnameAliases;
|
|
115
|
+
private workspaceHostnames;
|
|
116
|
+
private configuredPublicBaseHostnames;
|
|
117
|
+
private publicBaseHostnames;
|
|
118
|
+
constructor(publicBaseUrl?: string | null);
|
|
119
|
+
registerWorkspaceService(input: RegisterWorkspaceServiceInput): ServiceProxyRouteEntry;
|
|
120
|
+
registerRoute(entry: ServiceProxyRouteEntry): void;
|
|
121
|
+
replaceWorkspaceBranchRoutes(params: {
|
|
122
|
+
workspaceId: string;
|
|
123
|
+
newBranch: string | null;
|
|
124
|
+
}): boolean;
|
|
125
|
+
removeRoute(hostname: string): void;
|
|
126
|
+
removeRouteForWorkspaceScript(params: {
|
|
127
|
+
workspaceId: string;
|
|
128
|
+
scriptName: string;
|
|
129
|
+
}): void;
|
|
130
|
+
removeWorkspaceService(params: {
|
|
131
|
+
workspaceId: string;
|
|
132
|
+
scriptName: string;
|
|
133
|
+
}): void;
|
|
134
|
+
projectUrls(input: {
|
|
135
|
+
projectSlug: string;
|
|
136
|
+
branchName: string | null;
|
|
137
|
+
scriptName: string;
|
|
138
|
+
daemonPort: number | null | undefined;
|
|
139
|
+
publicBaseUrl?: string | null;
|
|
140
|
+
}): ServiceProxyUrlProjection;
|
|
141
|
+
projectWorkspaceService(input: {
|
|
142
|
+
projectSlug: string;
|
|
143
|
+
branchName: string | null;
|
|
144
|
+
scriptName: string;
|
|
145
|
+
daemonPort: number | null | undefined;
|
|
146
|
+
publicBaseUrl?: string | null;
|
|
147
|
+
}): ServiceProxyScriptProjection;
|
|
148
|
+
projectWorkspaceServiceState(input: {
|
|
149
|
+
workspaceId: string;
|
|
150
|
+
projectSlug: string;
|
|
151
|
+
branchName: string | null;
|
|
152
|
+
scriptName: string;
|
|
153
|
+
daemonPort: number | null | undefined;
|
|
154
|
+
publicBaseUrl?: string | null;
|
|
155
|
+
}): ServiceProxyWorkspaceScriptProjection;
|
|
156
|
+
getHealthCheckTargets(): ServiceProxyHealthTarget[];
|
|
157
|
+
getWorkspaceHealthTargets(workspaceId: string): ServiceProxyHealthTarget[];
|
|
158
|
+
getHealthTargetForHostname(hostname: string): ServiceProxyHealthTarget | null;
|
|
159
|
+
removeServiceRoutesByHostnames(hostnames: string[]): void;
|
|
160
|
+
removeRoutesForPort(port: number): void;
|
|
161
|
+
classifyHost(host: string | undefined): HostClassification;
|
|
162
|
+
findRoute(host: string): ServiceProxyRoute | null;
|
|
163
|
+
getRouteEntry(hostname: string): ServiceProxyRouteEntry | null;
|
|
164
|
+
listRoutes(): ServiceProxyRouteEntry[];
|
|
165
|
+
listRoutesForWorkspace(workspaceId: string): ServiceProxyRouteEntry[];
|
|
166
|
+
private assertCanRegister;
|
|
167
|
+
private assertNoInternalCollisions;
|
|
168
|
+
private toStoredEntry;
|
|
169
|
+
private getRouteByHostname;
|
|
170
|
+
private getRouteHostnames;
|
|
171
|
+
private addHostnameToWorkspaceIndex;
|
|
172
|
+
private removeHostnameFromWorkspaceIndex;
|
|
173
|
+
private rebuildPublicBaseHostnames;
|
|
174
|
+
}
|
|
175
|
+
export { ServiceProxyRouteRegistry as ScriptRouteStore };
|
|
176
|
+
export type ScriptRoute = ServiceProxyRoute;
|
|
177
|
+
export type ScriptRouteEntry = ServiceProxyRouteEntry;
|
|
178
|
+
export declare function createScriptProxyMiddleware({ routeStore, logger, }: {
|
|
179
|
+
routeStore: ServiceProxyRouteRegistry;
|
|
180
|
+
logger: Logger;
|
|
181
|
+
}): RequestHandler;
|
|
182
|
+
export declare function createScriptProxyUpgradeHandler({ routeStore, logger, passthroughUnknown, }: {
|
|
183
|
+
routeStore: ServiceProxyRouteRegistry;
|
|
184
|
+
logger: Logger;
|
|
185
|
+
passthroughUnknown?: boolean;
|
|
186
|
+
}): (req: IncomingMessage, socket: net.Socket, head: Buffer) => void;
|
|
187
|
+
export interface ServiceProxySubsystem {
|
|
188
|
+
registerWorkspaceService(input: RegisterWorkspaceServiceInput): ServiceProxyRouteEntry;
|
|
189
|
+
removeWorkspaceService(params: {
|
|
190
|
+
workspaceId: string;
|
|
191
|
+
scriptName: string;
|
|
192
|
+
}): void;
|
|
193
|
+
removeServiceRoutesByHostnames(hostnames: string[]): void;
|
|
194
|
+
replaceWorkspaceBranchRoutes(params: {
|
|
195
|
+
workspaceId: string;
|
|
196
|
+
newBranch: string | null;
|
|
197
|
+
}): boolean;
|
|
198
|
+
getHealthCheckTargets(): ServiceProxyHealthTarget[];
|
|
199
|
+
getWorkspaceHealthTargets(workspaceId: string): ServiceProxyHealthTarget[];
|
|
200
|
+
getHealthTargetForHostname(hostname: string): ServiceProxyHealthTarget | null;
|
|
201
|
+
projectUrls(input: {
|
|
202
|
+
projectSlug: string;
|
|
203
|
+
branchName: string | null;
|
|
204
|
+
scriptName: string;
|
|
205
|
+
daemonPort: number | null | undefined;
|
|
206
|
+
publicBaseUrl?: string | null;
|
|
207
|
+
}): ServiceProxyUrlProjection;
|
|
208
|
+
projectWorkspaceService(input: {
|
|
209
|
+
projectSlug: string;
|
|
210
|
+
branchName: string | null;
|
|
211
|
+
scriptName: string;
|
|
212
|
+
daemonPort: number | null | undefined;
|
|
213
|
+
publicBaseUrl?: string | null;
|
|
214
|
+
}): ServiceProxyScriptProjection;
|
|
215
|
+
projectWorkspaceServiceState(input: {
|
|
216
|
+
workspaceId: string;
|
|
217
|
+
projectSlug: string;
|
|
218
|
+
branchName: string | null;
|
|
219
|
+
scriptName: string;
|
|
220
|
+
daemonPort: number | null | undefined;
|
|
221
|
+
publicBaseUrl?: string | null;
|
|
222
|
+
}): ServiceProxyWorkspaceScriptProjection;
|
|
223
|
+
middleware(): RequestHandler;
|
|
224
|
+
upgradeHandler(options: {
|
|
225
|
+
passthroughUnknown: boolean;
|
|
226
|
+
}): (req: IncomingMessage, socket: net.Socket, head: Buffer) => void;
|
|
227
|
+
startStandalone(options: {
|
|
228
|
+
listenTarget: ServiceProxyListenTarget;
|
|
229
|
+
}): Promise<ServiceProxyListenTarget>;
|
|
230
|
+
stopStandalone(): Promise<void>;
|
|
231
|
+
}
|
|
232
|
+
export declare function createServiceProxySubsystem({ logger, publicBaseUrl, }: {
|
|
233
|
+
logger: Logger;
|
|
234
|
+
publicBaseUrl?: string | null;
|
|
235
|
+
}): ServiceProxySubsystem;
|
|
236
|
+
export declare function findFreePort(): Promise<number>;
|
|
237
|
+
//# sourceMappingURL=service-proxy.d.ts.map
|