@keystrokehq/hosting 0.1.15 → 0.1.17
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/docker.cjs +154 -0
- package/dist/docker.cjs.map +1 -0
- package/dist/docker.d.cts +23 -0
- package/dist/docker.d.cts.map +1 -0
- package/dist/docker.d.mts +23 -0
- package/dist/docker.d.mts.map +1 -0
- package/dist/docker.mjs +152 -0
- package/dist/docker.mjs.map +1 -0
- package/dist/index.cjs +135 -8422
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -122
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +68 -122
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +103 -8372
- package/dist/index.mjs.map +1 -1
- package/dist/org-artifacts.cjs +4 -0
- package/dist/org-artifacts.d.cts +2 -0
- package/dist/org-artifacts.d.mts +2 -0
- package/dist/org-artifacts.mjs +2 -0
- package/dist/plugin-4cuXkf42.d.cts +44 -0
- package/dist/plugin-4cuXkf42.d.cts.map +1 -0
- package/dist/plugin-eiAXqE7P.d.mts +44 -0
- package/dist/plugin-eiAXqE7P.d.mts.map +1 -0
- package/dist/runtime-BmfsHLrk.mjs +19 -0
- package/dist/runtime-BmfsHLrk.mjs.map +1 -0
- package/dist/runtime-CV7pSfMl.cjs +30 -0
- package/dist/runtime-CV7pSfMl.cjs.map +1 -0
- package/dist/runtime-Cp906goK.d.cts +88 -0
- package/dist/runtime-Cp906goK.d.cts.map +1 -0
- package/dist/runtime-Cp906goK.d.mts +88 -0
- package/dist/runtime-Cp906goK.d.mts.map +1 -0
- package/dist/wait-for-health-DM55_NQh.cjs +340 -0
- package/dist/wait-for-health-DM55_NQh.cjs.map +1 -0
- package/dist/wait-for-health-XEzPPQIO.mjs +209 -0
- package/dist/wait-for-health-XEzPPQIO.mjs.map +1 -0
- package/package.json +13 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { a as ProjectRuntimeDatabase, c as ProjectRuntimeInput, d as ProjectRuntimeSleepInput, f as ProjectRuntimeWakeInput, i as ProjectRuntime, l as ProjectRuntimeReconcileInput, m as parseOrgArtifactsFromEnv, n as OrgProjectDeploy, o as ProjectRuntimeDestroyInput, p as encodeOrgArtifacts, r as ProjectPingTarget, s as ProjectRuntimeHosting, t as OrgArtifactSpec, u as ProjectRuntimeResult } from "./runtime-Cp906goK.cjs";
|
|
2
|
+
import { a as WorkerRuntimeConfig, i as OrganizationHostingResult, n as HostingPlugin, o as WorkerRuntimeConfigError, r as OrganizationHostingInput, s as resolveWorkerRuntimeConfig, t as HostingOptions } from "./plugin-4cuXkf42.cjs";
|
|
2
3
|
|
|
3
4
|
//#region src/constants.d.ts
|
|
4
5
|
declare const PROJECT_SERVER_IMAGE = "keystroke/project-server:local";
|
|
@@ -15,130 +16,37 @@ declare const PROJECT_SERVER_DEPLOY_STATUS: {
|
|
|
15
16
|
readonly port: 3000;
|
|
16
17
|
};
|
|
17
18
|
//#endregion
|
|
18
|
-
//#region src/runtime.d.ts
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
password: string;
|
|
25
|
-
searchPath: string;
|
|
26
|
-
organizationId: string; /** @deprecated Per-project workers only — org workers omit this. */
|
|
27
|
-
projectId?: string;
|
|
28
|
-
};
|
|
29
|
-
type OrgProjectDeploy = {
|
|
30
|
-
projectId: string;
|
|
31
|
-
name: string;
|
|
32
|
-
artifactId: string;
|
|
33
|
-
artifactStorageKey: string;
|
|
34
|
-
artifactVersion: number;
|
|
19
|
+
//#region src/runtime-control.d.ts
|
|
20
|
+
declare const PROJECT_SERVER_CONTROL: {
|
|
21
|
+
readonly load: "/control/projects/load";
|
|
22
|
+
readonly promote: "/control/projects/promote";
|
|
23
|
+
readonly unload: "/control/projects/unload";
|
|
24
|
+
readonly port: 3000;
|
|
35
25
|
};
|
|
36
|
-
type
|
|
26
|
+
type LoadProjectOnRuntimeInput = {
|
|
37
27
|
projectId: string;
|
|
38
|
-
|
|
39
|
-
artifactId: string; /** Monotonic per-project artifact version from the platform database. */
|
|
28
|
+
artifactId: string;
|
|
40
29
|
artifactVersion: number;
|
|
30
|
+
storageKey: string;
|
|
31
|
+
activate?: boolean;
|
|
41
32
|
};
|
|
42
|
-
type
|
|
43
|
-
appName: string;
|
|
44
|
-
};
|
|
45
|
-
type ProjectRuntimeInput = {
|
|
46
|
-
organizationId: string;
|
|
47
|
-
projects: OrgProjectDeploy[];
|
|
48
|
-
database: ProjectRuntimeDatabase;
|
|
49
|
-
hosting?: ProjectRuntimeHosting; /** Extra env merged into the project server launch spec (e.g. from an llmProxy plugin). */
|
|
50
|
-
env?: Record<string, string>; /** Previous runtime to retire after a successful cutover. */
|
|
51
|
-
previousRuntimeId?: string | null;
|
|
52
|
-
};
|
|
53
|
-
/** Builds base64 `KEYSTROKE_ORG_ARTIFACTS` payload for org worker containers. */
|
|
54
|
-
declare function encodeOrgArtifacts(artifacts: OrgArtifactSpec[]): string;
|
|
55
|
-
declare function parseOrgArtifactsFromEnv(env?: NodeJS.ProcessEnv): OrgArtifactSpec[] | undefined;
|
|
56
|
-
type ProjectRuntimeDestroyInput = {
|
|
57
|
-
runtimeId: string;
|
|
58
|
-
hosting?: ProjectRuntimeHosting;
|
|
59
|
-
};
|
|
60
|
-
type ProjectRuntimeReconcileInput = {
|
|
61
|
-
organizationId: string; /** The runtime to keep — every other runtime belonging to this org should be destroyed. */
|
|
62
|
-
keepRuntimeId: string;
|
|
63
|
-
hosting?: ProjectRuntimeHosting;
|
|
64
|
-
};
|
|
65
|
-
type ProjectRuntimeResult = {
|
|
66
|
-
runtimeId: string;
|
|
67
|
-
baseUrl: string;
|
|
68
|
-
};
|
|
69
|
-
type ProjectRuntime = {
|
|
70
|
-
start(input: ProjectRuntimeInput): Promise<ProjectRuntimeResult>;
|
|
71
|
-
destroy?(input: ProjectRuntimeDestroyInput): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* Sweep away every runtime for this org except `keepRuntimeId`, retrying
|
|
74
|
-
* transient failures instead of giving up after one attempt. This catches
|
|
75
|
-
* orphans that a single {@link destroy} call missed (e.g. a previous deploy's
|
|
76
|
-
* destroy failed silently), not just the one runtime recorded as "previous."
|
|
77
|
-
*/
|
|
78
|
-
reconcile?(input: ProjectRuntimeReconcileInput): Promise<void>;
|
|
79
|
-
};
|
|
80
|
-
type ProjectPingTarget = {
|
|
81
|
-
baseUrl: string | null;
|
|
82
|
-
runtimeId: string | null;
|
|
83
|
-
};
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region src/worker-runtime-config.d.ts
|
|
86
|
-
/** Resolved platform ↔ project-server worker auth contract. */
|
|
87
|
-
type WorkerRuntimeConfig = {
|
|
88
|
-
/** Platform API base URL reachable from the project-server runtime. */platformUrl: string; /** Bearer token for platform `/internal` routes. */
|
|
89
|
-
workerToken: string;
|
|
90
|
-
};
|
|
91
|
-
declare class WorkerRuntimeConfigError extends Error {
|
|
92
|
-
readonly missing: readonly string[];
|
|
93
|
-
constructor(missing: string[]);
|
|
94
|
-
}
|
|
95
|
-
/** Fail fast when the platform cannot start worker-mode project servers. */
|
|
96
|
-
declare function resolveWorkerRuntimeConfig(source?: NodeJS.ProcessEnv): WorkerRuntimeConfig;
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region src/plugin.d.ts
|
|
99
|
-
type HostingOptions = {
|
|
100
|
-
image?: string;
|
|
101
|
-
env?: NodeJS.ProcessEnv;
|
|
33
|
+
type RuntimeControlOptions = {
|
|
102
34
|
fetchImpl?: typeof fetch;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
type OrganizationHostingInput = {
|
|
106
|
-
organizationId: string;
|
|
107
|
-
name: string;
|
|
108
|
-
};
|
|
109
|
-
type OrganizationHostingResult = {
|
|
110
|
-
appName: string;
|
|
111
|
-
};
|
|
112
|
-
type HostingPlugin = {
|
|
113
|
-
name: string; /** Validated at plugin creation — shared by platform internal routes and project-server containers. */
|
|
114
|
-
workerRuntime: WorkerRuntimeConfig;
|
|
115
|
-
createRuntime(): ProjectRuntime;
|
|
116
|
-
provisionOrganization?(input: OrganizationHostingInput): Promise<OrganizationHostingResult>;
|
|
117
|
-
deprovisionOrganization?(result: OrganizationHostingResult): Promise<void>;
|
|
118
|
-
canPingTarget?(target: ProjectPingTarget): target is {
|
|
119
|
-
baseUrl: string;
|
|
120
|
-
runtimeId: string | null;
|
|
121
|
-
};
|
|
122
|
-
pingRequestHeaders?(runtimeId: string | null): Record<string, string>;
|
|
123
|
-
};
|
|
124
|
-
//#endregion
|
|
125
|
-
//#region src/docker/create-docker-runtime.d.ts
|
|
126
|
-
type WorkspacesMount = {
|
|
127
|
-
hostPath: string;
|
|
128
|
-
containerPath: string;
|
|
35
|
+
timeoutMs?: number; /** Bearer token — typically the org's WORKER_INTERNAL_TOKEN. */
|
|
36
|
+
workerToken?: string;
|
|
129
37
|
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
declare function
|
|
38
|
+
declare function loadProjectOnRuntime(baseUrl: string, input: LoadProjectOnRuntimeInput, options?: RuntimeControlOptions): Promise<void>;
|
|
39
|
+
declare function promoteProjectOnRuntime(baseUrl: string, input: {
|
|
40
|
+
projectId: string;
|
|
41
|
+
artifactId: string;
|
|
42
|
+
}, options?: RuntimeControlOptions): Promise<void>;
|
|
43
|
+
declare function unloadProjectOnRuntime(baseUrl: string, input: {
|
|
44
|
+
projectId: string;
|
|
45
|
+
artifactId: string;
|
|
46
|
+
force?: boolean;
|
|
47
|
+
}, options?: RuntimeControlOptions): Promise<void>;
|
|
48
|
+
/** True when the org runtime answers /health. */
|
|
49
|
+
declare function pingRuntimeHealth(baseUrl: string, options?: RuntimeControlOptions): Promise<boolean>;
|
|
142
50
|
//#endregion
|
|
143
51
|
//#region src/runtime-env.d.ts
|
|
144
52
|
/** Env keys that must never be forwarded into untrusted org workers. */
|
|
@@ -217,19 +125,57 @@ type ProjectDeployStatus = {
|
|
|
217
125
|
ok: boolean;
|
|
218
126
|
error?: string;
|
|
219
127
|
};
|
|
128
|
+
type VersionDeployStatus = {
|
|
129
|
+
projectId: string;
|
|
130
|
+
artifactId: string;
|
|
131
|
+
state: "active" | "resident" | "indexed";
|
|
132
|
+
ok: boolean;
|
|
133
|
+
activeJobCount?: number;
|
|
134
|
+
error?: string;
|
|
135
|
+
};
|
|
220
136
|
type DeployStatusResponse = {
|
|
221
137
|
projects: ProjectDeployStatus[];
|
|
138
|
+
versions?: VersionDeployStatus[];
|
|
222
139
|
};
|
|
223
140
|
type FetchDeployStatusOptions = {
|
|
224
141
|
fetchImpl?: typeof fetch;
|
|
225
142
|
timeoutMs?: number;
|
|
226
143
|
};
|
|
144
|
+
type WaitForDeployStatusOptions = {
|
|
145
|
+
fetchImpl?: typeof fetch;
|
|
146
|
+
timeoutMs?: number;
|
|
147
|
+
intervalMs?: number;
|
|
148
|
+
};
|
|
227
149
|
/**
|
|
228
150
|
* Ask a running org machine which projects bootstrapped and which failed.
|
|
229
|
-
*
|
|
230
|
-
*
|
|
151
|
+
* Returns undefined when the endpoint is unreachable, non-OK, times out, or
|
|
152
|
+
* returns an unusable payload — callers must treat that as non-affirmative
|
|
153
|
+
* health for every pending project (never promote on silence).
|
|
231
154
|
*/
|
|
232
155
|
declare function fetchDeployStatus(baseUrl: string, options?: FetchDeployStatusOptions): Promise<DeployStatusResponse | undefined>;
|
|
156
|
+
/**
|
|
157
|
+
* Poll `/deploy-status` until the real worker returns a usable payload or the
|
|
158
|
+
* deadline expires. Retries only transient unavailability (network errors,
|
|
159
|
+
* non-2xx including early-health 404, timeouts, malformed bodies). Any valid
|
|
160
|
+
* `{ projects: [...] }` response — including empty or explicit failures — is
|
|
161
|
+
* terminal so genuine bootstrap errors surface immediately.
|
|
162
|
+
*/
|
|
163
|
+
declare function waitForDeployStatus(baseUrl: string, options?: WaitForDeployStatusOptions): Promise<DeployStatusResponse | undefined>;
|
|
164
|
+
type DeployHealthVerdict = {
|
|
165
|
+
ok: true;
|
|
166
|
+
} | {
|
|
167
|
+
ok: false;
|
|
168
|
+
error: string;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Require an explicit `{ projectId, ok: true }` entry for each candidate.
|
|
172
|
+
* Missing entries, `ok: false`, empty `projects`, or an unavailable status
|
|
173
|
+
* response all fail closed for that project.
|
|
174
|
+
*/
|
|
175
|
+
declare function classifyDeployHealth(input: {
|
|
176
|
+
projectIds: string[];
|
|
177
|
+
deployStatus: DeployStatusResponse | undefined;
|
|
178
|
+
}): Map<string, DeployHealthVerdict>;
|
|
233
179
|
//#endregion
|
|
234
|
-
export { DEV_PLATFORM_WORKER_TOKEN, type
|
|
180
|
+
export { DEV_PLATFORM_WORKER_TOKEN, type DeployHealthVerdict, type DeployStatusResponse, FORBIDDEN_WORKER_ENV_KEYS, type FetchDeployStatusOptions, type HostingOptions, type HostingPlugin, type LoadProjectOnRuntimeInput, type OrgArtifactSpec, type OrgProjectDeploy, type OrganizationHostingInput, type OrganizationHostingResult, PROJECT_SERVER_CONTROL, PROJECT_SERVER_DEPLOY_STATUS, PROJECT_SERVER_FRAMEWORK_NODE_MODULES, PROJECT_SERVER_FRAMEWORK_ROOT, PROJECT_SERVER_HEALTH, PROJECT_SERVER_IMAGE, PROJECT_SERVER_PORT, PROJECT_SERVER_ROOT, type PingProjectOptions, type ProjectDeployStatus, type ProjectPingTarget, type ProjectRuntime, type ProjectRuntimeDatabase, type ProjectRuntimeDestroyInput, type ProjectRuntimeHosting, type ProjectRuntimeInput, type ProjectRuntimeReconcileInput, type ProjectRuntimeResult, type ProjectRuntimeSleepInput, type ProjectRuntimeWakeInput, RUNTIME_PING_TIMEOUT_MS, type RuntimeControlOptions, type RuntimeLaunchSpec, type VerifiedOrgWorkerToken, type VersionDeployStatus, type WaitForDeployStatusOptions, type WaitForHealthOptions, type WorkerRuntimeConfig, WorkerRuntimeConfigError, buildRuntimeEnv, canPingProjectTarget, classifyDeployHealth, encodeOrgArtifacts, fetchDeployStatus, formatDockerEnv, loadProjectOnRuntime, mintOrgWorkerToken, parseOrgArtifactsFromEnv, pingProject, pingProjectTarget, pingRuntimeHealth, promoteProjectOnRuntime, resolvePlatformWorkerToken, resolveProjectServerImage, resolveRuntimeLaunch, resolveWorkerPlatformUrl, resolveWorkerRuntimeConfig, rewriteLoopbackHost, rewriteLoopbackUrl, unloadProjectOnRuntime, verifyOrgWorkerToken, waitForDeployStatus, waitForHealth };
|
|
235
181
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/constants.ts","../src/runtime
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/constants.ts","../src/runtime-control.ts","../src/runtime-env.ts","../src/org-worker-token.ts","../src/wait-for-health.ts","../src/runtime-constants.ts","../src/ping-project.ts","../src/ping-project-target.ts","../src/deploy-status.ts"],"mappings":";;;;cAAa,oBAAA;AAAA,cAEA,mBAAA;AAAA,cAEA,mBAAA;AAAA,cAEA,6BAAA;AAAA,cAEA,qCAAA;AAAA,cAEA,qBAAA;EAAA,SAGH,IAAA;EAAA,SAAA,IAAA;AAAA;AAAA,cAEG,4BAAA;EAAA,SAGH,IAAA;EAAA,SAAA,IAAA;AAAA;;;cCfG,sBAAA;EAAA;;;;;KAOD,yBAAA;EACV,SAAA;EACA,UAAA;EACA,eAAA;EACA,UAAA;EACA,QAAA;AAAA;AAAA,KAGU,qBAAA;EACV,SAAA,UAAmB,KAAK;EACxB,SAAA;EAEA,WAAA;AAAA;AAAA,iBAoCoB,oBAAA,CACpB,OAAA,UACA,KAAA,EAAO,yBAAA,EACP,OAAA,GAAS,qBAAA,GACR,OAAA;AAAA,iBAImB,uB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.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { a as ProjectRuntimeDatabase, c as ProjectRuntimeInput, d as ProjectRuntimeSleepInput, f as ProjectRuntimeWakeInput, i as ProjectRuntime, l as ProjectRuntimeReconcileInput, m as parseOrgArtifactsFromEnv, n as OrgProjectDeploy, o as ProjectRuntimeDestroyInput, p as encodeOrgArtifacts, r as ProjectPingTarget, s as ProjectRuntimeHosting, t as OrgArtifactSpec, u as ProjectRuntimeResult } from "./runtime-Cp906goK.mjs";
|
|
2
|
+
import { a as WorkerRuntimeConfig, i as OrganizationHostingResult, n as HostingPlugin, o as WorkerRuntimeConfigError, r as OrganizationHostingInput, s as resolveWorkerRuntimeConfig, t as HostingOptions } from "./plugin-eiAXqE7P.mjs";
|
|
2
3
|
|
|
3
4
|
//#region src/constants.d.ts
|
|
4
5
|
declare const PROJECT_SERVER_IMAGE = "keystroke/project-server:local";
|
|
@@ -15,130 +16,37 @@ declare const PROJECT_SERVER_DEPLOY_STATUS: {
|
|
|
15
16
|
readonly port: 3000;
|
|
16
17
|
};
|
|
17
18
|
//#endregion
|
|
18
|
-
//#region src/runtime.d.ts
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
password: string;
|
|
25
|
-
searchPath: string;
|
|
26
|
-
organizationId: string; /** @deprecated Per-project workers only — org workers omit this. */
|
|
27
|
-
projectId?: string;
|
|
28
|
-
};
|
|
29
|
-
type OrgProjectDeploy = {
|
|
30
|
-
projectId: string;
|
|
31
|
-
name: string;
|
|
32
|
-
artifactId: string;
|
|
33
|
-
artifactStorageKey: string;
|
|
34
|
-
artifactVersion: number;
|
|
19
|
+
//#region src/runtime-control.d.ts
|
|
20
|
+
declare const PROJECT_SERVER_CONTROL: {
|
|
21
|
+
readonly load: "/control/projects/load";
|
|
22
|
+
readonly promote: "/control/projects/promote";
|
|
23
|
+
readonly unload: "/control/projects/unload";
|
|
24
|
+
readonly port: 3000;
|
|
35
25
|
};
|
|
36
|
-
type
|
|
26
|
+
type LoadProjectOnRuntimeInput = {
|
|
37
27
|
projectId: string;
|
|
38
|
-
|
|
39
|
-
artifactId: string; /** Monotonic per-project artifact version from the platform database. */
|
|
28
|
+
artifactId: string;
|
|
40
29
|
artifactVersion: number;
|
|
30
|
+
storageKey: string;
|
|
31
|
+
activate?: boolean;
|
|
41
32
|
};
|
|
42
|
-
type
|
|
43
|
-
appName: string;
|
|
44
|
-
};
|
|
45
|
-
type ProjectRuntimeInput = {
|
|
46
|
-
organizationId: string;
|
|
47
|
-
projects: OrgProjectDeploy[];
|
|
48
|
-
database: ProjectRuntimeDatabase;
|
|
49
|
-
hosting?: ProjectRuntimeHosting; /** Extra env merged into the project server launch spec (e.g. from an llmProxy plugin). */
|
|
50
|
-
env?: Record<string, string>; /** Previous runtime to retire after a successful cutover. */
|
|
51
|
-
previousRuntimeId?: string | null;
|
|
52
|
-
};
|
|
53
|
-
/** Builds base64 `KEYSTROKE_ORG_ARTIFACTS` payload for org worker containers. */
|
|
54
|
-
declare function encodeOrgArtifacts(artifacts: OrgArtifactSpec[]): string;
|
|
55
|
-
declare function parseOrgArtifactsFromEnv(env?: NodeJS.ProcessEnv): OrgArtifactSpec[] | undefined;
|
|
56
|
-
type ProjectRuntimeDestroyInput = {
|
|
57
|
-
runtimeId: string;
|
|
58
|
-
hosting?: ProjectRuntimeHosting;
|
|
59
|
-
};
|
|
60
|
-
type ProjectRuntimeReconcileInput = {
|
|
61
|
-
organizationId: string; /** The runtime to keep — every other runtime belonging to this org should be destroyed. */
|
|
62
|
-
keepRuntimeId: string;
|
|
63
|
-
hosting?: ProjectRuntimeHosting;
|
|
64
|
-
};
|
|
65
|
-
type ProjectRuntimeResult = {
|
|
66
|
-
runtimeId: string;
|
|
67
|
-
baseUrl: string;
|
|
68
|
-
};
|
|
69
|
-
type ProjectRuntime = {
|
|
70
|
-
start(input: ProjectRuntimeInput): Promise<ProjectRuntimeResult>;
|
|
71
|
-
destroy?(input: ProjectRuntimeDestroyInput): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* Sweep away every runtime for this org except `keepRuntimeId`, retrying
|
|
74
|
-
* transient failures instead of giving up after one attempt. This catches
|
|
75
|
-
* orphans that a single {@link destroy} call missed (e.g. a previous deploy's
|
|
76
|
-
* destroy failed silently), not just the one runtime recorded as "previous."
|
|
77
|
-
*/
|
|
78
|
-
reconcile?(input: ProjectRuntimeReconcileInput): Promise<void>;
|
|
79
|
-
};
|
|
80
|
-
type ProjectPingTarget = {
|
|
81
|
-
baseUrl: string | null;
|
|
82
|
-
runtimeId: string | null;
|
|
83
|
-
};
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region src/worker-runtime-config.d.ts
|
|
86
|
-
/** Resolved platform ↔ project-server worker auth contract. */
|
|
87
|
-
type WorkerRuntimeConfig = {
|
|
88
|
-
/** Platform API base URL reachable from the project-server runtime. */platformUrl: string; /** Bearer token for platform `/internal` routes. */
|
|
89
|
-
workerToken: string;
|
|
90
|
-
};
|
|
91
|
-
declare class WorkerRuntimeConfigError extends Error {
|
|
92
|
-
readonly missing: readonly string[];
|
|
93
|
-
constructor(missing: string[]);
|
|
94
|
-
}
|
|
95
|
-
/** Fail fast when the platform cannot start worker-mode project servers. */
|
|
96
|
-
declare function resolveWorkerRuntimeConfig(source?: NodeJS.ProcessEnv): WorkerRuntimeConfig;
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region src/plugin.d.ts
|
|
99
|
-
type HostingOptions = {
|
|
100
|
-
image?: string;
|
|
101
|
-
env?: NodeJS.ProcessEnv;
|
|
33
|
+
type RuntimeControlOptions = {
|
|
102
34
|
fetchImpl?: typeof fetch;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
type OrganizationHostingInput = {
|
|
106
|
-
organizationId: string;
|
|
107
|
-
name: string;
|
|
108
|
-
};
|
|
109
|
-
type OrganizationHostingResult = {
|
|
110
|
-
appName: string;
|
|
111
|
-
};
|
|
112
|
-
type HostingPlugin = {
|
|
113
|
-
name: string; /** Validated at plugin creation — shared by platform internal routes and project-server containers. */
|
|
114
|
-
workerRuntime: WorkerRuntimeConfig;
|
|
115
|
-
createRuntime(): ProjectRuntime;
|
|
116
|
-
provisionOrganization?(input: OrganizationHostingInput): Promise<OrganizationHostingResult>;
|
|
117
|
-
deprovisionOrganization?(result: OrganizationHostingResult): Promise<void>;
|
|
118
|
-
canPingTarget?(target: ProjectPingTarget): target is {
|
|
119
|
-
baseUrl: string;
|
|
120
|
-
runtimeId: string | null;
|
|
121
|
-
};
|
|
122
|
-
pingRequestHeaders?(runtimeId: string | null): Record<string, string>;
|
|
123
|
-
};
|
|
124
|
-
//#endregion
|
|
125
|
-
//#region src/docker/create-docker-runtime.d.ts
|
|
126
|
-
type WorkspacesMount = {
|
|
127
|
-
hostPath: string;
|
|
128
|
-
containerPath: string;
|
|
35
|
+
timeoutMs?: number; /** Bearer token — typically the org's WORKER_INTERNAL_TOKEN. */
|
|
36
|
+
workerToken?: string;
|
|
129
37
|
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
declare function
|
|
38
|
+
declare function loadProjectOnRuntime(baseUrl: string, input: LoadProjectOnRuntimeInput, options?: RuntimeControlOptions): Promise<void>;
|
|
39
|
+
declare function promoteProjectOnRuntime(baseUrl: string, input: {
|
|
40
|
+
projectId: string;
|
|
41
|
+
artifactId: string;
|
|
42
|
+
}, options?: RuntimeControlOptions): Promise<void>;
|
|
43
|
+
declare function unloadProjectOnRuntime(baseUrl: string, input: {
|
|
44
|
+
projectId: string;
|
|
45
|
+
artifactId: string;
|
|
46
|
+
force?: boolean;
|
|
47
|
+
}, options?: RuntimeControlOptions): Promise<void>;
|
|
48
|
+
/** True when the org runtime answers /health. */
|
|
49
|
+
declare function pingRuntimeHealth(baseUrl: string, options?: RuntimeControlOptions): Promise<boolean>;
|
|
142
50
|
//#endregion
|
|
143
51
|
//#region src/runtime-env.d.ts
|
|
144
52
|
/** Env keys that must never be forwarded into untrusted org workers. */
|
|
@@ -217,19 +125,57 @@ type ProjectDeployStatus = {
|
|
|
217
125
|
ok: boolean;
|
|
218
126
|
error?: string;
|
|
219
127
|
};
|
|
128
|
+
type VersionDeployStatus = {
|
|
129
|
+
projectId: string;
|
|
130
|
+
artifactId: string;
|
|
131
|
+
state: "active" | "resident" | "indexed";
|
|
132
|
+
ok: boolean;
|
|
133
|
+
activeJobCount?: number;
|
|
134
|
+
error?: string;
|
|
135
|
+
};
|
|
220
136
|
type DeployStatusResponse = {
|
|
221
137
|
projects: ProjectDeployStatus[];
|
|
138
|
+
versions?: VersionDeployStatus[];
|
|
222
139
|
};
|
|
223
140
|
type FetchDeployStatusOptions = {
|
|
224
141
|
fetchImpl?: typeof fetch;
|
|
225
142
|
timeoutMs?: number;
|
|
226
143
|
};
|
|
144
|
+
type WaitForDeployStatusOptions = {
|
|
145
|
+
fetchImpl?: typeof fetch;
|
|
146
|
+
timeoutMs?: number;
|
|
147
|
+
intervalMs?: number;
|
|
148
|
+
};
|
|
227
149
|
/**
|
|
228
150
|
* Ask a running org machine which projects bootstrapped and which failed.
|
|
229
|
-
*
|
|
230
|
-
*
|
|
151
|
+
* Returns undefined when the endpoint is unreachable, non-OK, times out, or
|
|
152
|
+
* returns an unusable payload — callers must treat that as non-affirmative
|
|
153
|
+
* health for every pending project (never promote on silence).
|
|
231
154
|
*/
|
|
232
155
|
declare function fetchDeployStatus(baseUrl: string, options?: FetchDeployStatusOptions): Promise<DeployStatusResponse | undefined>;
|
|
156
|
+
/**
|
|
157
|
+
* Poll `/deploy-status` until the real worker returns a usable payload or the
|
|
158
|
+
* deadline expires. Retries only transient unavailability (network errors,
|
|
159
|
+
* non-2xx including early-health 404, timeouts, malformed bodies). Any valid
|
|
160
|
+
* `{ projects: [...] }` response — including empty or explicit failures — is
|
|
161
|
+
* terminal so genuine bootstrap errors surface immediately.
|
|
162
|
+
*/
|
|
163
|
+
declare function waitForDeployStatus(baseUrl: string, options?: WaitForDeployStatusOptions): Promise<DeployStatusResponse | undefined>;
|
|
164
|
+
type DeployHealthVerdict = {
|
|
165
|
+
ok: true;
|
|
166
|
+
} | {
|
|
167
|
+
ok: false;
|
|
168
|
+
error: string;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Require an explicit `{ projectId, ok: true }` entry for each candidate.
|
|
172
|
+
* Missing entries, `ok: false`, empty `projects`, or an unavailable status
|
|
173
|
+
* response all fail closed for that project.
|
|
174
|
+
*/
|
|
175
|
+
declare function classifyDeployHealth(input: {
|
|
176
|
+
projectIds: string[];
|
|
177
|
+
deployStatus: DeployStatusResponse | undefined;
|
|
178
|
+
}): Map<string, DeployHealthVerdict>;
|
|
233
179
|
//#endregion
|
|
234
|
-
export { DEV_PLATFORM_WORKER_TOKEN, type
|
|
180
|
+
export { DEV_PLATFORM_WORKER_TOKEN, type DeployHealthVerdict, type DeployStatusResponse, FORBIDDEN_WORKER_ENV_KEYS, type FetchDeployStatusOptions, type HostingOptions, type HostingPlugin, type LoadProjectOnRuntimeInput, type OrgArtifactSpec, type OrgProjectDeploy, type OrganizationHostingInput, type OrganizationHostingResult, PROJECT_SERVER_CONTROL, PROJECT_SERVER_DEPLOY_STATUS, PROJECT_SERVER_FRAMEWORK_NODE_MODULES, PROJECT_SERVER_FRAMEWORK_ROOT, PROJECT_SERVER_HEALTH, PROJECT_SERVER_IMAGE, PROJECT_SERVER_PORT, PROJECT_SERVER_ROOT, type PingProjectOptions, type ProjectDeployStatus, type ProjectPingTarget, type ProjectRuntime, type ProjectRuntimeDatabase, type ProjectRuntimeDestroyInput, type ProjectRuntimeHosting, type ProjectRuntimeInput, type ProjectRuntimeReconcileInput, type ProjectRuntimeResult, type ProjectRuntimeSleepInput, type ProjectRuntimeWakeInput, RUNTIME_PING_TIMEOUT_MS, type RuntimeControlOptions, type RuntimeLaunchSpec, type VerifiedOrgWorkerToken, type VersionDeployStatus, type WaitForDeployStatusOptions, type WaitForHealthOptions, type WorkerRuntimeConfig, WorkerRuntimeConfigError, buildRuntimeEnv, canPingProjectTarget, classifyDeployHealth, encodeOrgArtifacts, fetchDeployStatus, formatDockerEnv, loadProjectOnRuntime, mintOrgWorkerToken, parseOrgArtifactsFromEnv, pingProject, pingProjectTarget, pingRuntimeHealth, promoteProjectOnRuntime, resolvePlatformWorkerToken, resolveProjectServerImage, resolveRuntimeLaunch, resolveWorkerPlatformUrl, resolveWorkerRuntimeConfig, rewriteLoopbackHost, rewriteLoopbackUrl, unloadProjectOnRuntime, verifyOrgWorkerToken, waitForDeployStatus, waitForHealth };
|
|
235
181
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/constants.ts","../src/runtime
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/constants.ts","../src/runtime-control.ts","../src/runtime-env.ts","../src/org-worker-token.ts","../src/wait-for-health.ts","../src/runtime-constants.ts","../src/ping-project.ts","../src/ping-project-target.ts","../src/deploy-status.ts"],"mappings":";;;;cAAa,oBAAA;AAAA,cAEA,mBAAA;AAAA,cAEA,mBAAA;AAAA,cAEA,6BAAA;AAAA,cAEA,qCAAA;AAAA,cAEA,qBAAA;EAAA,SAGH,IAAA;EAAA,SAAA,IAAA;AAAA;AAAA,cAEG,4BAAA;EAAA,SAGH,IAAA;EAAA,SAAA,IAAA;AAAA;;;cCfG,sBAAA;EAAA;;;;;KAOD,yBAAA;EACV,SAAA;EACA,UAAA;EACA,eAAA;EACA,UAAA;EACA,QAAA;AAAA;AAAA,KAGU,qBAAA;EACV,SAAA,UAAmB,KAAK;EACxB,SAAA;EAEA,WAAA;AAAA;AAAA,iBAoCoB,oBAAA,CACpB,OAAA,UACA,KAAA,EAAO,yBAAA,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