@better-openclaw/core 1.0.20 → 1.0.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.
Files changed (52) hide show
  1. package/.github/workflows/publish-core.yml +1 -1
  2. package/dist/deployers/coolify.cjs +61 -50
  3. package/dist/deployers/coolify.cjs.map +1 -1
  4. package/dist/deployers/coolify.d.cts +4 -11
  5. package/dist/deployers/coolify.d.cts.map +1 -1
  6. package/dist/deployers/coolify.d.mts +4 -11
  7. package/dist/deployers/coolify.d.mts.map +1 -1
  8. package/dist/deployers/coolify.mjs +62 -50
  9. package/dist/deployers/coolify.mjs.map +1 -1
  10. package/dist/deployers/dokploy.cjs +106 -29
  11. package/dist/deployers/dokploy.cjs.map +1 -1
  12. package/dist/deployers/dokploy.d.cts +2 -1
  13. package/dist/deployers/dokploy.d.cts.map +1 -1
  14. package/dist/deployers/dokploy.d.mts +2 -1
  15. package/dist/deployers/dokploy.d.mts.map +1 -1
  16. package/dist/deployers/dokploy.mjs +107 -29
  17. package/dist/deployers/dokploy.mjs.map +1 -1
  18. package/dist/deployers/index.cjs.map +1 -1
  19. package/dist/deployers/index.d.cts +2 -2
  20. package/dist/deployers/index.d.cts.map +1 -1
  21. package/dist/deployers/index.d.mts +2 -2
  22. package/dist/deployers/index.d.mts.map +1 -1
  23. package/dist/deployers/index.mjs.map +1 -1
  24. package/dist/deployers/strip-host-ports.cjs +138 -0
  25. package/dist/deployers/strip-host-ports.cjs.map +1 -0
  26. package/dist/deployers/strip-host-ports.d.cts +62 -0
  27. package/dist/deployers/strip-host-ports.d.cts.map +1 -0
  28. package/dist/deployers/strip-host-ports.d.mts +62 -0
  29. package/dist/deployers/strip-host-ports.d.mts.map +1 -0
  30. package/dist/deployers/strip-host-ports.mjs +133 -0
  31. package/dist/deployers/strip-host-ports.mjs.map +1 -0
  32. package/dist/deployers/strip-host-ports.test.cjs +89 -0
  33. package/dist/deployers/strip-host-ports.test.cjs.map +1 -0
  34. package/dist/deployers/strip-host-ports.test.d.cts +1 -0
  35. package/dist/deployers/strip-host-ports.test.d.mts +1 -0
  36. package/dist/deployers/strip-host-ports.test.mjs +90 -0
  37. package/dist/deployers/strip-host-ports.test.mjs.map +1 -0
  38. package/dist/deployers/types.d.cts +173 -2
  39. package/dist/deployers/types.d.cts.map +1 -1
  40. package/dist/deployers/types.d.mts +173 -2
  41. package/dist/deployers/types.d.mts.map +1 -1
  42. package/dist/index.d.cts +2 -2
  43. package/dist/index.d.mts +2 -2
  44. package/package.json +2 -1
  45. package/src/deployers/coolify.ts +198 -103
  46. package/src/deployers/dokploy.ts +209 -55
  47. package/src/deployers/index.ts +1 -0
  48. package/src/deployers/strip-host-ports.test.ts +100 -0
  49. package/src/deployers/strip-host-ports.ts +187 -0
  50. package/src/deployers/types.ts +185 -1
  51. package/src/index.ts +19 -4
  52. package/tsconfig.tsbuildinfo +1 -0
@@ -19,7 +19,7 @@ jobs:
19
19
 
20
20
  - uses: pnpm/action-setup@v4
21
21
  with:
22
- version: 9
22
+ version: 10.30.3
23
23
  run_install: false
24
24
 
25
25
  - name: Install dependencies
@@ -1,14 +1,24 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_deployers_strip_host_ports = require('./strip-host-ports.cjs');
2
3
 
3
4
  //#region src/deployers/coolify.ts
4
- /** Build a full Coolify API URL (base + /api/v1 + path). */
5
+ /**
6
+ * Coolify PaaS deployer
7
+ *
8
+ * Deploys Docker Compose stacks via Coolify v4 API
9
+ *
10
+ * Docs:
11
+ * https://coolify.io/docs/api-reference/api
12
+ *
13
+ * Auth:
14
+ * Authorization: Bearer <token>
15
+ *
16
+ * Base path:
17
+ * /api/v1
18
+ */
5
19
  function apiUrl(target, path) {
6
20
  return `${target.instanceUrl.replace(/\/+$/, "")}/api/v1${path}`;
7
21
  }
8
- /**
9
- * Typed fetch wrapper for the Coolify v4 API.
10
- * Handles JSON serialisation, Bearer auth, and error extraction.
11
- */
12
22
  async function coolifyFetch(target, path, options = {}) {
13
23
  const res = await fetch(apiUrl(target, path), {
14
24
  method: options.method ?? "GET",
@@ -31,18 +41,24 @@ async function coolifyFetch(target, path, options = {}) {
31
41
  if (!text) return void 0;
32
42
  return JSON.parse(text);
33
43
  }
34
- /**
35
- * Parse .env content into key-value pairs for Coolify's bulk env API.
36
- */
44
+ function hashString(str) {
45
+ let hash = 0;
46
+ for (let i = 0; i < str.length; i++) {
47
+ hash = (hash << 5) - hash + str.charCodeAt(i);
48
+ hash |= 0;
49
+ }
50
+ return hash;
51
+ }
37
52
  function parseEnvContent(envContent) {
53
+ if (!envContent) return [];
38
54
  const result = [];
39
55
  for (const line of envContent.split("\n")) {
40
56
  const trimmed = line.trim();
41
57
  if (!trimmed || trimmed.startsWith("#")) continue;
42
- const eqIdx = trimmed.indexOf("=");
43
- if (eqIdx <= 0) continue;
44
- const key = trimmed.slice(0, eqIdx);
45
- const value = trimmed.slice(eqIdx + 1);
58
+ const idx = trimmed.indexOf("=");
59
+ if (idx <= 0) continue;
60
+ const key = trimmed.slice(0, idx);
61
+ const value = trimmed.slice(idx + 1);
46
62
  result.push({
47
63
  key,
48
64
  value,
@@ -53,16 +69,6 @@ function parseEnvContent(envContent) {
53
69
  }
54
70
  return result;
55
71
  }
56
- /**
57
- * Deploys Docker Compose stacks to a Coolify v4 instance.
58
- *
59
- * Deploy flow (5 steps):
60
- * 1. Discover the first available server
61
- * 2. Create a Coolify project
62
- * 3. Create a compose service with the raw docker-compose YAML
63
- * 4. Push .env variables via the bulk env API
64
- * 5. Trigger the deployment
65
- */
66
72
  var CoolifyDeployer = class {
67
73
  name = "Coolify";
68
74
  id = "coolify";
@@ -83,15 +89,15 @@ var CoolifyDeployer = class {
83
89
  status: "pending"
84
90
  };
85
91
  const step2 = {
86
- step: "Create project",
92
+ step: "Find or create project",
87
93
  status: "pending"
88
94
  };
89
95
  const step3 = {
90
- step: "Create compose service",
96
+ step: "Find or create service",
91
97
  status: "pending"
92
98
  };
93
99
  const step4 = {
94
- step: "Set environment variables",
100
+ step: "Update environment variables",
95
101
  status: "pending"
96
102
  };
97
103
  const step5 = {
@@ -109,68 +115,73 @@ var CoolifyDeployer = class {
109
115
  success: false,
110
116
  steps
111
117
  };
118
+ const composeYaml = require_deployers_strip_host_ports.sanitizeComposeForPaas(input.composeYaml);
112
119
  try {
113
120
  step1.status = "running";
114
121
  const servers = await coolifyFetch(input.target, "/servers");
115
- if (!servers || servers.length === 0) throw new Error("No servers found in Coolify instance");
122
+ if (!servers.length) throw new Error("No Coolify servers available");
116
123
  const server = servers[0];
117
124
  step1.status = "done";
118
- step1.detail = `Server: ${server.name} (${server.ip})`;
125
+ step1.detail = `${server.name} (${server.ip})`;
119
126
  step2.status = "running";
120
- const project = await coolifyFetch(input.target, "/projects", {
127
+ let project = (await coolifyFetch(input.target, "/projects")).find((p) => p.name === input.projectName);
128
+ if (!project) project = await coolifyFetch(input.target, "/projects", {
121
129
  method: "POST",
122
130
  body: {
123
131
  name: input.projectName,
124
- description: input.description ?? `OpenClaw stack: ${input.projectName}`
132
+ description: input.description ?? `Stack ${input.projectName}`
125
133
  }
126
134
  });
127
135
  result.projectId = project.uuid;
128
136
  step2.status = "done";
129
- step2.detail = `Project: ${project.uuid}`;
137
+ step2.detail = project.uuid;
130
138
  const projectDetail = await coolifyFetch(input.target, `/projects/${project.uuid}`);
131
- const envUuid = projectDetail.environments?.[0]?.uuid;
132
- const envName = projectDetail.environments?.[0]?.name ?? "production";
133
- if (!envUuid) throw new Error("No default environment found in project");
139
+ const env = projectDetail.environments?.find((e) => e.name === "production") ?? projectDetail.environments?.[0];
140
+ if (!env) throw new Error("No environment found");
134
141
  step3.status = "running";
135
- const service = await coolifyFetch(input.target, "/services", {
142
+ let service = (await coolifyFetch(input.target, `/projects/${project.uuid}/services`)).find((s) => s.name === input.projectName);
143
+ if (!service) service = await coolifyFetch(input.target, "/services", {
136
144
  method: "POST",
137
145
  body: {
138
146
  project_uuid: project.uuid,
139
147
  server_uuid: server.uuid,
140
- environment_name: envName,
141
- environment_uuid: envUuid,
142
- docker_compose_raw: input.composeYaml,
143
- name: input.projectName,
144
- description: input.description ?? "Deployed via OpenClaw web builder",
145
- instant_deploy: false
148
+ environment_uuid: env.uuid,
149
+ environment_name: env.name,
150
+ docker_compose_raw: composeYaml,
151
+ name: input.projectName
146
152
  }
147
153
  });
154
+ else if (hashString(composeYaml) !== hashString(service.docker_compose_raw ?? "")) await coolifyFetch(input.target, `/services/${service.uuid}`, {
155
+ method: "PATCH",
156
+ body: { docker_compose_raw: composeYaml }
157
+ });
148
158
  result.composeId = service.uuid;
149
159
  step3.status = "done";
150
- step3.detail = `Service: ${service.uuid}`;
160
+ step3.detail = service.uuid;
151
161
  step4.status = "running";
152
162
  const envVars = parseEnvContent(input.envContent);
153
- if (envVars.length > 0) await coolifyFetch(input.target, `/services/${service.uuid}/envs`, {
163
+ if (envVars.length) await coolifyFetch(input.target, `/services/${service.uuid}/envs`, {
154
164
  method: "PATCH",
155
165
  body: envVars
156
166
  });
157
167
  step4.status = "done";
158
- step4.detail = `${envVars.length} variables set`;
168
+ step4.detail = `${envVars.length} vars`;
159
169
  step5.status = "running";
160
- const deployments = await coolifyFetch(input.target, `/deploy?uuid=${service.uuid}&force=true`);
170
+ const deploy = await coolifyFetch(input.target, `/deploy?uuid=${service.uuid}&force=true`);
161
171
  step5.status = "done";
162
- step5.detail = deployments?.deployments?.[0]?.deployment_uuid ?? "Deployment triggered";
172
+ step5.detail = deploy.deployments?.[0]?.deployment_uuid ?? "Deployment started";
163
173
  result.success = true;
164
174
  result.dashboardUrl = `${input.target.instanceUrl.replace(/\/+$/, "")}/project/${project.uuid}`;
175
+ return result;
165
176
  } catch (err) {
166
- const failedStep = steps.find((s) => s.status === "running");
167
- if (failedStep) {
168
- failedStep.status = "error";
169
- failedStep.detail = err instanceof Error ? err.message : String(err);
177
+ const running = steps.find((s) => s.status === "running");
178
+ if (running) {
179
+ running.status = "error";
180
+ running.detail = err instanceof Error ? err.message : String(err);
170
181
  }
171
182
  result.error = err instanceof Error ? err.message : String(err);
183
+ return result;
172
184
  }
173
- return result;
174
185
  }
175
186
  };
176
187
 
@@ -1 +1 @@
1
- {"version":3,"file":"coolify.cjs","names":[],"sources":["../../src/deployers/coolify.ts"],"sourcesContent":["/**\n * Coolify PaaS deployer — deploys Docker Compose stacks via the Coolify v4 REST API.\n *\n * API docs: https://coolify.io/docs/api-reference/api/\n * Auth: Authorization: Bearer <token>\n * Base path: /api/v1\n */\n\nimport type { DeployInput, DeployResult, DeployStep, DeployTarget, PaasDeployer } from \"./types.js\";\n\n/** Shape returned by Coolify's project endpoints. */\ninterface CoolifyProject {\n\tuuid: string;\n\tname: string;\n\tenvironments?: { uuid: string; name: string }[];\n}\n\n/** Shape returned by Coolify's server listing. */\ninterface CoolifyServer {\n\tuuid: string;\n\tname: string;\n\tip: string;\n}\n\n/** Shape returned when creating a Coolify service (compose stack). */\ninterface CoolifyService {\n\tuuid: string;\n}\n\n/** Shape returned by Coolify's deploy trigger endpoint. */\ninterface CoolifyDeployment {\n\tmessage: string;\n\tresource_uuid: string;\n\tdeployment_uuid: string;\n}\n\n/** Build a full Coolify API URL (base + /api/v1 + path). */\nfunction apiUrl(target: DeployTarget, path: string): string {\n\tconst base = target.instanceUrl.replace(/\\/+$/, \"\");\n\treturn `${base}/api/v1${path}`;\n}\n\n/**\n * Typed fetch wrapper for the Coolify v4 API.\n * Handles JSON serialisation, Bearer auth, and error extraction.\n */\nasync function coolifyFetch<T>(\n\ttarget: DeployTarget,\n\tpath: string,\n\toptions: { method?: string; body?: unknown } = {},\n): Promise<T> {\n\tconst res = await fetch(apiUrl(target, path), {\n\t\tmethod: options.method ?? \"GET\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t\tAuthorization: `Bearer ${target.apiKey}`,\n\t\t},\n\t\tbody: options.body ? JSON.stringify(options.body) : undefined,\n\t});\n\n\tif (!res.ok) {\n\t\tconst text = await res.text().catch(() => \"\");\n\t\tlet detail = text;\n\t\ttry {\n\t\t\tconst json = JSON.parse(text);\n\t\t\tdetail = json.message || json.error || text;\n\t\t} catch {\n\t\t\t// use raw text\n\t\t}\n\t\tthrow new Error(`Coolify API ${res.status}: ${detail}`);\n\t}\n\n\tconst text = await res.text();\n\tif (!text) return undefined as T;\n\treturn JSON.parse(text) as T;\n}\n\n/**\n * Parse .env content into key-value pairs for Coolify's bulk env API.\n */\nfunction parseEnvContent(envContent: string): {\n\tkey: string;\n\tvalue: string;\n\tis_preview: boolean;\n\tis_build_time: boolean;\n\tis_literal: boolean;\n}[] {\n\tconst result: {\n\t\tkey: string;\n\t\tvalue: string;\n\t\tis_preview: boolean;\n\t\tis_build_time: boolean;\n\t\tis_literal: boolean;\n\t}[] = [];\n\n\tfor (const line of envContent.split(\"\\n\")) {\n\t\tconst trimmed = line.trim();\n\t\tif (!trimmed || trimmed.startsWith(\"#\")) continue;\n\n\t\tconst eqIdx = trimmed.indexOf(\"=\");\n\t\tif (eqIdx <= 0) continue;\n\n\t\tconst key = trimmed.slice(0, eqIdx);\n\t\tconst value = trimmed.slice(eqIdx + 1);\n\n\t\tresult.push({\n\t\t\tkey,\n\t\t\tvalue,\n\t\t\tis_preview: false,\n\t\t\tis_build_time: false,\n\t\t\tis_literal: true,\n\t\t});\n\t}\n\n\treturn result;\n}\n\n/**\n * Deploys Docker Compose stacks to a Coolify v4 instance.\n *\n * Deploy flow (5 steps):\n * 1. Discover the first available server\n * 2. Create a Coolify project\n * 3. Create a compose service with the raw docker-compose YAML\n * 4. Push .env variables via the bulk env API\n * 5. Trigger the deployment\n */\nexport class CoolifyDeployer implements PaasDeployer {\n\treadonly name = \"Coolify\";\n\treadonly id = \"coolify\";\n\n\tasync testConnection(target: DeployTarget): Promise<{ ok: boolean; error?: string }> {\n\t\ttry {\n\t\t\tawait coolifyFetch<unknown>(target, \"/version\");\n\t\t\treturn { ok: true };\n\t\t} catch (err) {\n\t\t\treturn { ok: false, error: err instanceof Error ? err.message : String(err) };\n\t\t}\n\t}\n\n\tasync deploy(input: DeployInput): Promise<DeployResult> {\n\t\tconst step1: DeployStep = { step: \"Discover server\", status: \"pending\" };\n\t\tconst step2: DeployStep = { step: \"Create project\", status: \"pending\" };\n\t\tconst step3: DeployStep = { step: \"Create compose service\", status: \"pending\" };\n\t\tconst step4: DeployStep = { step: \"Set environment variables\", status: \"pending\" };\n\t\tconst step5: DeployStep = { step: \"Trigger deployment\", status: \"pending\" };\n\t\tconst steps: DeployStep[] = [step1, step2, step3, step4, step5];\n\n\t\tconst result: DeployResult = { success: false, steps };\n\n\t\ttry {\n\t\t\t// Step 1: Discover default server\n\t\t\tstep1.status = \"running\";\n\t\t\tconst servers = await coolifyFetch<CoolifyServer[]>(input.target, \"/servers\");\n\t\t\tif (!servers || servers.length === 0) {\n\t\t\t\tthrow new Error(\"No servers found in Coolify instance\");\n\t\t\t}\n\t\t\tconst server = servers[0] as CoolifyServer;\n\t\t\tstep1.status = \"done\";\n\t\t\tstep1.detail = `Server: ${server.name} (${server.ip})`;\n\n\t\t\t// Step 2: Create project\n\t\t\tstep2.status = \"running\";\n\t\t\tconst project = await coolifyFetch<CoolifyProject>(input.target, \"/projects\", {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: {\n\t\t\t\t\tname: input.projectName,\n\t\t\t\t\tdescription: input.description ?? `OpenClaw stack: ${input.projectName}`,\n\t\t\t\t},\n\t\t\t});\n\t\t\tresult.projectId = project.uuid;\n\t\t\tstep2.status = \"done\";\n\t\t\tstep2.detail = `Project: ${project.uuid}`;\n\n\t\t\t// Get the default environment\n\t\t\tconst projectDetail = await coolifyFetch<CoolifyProject>(\n\t\t\t\tinput.target,\n\t\t\t\t`/projects/${project.uuid}`,\n\t\t\t);\n\t\t\tconst envUuid = projectDetail.environments?.[0]?.uuid;\n\t\t\tconst envName = projectDetail.environments?.[0]?.name ?? \"production\";\n\t\t\tif (!envUuid) {\n\t\t\t\tthrow new Error(\"No default environment found in project\");\n\t\t\t}\n\n\t\t\t// Step 3: Create compose service with docker_compose_raw\n\t\t\tstep3.status = \"running\";\n\t\t\tconst service = await coolifyFetch<CoolifyService>(input.target, \"/services\", {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: {\n\t\t\t\t\tproject_uuid: project.uuid,\n\t\t\t\t\tserver_uuid: server.uuid,\n\t\t\t\t\tenvironment_name: envName,\n\t\t\t\t\tenvironment_uuid: envUuid,\n\t\t\t\t\tdocker_compose_raw: input.composeYaml,\n\t\t\t\t\tname: input.projectName,\n\t\t\t\t\tdescription: input.description ?? \"Deployed via OpenClaw web builder\",\n\t\t\t\t\tinstant_deploy: false,\n\t\t\t\t},\n\t\t\t});\n\t\t\tresult.composeId = service.uuid;\n\t\t\tstep3.status = \"done\";\n\t\t\tstep3.detail = `Service: ${service.uuid}`;\n\n\t\t\t// Step 4: Set environment variables\n\t\t\tstep4.status = \"running\";\n\t\t\tconst envVars = parseEnvContent(input.envContent);\n\t\t\tif (envVars.length > 0) {\n\t\t\t\tawait coolifyFetch(input.target, `/services/${service.uuid}/envs`, {\n\t\t\t\t\tmethod: \"PATCH\",\n\t\t\t\t\tbody: envVars,\n\t\t\t\t});\n\t\t\t}\n\t\t\tstep4.status = \"done\";\n\t\t\tstep4.detail = `${envVars.length} variables set`;\n\n\t\t\t// Step 5: Trigger deployment\n\t\t\tstep5.status = \"running\";\n\t\t\tconst deployments = await coolifyFetch<{ deployments: CoolifyDeployment[] }>(\n\t\t\t\tinput.target,\n\t\t\t\t`/deploy?uuid=${service.uuid}&force=true`,\n\t\t\t);\n\t\t\tstep5.status = \"done\";\n\t\t\tstep5.detail = deployments?.deployments?.[0]?.deployment_uuid ?? \"Deployment triggered\";\n\n\t\t\tresult.success = true;\n\t\t\tconst base = input.target.instanceUrl.replace(/\\/+$/, \"\");\n\t\t\tresult.dashboardUrl = `${base}/project/${project.uuid}`;\n\t\t} catch (err) {\n\t\t\tconst failedStep = steps.find((s) => s.status === \"running\");\n\t\t\tif (failedStep) {\n\t\t\t\tfailedStep.status = \"error\";\n\t\t\t\tfailedStep.detail = err instanceof Error ? err.message : String(err);\n\t\t\t}\n\t\t\tresult.error = err instanceof Error ? err.message : String(err);\n\t\t}\n\n\t\treturn result;\n\t}\n}\n"],"mappings":";;;;AAqCA,SAAS,OAAO,QAAsB,MAAsB;AAE3D,QAAO,GADM,OAAO,YAAY,QAAQ,QAAQ,GAAG,CACpC,SAAS;;;;;;AAOzB,eAAe,aACd,QACA,MACA,UAA+C,EAAE,EACpC;CACb,MAAM,MAAM,MAAM,MAAM,OAAO,QAAQ,KAAK,EAAE;EAC7C,QAAQ,QAAQ,UAAU;EAC1B,SAAS;GACR,gBAAgB;GAChB,eAAe,UAAU,OAAO;GAChC;EACD,MAAM,QAAQ,OAAO,KAAK,UAAU,QAAQ,KAAK,GAAG;EACpD,CAAC;AAEF,KAAI,CAAC,IAAI,IAAI;EACZ,MAAM,OAAO,MAAM,IAAI,MAAM,CAAC,YAAY,GAAG;EAC7C,IAAI,SAAS;AACb,MAAI;GACH,MAAM,OAAO,KAAK,MAAM,KAAK;AAC7B,YAAS,KAAK,WAAW,KAAK,SAAS;UAChC;AAGR,QAAM,IAAI,MAAM,eAAe,IAAI,OAAO,IAAI,SAAS;;CAGxD,MAAM,OAAO,MAAM,IAAI,MAAM;AAC7B,KAAI,CAAC,KAAM,QAAO;AAClB,QAAO,KAAK,MAAM,KAAK;;;;;AAMxB,SAAS,gBAAgB,YAMrB;CACH,MAAM,SAMA,EAAE;AAER,MAAK,MAAM,QAAQ,WAAW,MAAM,KAAK,EAAE;EAC1C,MAAM,UAAU,KAAK,MAAM;AAC3B,MAAI,CAAC,WAAW,QAAQ,WAAW,IAAI,CAAE;EAEzC,MAAM,QAAQ,QAAQ,QAAQ,IAAI;AAClC,MAAI,SAAS,EAAG;EAEhB,MAAM,MAAM,QAAQ,MAAM,GAAG,MAAM;EACnC,MAAM,QAAQ,QAAQ,MAAM,QAAQ,EAAE;AAEtC,SAAO,KAAK;GAC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s","names":["sanitizeComposeForPaas"],"sources":["../../src/deployers/coolify.ts"],"sourcesContent":["/**\n * Coolify PaaS deployer\n *\n * Deploys Docker Compose stacks via Coolify v4 API\n *\n * Docs:\n * https://coolify.io/docs/api-reference/api\n *\n * Auth:\n * Authorization: Bearer <token>\n *\n * Base path:\n * /api/v1\n */\n\nimport { sanitizeComposeForPaas } from \"./strip-host-ports.js\";\nimport type { DeployInput, DeployResult, DeployStep, DeployTarget, PaasDeployer } from \"./types.js\";\n\n/* ----------------------------- */\n/* Coolify API Types */\n/* ----------------------------- */\n\ninterface CoolifyProject {\n\tuuid: string;\n\tname: string;\n\tenvironments?: {\n\t\tuuid: string;\n\t\tname: string;\n\t}[];\n}\n\ninterface CoolifyServer {\n\tuuid: string;\n\tname: string;\n\tip: string;\n}\n\ninterface CoolifyService {\n\tuuid: string;\n\tname: string;\n\tdocker_compose_raw?: string;\n}\n\ninterface CoolifyDeployment {\n\tmessage: string;\n\tresource_uuid: string;\n\tdeployment_uuid: string;\n}\n\n/* ----------------------------- */\n/* Utilities */\n/* ----------------------------- */\n\nfunction apiUrl(target: DeployTarget, path: string) {\n\tconst base = target.instanceUrl.replace(/\\/+$/, \"\");\n\treturn `${base}/api/v1${path}`;\n}\n\nasync function coolifyFetch<T>(\n\ttarget: DeployTarget,\n\tpath: string,\n\toptions: { method?: string; body?: unknown } = {},\n): Promise<T> {\n\tconst res = await fetch(apiUrl(target, path), {\n\t\tmethod: options.method ?? \"GET\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t\tAuthorization: `Bearer ${target.apiKey}`,\n\t\t},\n\t\tbody: options.body ? JSON.stringify(options.body) : undefined,\n\t});\n\n\tif (!res.ok) {\n\t\tconst text = await res.text().catch(() => \"\");\n\t\tlet detail = text;\n\n\t\ttry {\n\t\t\tconst json = JSON.parse(text);\n\t\t\tdetail = json.message || json.error || text;\n\t\t} catch {}\n\n\t\tthrow new Error(`Coolify API ${res.status}: ${detail}`);\n\t}\n\n\tconst text = await res.text();\n\n\tif (!text) return undefined as T;\n\n\treturn JSON.parse(text);\n}\n\nfunction hashString(str: string) {\n\tlet hash = 0;\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\thash = (hash << 5) - hash + str.charCodeAt(i);\n\t\thash |= 0;\n\t}\n\n\treturn hash;\n}\n\nfunction parseEnvContent(envContent?: string) {\n\tif (!envContent) return [];\n\n\tconst result = [];\n\n\tfor (const line of envContent.split(\"\\n\")) {\n\t\tconst trimmed = line.trim();\n\n\t\tif (!trimmed || trimmed.startsWith(\"#\")) continue;\n\n\t\tconst idx = trimmed.indexOf(\"=\");\n\n\t\tif (idx <= 0) continue;\n\n\t\tconst key = trimmed.slice(0, idx);\n\t\tconst value = trimmed.slice(idx + 1);\n\n\t\tresult.push({\n\t\t\tkey,\n\t\t\tvalue,\n\t\t\tis_preview: false,\n\t\t\tis_build_time: false,\n\t\t\tis_literal: true,\n\t\t});\n\t}\n\n\treturn result;\n}\n\n/* ----------------------------- */\n/* Coolify Deployer */\n/* ----------------------------- */\n\nexport class CoolifyDeployer implements PaasDeployer {\n\treadonly name = \"Coolify\";\n\treadonly id = \"coolify\";\n\n\tasync testConnection(target: DeployTarget) {\n\t\ttry {\n\t\t\tawait coolifyFetch(target, \"/version\");\n\n\t\t\treturn { ok: true };\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t};\n\t\t}\n\t}\n\n\tasync deploy(input: DeployInput): Promise<DeployResult> {\n\t\tconst step1: DeployStep = { step: \"Discover server\", status: \"pending\" };\n\t\tconst step2: DeployStep = {\n\t\t\tstep: \"Find or create project\",\n\t\t\tstatus: \"pending\",\n\t\t};\n\t\tconst step3: DeployStep = {\n\t\t\tstep: \"Find or create service\",\n\t\t\tstatus: \"pending\",\n\t\t};\n\t\tconst step4: DeployStep = {\n\t\t\tstep: \"Update environment variables\",\n\t\t\tstatus: \"pending\",\n\t\t};\n\t\tconst step5: DeployStep = { step: \"Trigger deployment\", status: \"pending\" };\n\t\tconst steps: DeployStep[] = [step1, step2, step3, step4, step5];\n\n\t\tconst result: DeployResult = { success: false, steps };\n\n\t\t// Strip host port bindings — Coolify routes via Traefik,\n\t\t// so host ports are unnecessary and cause \"port already allocated\" errors.\n\t\tconst composeYaml = sanitizeComposeForPaas(input.composeYaml);\n\n\t\ttry {\n\t\t\t/* ----------------------------- */\n\t\t\t/* STEP 1: Discover server */\n\t\t\t/* ----------------------------- */\n\n\t\t\tstep1.status = \"running\";\n\n\t\t\tconst servers = await coolifyFetch<CoolifyServer[]>(input.target, \"/servers\");\n\n\t\t\tif (!servers.length) {\n\t\t\t\tthrow new Error(\"No Coolify servers available\");\n\t\t\t}\n\n\t\t\tconst server = servers[0]!;\n\n\t\t\tstep1.status = \"done\";\n\t\t\tstep1.detail = `${server.name} (${server.ip})`;\n\n\t\t\t/* ----------------------------- */\n\t\t\t/* STEP 2: Find or create project */\n\t\t\t/* ----------------------------- */\n\n\t\t\tstep2.status = \"running\";\n\n\t\t\tconst projects = await coolifyFetch<CoolifyProject[]>(input.target, \"/projects\");\n\n\t\t\tlet project = projects.find((p) => p.name === input.projectName);\n\n\t\t\tif (!project) {\n\t\t\t\tproject = await coolifyFetch<CoolifyProject>(input.target, \"/projects\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tname: input.projectName,\n\t\t\t\t\t\tdescription: input.description ?? `Stack ${input.projectName}`,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tresult.projectId = project.uuid;\n\n\t\t\tstep2.status = \"done\";\n\t\t\tstep2.detail = project.uuid;\n\n\t\t\t/* ----------------------------- */\n\t\t\t/* Find environment */\n\t\t\t/* ----------------------------- */\n\n\t\t\tconst projectDetail = await coolifyFetch<CoolifyProject>(\n\t\t\t\tinput.target,\n\t\t\t\t`/projects/${project.uuid}`,\n\t\t\t);\n\n\t\t\tconst env =\n\t\t\t\tprojectDetail.environments?.find((e) => e.name === \"production\") ??\n\t\t\t\tprojectDetail.environments?.[0];\n\n\t\t\tif (!env) throw new Error(\"No environment found\");\n\n\t\t\t/* ----------------------------- */\n\t\t\t/* STEP 3: Find or create service */\n\t\t\t/* ----------------------------- */\n\n\t\t\tstep3.status = \"running\";\n\n\t\t\tconst services = await coolifyFetch<CoolifyService[]>(\n\t\t\t\tinput.target,\n\t\t\t\t`/projects/${project.uuid}/services`,\n\t\t\t);\n\n\t\t\tlet service = services.find((s) => s.name === input.projectName);\n\n\t\t\tif (!service) {\n\t\t\t\tservice = await coolifyFetch<CoolifyService>(input.target, \"/services\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tproject_uuid: project.uuid,\n\n\t\t\t\t\t\tserver_uuid: server.uuid,\n\n\t\t\t\t\t\tenvironment_uuid: env.uuid,\n\n\t\t\t\t\t\tenvironment_name: env.name,\n\n\t\t\t\t\t\tdocker_compose_raw: composeYaml,\n\n\t\t\t\t\t\tname: input.projectName,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst newHash = hashString(composeYaml);\n\t\t\t\tconst oldHash = hashString(service.docker_compose_raw ?? \"\");\n\n\t\t\t\tif (newHash !== oldHash) {\n\t\t\t\t\tawait coolifyFetch(input.target, `/services/${service.uuid}`, {\n\t\t\t\t\t\tmethod: \"PATCH\",\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tdocker_compose_raw: composeYaml,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tresult.composeId = service.uuid;\n\n\t\t\tstep3.status = \"done\";\n\t\t\tstep3.detail = service.uuid;\n\n\t\t\t/* ----------------------------- */\n\t\t\t/* STEP 4: Environment variables */\n\t\t\t/* ----------------------------- */\n\n\t\t\tstep4.status = \"running\";\n\n\t\t\tconst envVars = parseEnvContent(input.envContent);\n\n\t\t\tif (envVars.length) {\n\t\t\t\tawait coolifyFetch(input.target, `/services/${service.uuid}/envs`, {\n\t\t\t\t\tmethod: \"PATCH\",\n\t\t\t\t\tbody: envVars,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tstep4.status = \"done\";\n\t\t\tstep4.detail = `${envVars.length} vars`;\n\n\t\t\t/* ----------------------------- */\n\t\t\t/* STEP 5: Deploy */\n\t\t\t/* ----------------------------- */\n\n\t\t\tstep5.status = \"running\";\n\n\t\t\tconst deploy = await coolifyFetch<{ deployments: CoolifyDeployment[] }>(\n\t\t\t\tinput.target,\n\t\t\t\t`/deploy?uuid=${service.uuid}&force=true`,\n\t\t\t);\n\n\t\t\tstep5.status = \"done\";\n\t\t\tstep5.detail = deploy.deployments?.[0]?.deployment_uuid ?? \"Deployment started\";\n\n\t\t\tresult.success = true;\n\n\t\t\tconst base = input.target.instanceUrl.replace(/\\/+$/, \"\");\n\n\t\t\tresult.dashboardUrl = `${base}/project/${project.uuid}`;\n\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst running = steps.find((s) => s.status === \"running\");\n\n\t\t\tif (running) {\n\t\t\t\trunning.status = \"error\";\n\t\t\t\trunning.detail = err instanceof Error ? err.message : String(err);\n\t\t\t}\n\n\t\t\tresult.error = err instanceof Error ? err.message : String(err);\n\n\t\t\treturn result;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqDA,SAAS,OAAO,QAAsB,MAAc;AAEnD,QAAO,GADM,OAAO,YAAY,QAAQ,QAAQ,GAAG,CACpC,SAAS;;AAGzB,eAAe,aACd,QACA,MACA,UAA+C,EAAE,EACpC;CACb,MAAM,MAAM,MAAM,MAAM,OAAO,QAAQ,KAAK,EAAE;EAC7C,QAAQ,QAAQ,UAAU;EAC1B,SAAS;GACR,gBAAgB;GAChB,eAAe,UAAU,OAAO;GAChC;EACD,MAAM,QAAQ,OAAO,KAAK,UAAU,QAAQ,KAAK,GAAG;EACpD,CAAC;AAEF,KAAI,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I;AAE/D,UAAO"}
@@ -1,22 +1,15 @@
1
1
  import { DeployInput, DeployResult, DeployTarget, PaasDeployer } from "./types.cjs";
2
2
 
3
3
  //#region src/deployers/coolify.d.ts
4
- /**
5
- * Deploys Docker Compose stacks to a Coolify v4 instance.
6
- *
7
- * Deploy flow (5 steps):
8
- * 1. Discover the first available server
9
- * 2. Create a Coolify project
10
- * 3. Create a compose service with the raw docker-compose YAML
11
- * 4. Push .env variables via the bulk env API
12
- * 5. Trigger the deployment
13
- */
14
4
  declare class CoolifyDeployer implements PaasDeployer {
15
5
  readonly name = "Coolify";
16
6
  readonly id = "coolify";
17
7
  testConnection(target: DeployTarget): Promise<{
18
8
  ok: boolean;
19
- error?: string;
9
+ error?: undefined;
10
+ } | {
11
+ ok: boolean;
12
+ error: string;
20
13
  }>;
21
14
  deploy(input: DeployInput): Promise<DeployResult>;
22
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"coolify.d.cts","names":[],"sources":["../../src/deployers/coolify.ts"],"mappings":";;;;;;;;;;;;;cA+Ha,eAAA,YAA2B,YAAA;EAAA,SAC9B,IAAA;EAAA,SACA,EAAA;EAEH,cAAA,CAAe,MAAA,EAAQ,YAAA,GAAe,OAAA;IAAU,EAAA;IAAa,KAAA;EAAA;EAS7D,MAAA,CAAO,KAAA,EAAO,WAAA,GAAc,OAAA,CAAQ,YAAA;AAAA"}
1
+ {"version":3,"file":"coolify.d.cts","names":[],"sources":["../../src/deployers/coolify.ts"],"mappings":";;;cAuIa,eAAA,YAA2B,YAAA;EAAA,SAC9B,IAAA;EAAA,SACA,EAAA;EAEH,cAAA,CAAe,MAAA,EAAQ,YAAA,GAAY,OAAA;;;;;;;EAanC,MAAA,CAAO,KAAA,EAAO,WAAA,GAAc,OAAA,CAAQ,YAAA;AAAA"}
@@ -1,22 +1,15 @@
1
1
  import { DeployInput, DeployResult, DeployTarget, PaasDeployer } from "./types.mjs";
2
2
 
3
3
  //#region src/deployers/coolify.d.ts
4
- /**
5
- * Deploys Docker Compose stacks to a Coolify v4 instance.
6
- *
7
- * Deploy flow (5 steps):
8
- * 1. Discover the first available server
9
- * 2. Create a Coolify project
10
- * 3. Create a compose service with the raw docker-compose YAML
11
- * 4. Push .env variables via the bulk env API
12
- * 5. Trigger the deployment
13
- */
14
4
  declare class CoolifyDeployer implements PaasDeployer {
15
5
  readonly name = "Coolify";
16
6
  readonly id = "coolify";
17
7
  testConnection(target: DeployTarget): Promise<{
18
8
  ok: boolean;
19
- error?: string;
9
+ error?: undefined;
10
+ } | {
11
+ ok: boolean;
12
+ error: string;
20
13
  }>;
21
14
  deploy(input: DeployInput): Promise<DeployResult>;
22
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"coolify.d.mts","names":[],"sources":["../../src/deployers/coolify.ts"],"mappings":";;;;;;;;;;;;;cA+Ha,eAAA,YAA2B,YAAA;EAAA,SAC9B,IAAA;EAAA,SACA,EAAA;EAEH,cAAA,CAAe,MAAA,EAAQ,YAAA,GAAe,OAAA;IAAU,EAAA;IAAa,KAAA;EAAA;EAS7D,MAAA,CAAO,KAAA,EAAO,WAAA,GAAc,OAAA,CAAQ,YAAA;AAAA"}
1
+ {"version":3,"file":"coolify.d.mts","names":[],"sources":["../../src/deployers/coolify.ts"],"mappings":";;;cAuIa,eAAA,YAA2B,YAAA;EAAA,SAC9B,IAAA;EAAA,SACA,EAAA;EAEH,cAAA,CAAe,MAAA,EAAQ,YAAA,GAAY,OAAA;;;;;;;EAanC,MAAA,CAAO,KAAA,EAAO,WAAA,GAAc,OAAA,CAAQ,YAAA;AAAA"}
@@ -1,12 +1,23 @@
1
+ import { sanitizeComposeForPaas } from "./strip-host-ports.mjs";
2
+
1
3
  //#region src/deployers/coolify.ts
2
- /** Build a full Coolify API URL (base + /api/v1 + path). */
4
+ /**
5
+ * Coolify PaaS deployer
6
+ *
7
+ * Deploys Docker Compose stacks via Coolify v4 API
8
+ *
9
+ * Docs:
10
+ * https://coolify.io/docs/api-reference/api
11
+ *
12
+ * Auth:
13
+ * Authorization: Bearer <token>
14
+ *
15
+ * Base path:
16
+ * /api/v1
17
+ */
3
18
  function apiUrl(target, path) {
4
19
  return `${target.instanceUrl.replace(/\/+$/, "")}/api/v1${path}`;
5
20
  }
6
- /**
7
- * Typed fetch wrapper for the Coolify v4 API.
8
- * Handles JSON serialisation, Bearer auth, and error extraction.
9
- */
10
21
  async function coolifyFetch(target, path, options = {}) {
11
22
  const res = await fetch(apiUrl(target, path), {
12
23
  method: options.method ?? "GET",
@@ -29,18 +40,24 @@ async function coolifyFetch(target, path, options = {}) {
29
40
  if (!text) return void 0;
30
41
  return JSON.parse(text);
31
42
  }
32
- /**
33
- * Parse .env content into key-value pairs for Coolify's bulk env API.
34
- */
43
+ function hashString(str) {
44
+ let hash = 0;
45
+ for (let i = 0; i < str.length; i++) {
46
+ hash = (hash << 5) - hash + str.charCodeAt(i);
47
+ hash |= 0;
48
+ }
49
+ return hash;
50
+ }
35
51
  function parseEnvContent(envContent) {
52
+ if (!envContent) return [];
36
53
  const result = [];
37
54
  for (const line of envContent.split("\n")) {
38
55
  const trimmed = line.trim();
39
56
  if (!trimmed || trimmed.startsWith("#")) continue;
40
- const eqIdx = trimmed.indexOf("=");
41
- if (eqIdx <= 0) continue;
42
- const key = trimmed.slice(0, eqIdx);
43
- const value = trimmed.slice(eqIdx + 1);
57
+ const idx = trimmed.indexOf("=");
58
+ if (idx <= 0) continue;
59
+ const key = trimmed.slice(0, idx);
60
+ const value = trimmed.slice(idx + 1);
44
61
  result.push({
45
62
  key,
46
63
  value,
@@ -51,16 +68,6 @@ function parseEnvContent(envContent) {
51
68
  }
52
69
  return result;
53
70
  }
54
- /**
55
- * Deploys Docker Compose stacks to a Coolify v4 instance.
56
- *
57
- * Deploy flow (5 steps):
58
- * 1. Discover the first available server
59
- * 2. Create a Coolify project
60
- * 3. Create a compose service with the raw docker-compose YAML
61
- * 4. Push .env variables via the bulk env API
62
- * 5. Trigger the deployment
63
- */
64
71
  var CoolifyDeployer = class {
65
72
  name = "Coolify";
66
73
  id = "coolify";
@@ -81,15 +88,15 @@ var CoolifyDeployer = class {
81
88
  status: "pending"
82
89
  };
83
90
  const step2 = {
84
- step: "Create project",
91
+ step: "Find or create project",
85
92
  status: "pending"
86
93
  };
87
94
  const step3 = {
88
- step: "Create compose service",
95
+ step: "Find or create service",
89
96
  status: "pending"
90
97
  };
91
98
  const step4 = {
92
- step: "Set environment variables",
99
+ step: "Update environment variables",
93
100
  status: "pending"
94
101
  };
95
102
  const step5 = {
@@ -107,68 +114,73 @@ var CoolifyDeployer = class {
107
114
  success: false,
108
115
  steps
109
116
  };
117
+ const composeYaml = sanitizeComposeForPaas(input.composeYaml);
110
118
  try {
111
119
  step1.status = "running";
112
120
  const servers = await coolifyFetch(input.target, "/servers");
113
- if (!servers || servers.length === 0) throw new Error("No servers found in Coolify instance");
121
+ if (!servers.length) throw new Error("No Coolify servers available");
114
122
  const server = servers[0];
115
123
  step1.status = "done";
116
- step1.detail = `Server: ${server.name} (${server.ip})`;
124
+ step1.detail = `${server.name} (${server.ip})`;
117
125
  step2.status = "running";
118
- const project = await coolifyFetch(input.target, "/projects", {
126
+ let project = (await coolifyFetch(input.target, "/projects")).find((p) => p.name === input.projectName);
127
+ if (!project) project = await coolifyFetch(input.target, "/projects", {
119
128
  method: "POST",
120
129
  body: {
121
130
  name: input.projectName,
122
- description: input.description ?? `OpenClaw stack: ${input.projectName}`
131
+ description: input.description ?? `Stack ${input.projectName}`
123
132
  }
124
133
  });
125
134
  result.projectId = project.uuid;
126
135
  step2.status = "done";
127
- step2.detail = `Project: ${project.uuid}`;
136
+ step2.detail = project.uuid;
128
137
  const projectDetail = await coolifyFetch(input.target, `/projects/${project.uuid}`);
129
- const envUuid = projectDetail.environments?.[0]?.uuid;
130
- const envName = projectDetail.environments?.[0]?.name ?? "production";
131
- if (!envUuid) throw new Error("No default environment found in project");
138
+ const env = projectDetail.environments?.find((e) => e.name === "production") ?? projectDetail.environments?.[0];
139
+ if (!env) throw new Error("No environment found");
132
140
  step3.status = "running";
133
- const service = await coolifyFetch(input.target, "/services", {
141
+ let service = (await coolifyFetch(input.target, `/projects/${project.uuid}/services`)).find((s) => s.name === input.projectName);
142
+ if (!service) service = await coolifyFetch(input.target, "/services", {
134
143
  method: "POST",
135
144
  body: {
136
145
  project_uuid: project.uuid,
137
146
  server_uuid: server.uuid,
138
- environment_name: envName,
139
- environment_uuid: envUuid,
140
- docker_compose_raw: input.composeYaml,
141
- name: input.projectName,
142
- description: input.description ?? "Deployed via OpenClaw web builder",
143
- instant_deploy: false
147
+ environment_uuid: env.uuid,
148
+ environment_name: env.name,
149
+ docker_compose_raw: composeYaml,
150
+ name: input.projectName
144
151
  }
145
152
  });
153
+ else if (hashString(composeYaml) !== hashString(service.docker_compose_raw ?? "")) await coolifyFetch(input.target, `/services/${service.uuid}`, {
154
+ method: "PATCH",
155
+ body: { docker_compose_raw: composeYaml }
156
+ });
146
157
  result.composeId = service.uuid;
147
158
  step3.status = "done";
148
- step3.detail = `Service: ${service.uuid}`;
159
+ step3.detail = service.uuid;
149
160
  step4.status = "running";
150
161
  const envVars = parseEnvContent(input.envContent);
151
- if (envVars.length > 0) await coolifyFetch(input.target, `/services/${service.uuid}/envs`, {
162
+ if (envVars.length) await coolifyFetch(input.target, `/services/${service.uuid}/envs`, {
152
163
  method: "PATCH",
153
164
  body: envVars
154
165
  });
155
166
  step4.status = "done";
156
- step4.detail = `${envVars.length} variables set`;
167
+ step4.detail = `${envVars.length} vars`;
157
168
  step5.status = "running";
158
- const deployments = await coolifyFetch(input.target, `/deploy?uuid=${service.uuid}&force=true`);
169
+ const deploy = await coolifyFetch(input.target, `/deploy?uuid=${service.uuid}&force=true`);
159
170
  step5.status = "done";
160
- step5.detail = deployments?.deployments?.[0]?.deployment_uuid ?? "Deployment triggered";
171
+ step5.detail = deploy.deployments?.[0]?.deployment_uuid ?? "Deployment started";
161
172
  result.success = true;
162
173
  result.dashboardUrl = `${input.target.instanceUrl.replace(/\/+$/, "")}/project/${project.uuid}`;
174
+ return result;
163
175
  } catch (err) {
164
- const failedStep = steps.find((s) => s.status === "running");
165
- if (failedStep) {
166
- failedStep.status = "error";
167
- failedStep.detail = err instanceof Error ? err.message : String(err);
176
+ const running = steps.find((s) => s.status === "running");
177
+ if (running) {
178
+ running.status = "error";
179
+ running.detail = err instanceof Error ? err.message : String(err);
168
180
  }
169
181
  result.error = err instanceof Error ? err.message : String(err);
182
+ return result;
170
183
  }
171
- return result;
172
184
  }
173
185
  };
174
186
 
@@ -1 +1 @@
1
- {"version":3,"file":"coolify.mjs","names":[],"sources":["../../src/deployers/coolify.ts"],"sourcesContent":["/**\n * Coolify PaaS deployer — deploys Docker Compose stacks via the Coolify v4 REST API.\n *\n * API docs: https://coolify.io/docs/api-reference/api/\n * Auth: Authorization: Bearer <token>\n * Base path: /api/v1\n */\n\nimport type { DeployInput, DeployResult, DeployStep, DeployTarget, PaasDeployer } from \"./types.js\";\n\n/** Shape returned by Coolify's project endpoints. */\ninterface CoolifyProject {\n\tuuid: string;\n\tname: string;\n\tenvironments?: { uuid: string; name: string }[];\n}\n\n/** Shape returned by Coolify's server listing. */\ninterface CoolifyServer {\n\tuuid: string;\n\tname: string;\n\tip: string;\n}\n\n/** Shape returned when creating a Coolify service (compose stack). */\ninterface CoolifyService {\n\tuuid: string;\n}\n\n/** Shape returned by Coolify's deploy trigger endpoint. */\ninterface CoolifyDeployment {\n\tmessage: string;\n\tresource_uuid: string;\n\tdeployment_uuid: string;\n}\n\n/** Build a full Coolify API URL (base + /api/v1 + path). */\nfunction apiUrl(target: DeployTarget, path: string): string {\n\tconst base = target.instanceUrl.replace(/\\/+$/, \"\");\n\treturn `${base}/api/v1${path}`;\n}\n\n/**\n * Typed fetch wrapper for the Coolify v4 API.\n * Handles JSON serialisation, Bearer auth, and error extraction.\n */\nasync function coolifyFetch<T>(\n\ttarget: DeployTarget,\n\tpath: string,\n\toptions: { method?: string; body?: unknown } = {},\n): Promise<T> {\n\tconst res = await fetch(apiUrl(target, path), {\n\t\tmethod: options.method ?? \"GET\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t\tAuthorization: `Bearer ${target.apiKey}`,\n\t\t},\n\t\tbody: options.body ? JSON.stringify(options.body) : undefined,\n\t});\n\n\tif (!res.ok) {\n\t\tconst text = await res.text().catch(() => \"\");\n\t\tlet detail = text;\n\t\ttry {\n\t\t\tconst json = JSON.parse(text);\n\t\t\tdetail = json.message || json.error || text;\n\t\t} catch {\n\t\t\t// use raw text\n\t\t}\n\t\tthrow new Error(`Coolify API ${res.status}: ${detail}`);\n\t}\n\n\tconst text = await res.text();\n\tif (!text) return undefined as T;\n\treturn JSON.parse(text) as T;\n}\n\n/**\n * Parse .env content into key-value pairs for Coolify's bulk env API.\n */\nfunction parseEnvContent(envContent: string): {\n\tkey: string;\n\tvalue: string;\n\tis_preview: boolean;\n\tis_build_time: boolean;\n\tis_literal: boolean;\n}[] {\n\tconst result: {\n\t\tkey: string;\n\t\tvalue: string;\n\t\tis_preview: boolean;\n\t\tis_build_time: boolean;\n\t\tis_literal: boolean;\n\t}[] = [];\n\n\tfor (const line of envContent.split(\"\\n\")) {\n\t\tconst trimmed = line.trim();\n\t\tif (!trimmed || trimmed.startsWith(\"#\")) continue;\n\n\t\tconst eqIdx = trimmed.indexOf(\"=\");\n\t\tif (eqIdx <= 0) continue;\n\n\t\tconst key = trimmed.slice(0, eqIdx);\n\t\tconst value = trimmed.slice(eqIdx + 1);\n\n\t\tresult.push({\n\t\t\tkey,\n\t\t\tvalue,\n\t\t\tis_preview: false,\n\t\t\tis_build_time: false,\n\t\t\tis_literal: true,\n\t\t});\n\t}\n\n\treturn result;\n}\n\n/**\n * Deploys Docker Compose stacks to a Coolify v4 instance.\n *\n * Deploy flow (5 steps):\n * 1. Discover the first available server\n * 2. Create a Coolify project\n * 3. Create a compose service with the raw docker-compose YAML\n * 4. Push .env variables via the bulk env API\n * 5. Trigger the deployment\n */\nexport class CoolifyDeployer implements PaasDeployer {\n\treadonly name = \"Coolify\";\n\treadonly id = \"coolify\";\n\n\tasync testConnection(target: DeployTarget): Promise<{ ok: boolean; error?: string }> {\n\t\ttry {\n\t\t\tawait coolifyFetch<unknown>(target, \"/version\");\n\t\t\treturn { ok: true };\n\t\t} catch (err) {\n\t\t\treturn { ok: false, error: err instanceof Error ? err.message : String(err) };\n\t\t}\n\t}\n\n\tasync deploy(input: DeployInput): Promise<DeployResult> {\n\t\tconst step1: DeployStep = { step: \"Discover server\", status: \"pending\" };\n\t\tconst step2: DeployStep = { step: \"Create project\", status: \"pending\" };\n\t\tconst step3: DeployStep = { step: \"Create compose service\", status: \"pending\" };\n\t\tconst step4: DeployStep = { step: \"Set environment variables\", status: \"pending\" };\n\t\tconst step5: DeployStep = { step: \"Trigger deployment\", status: \"pending\" };\n\t\tconst steps: DeployStep[] = [step1, step2, step3, step4, step5];\n\n\t\tconst result: DeployResult = { success: false, steps };\n\n\t\ttry {\n\t\t\t// Step 1: Discover default server\n\t\t\tstep1.status = \"running\";\n\t\t\tconst servers = await coolifyFetch<CoolifyServer[]>(input.target, \"/servers\");\n\t\t\tif (!servers || servers.length === 0) {\n\t\t\t\tthrow new Error(\"No servers found in Coolify instance\");\n\t\t\t}\n\t\t\tconst server = servers[0] as CoolifyServer;\n\t\t\tstep1.status = \"done\";\n\t\t\tstep1.detail = `Server: ${server.name} (${server.ip})`;\n\n\t\t\t// Step 2: Create project\n\t\t\tstep2.status = \"running\";\n\t\t\tconst project = await coolifyFetch<CoolifyProject>(input.target, \"/projects\", {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: {\n\t\t\t\t\tname: input.projectName,\n\t\t\t\t\tdescription: input.description ?? `OpenClaw stack: ${input.projectName}`,\n\t\t\t\t},\n\t\t\t});\n\t\t\tresult.projectId = project.uuid;\n\t\t\tstep2.status = \"done\";\n\t\t\tstep2.detail = `Project: ${project.uuid}`;\n\n\t\t\t// Get the default environment\n\t\t\tconst projectDetail = await coolifyFetch<CoolifyProject>(\n\t\t\t\tinput.target,\n\t\t\t\t`/projects/${project.uuid}`,\n\t\t\t);\n\t\t\tconst envUuid = projectDetail.environments?.[0]?.uuid;\n\t\t\tconst envName = projectDetail.environments?.[0]?.name ?? \"production\";\n\t\t\tif (!envUuid) {\n\t\t\t\tthrow new Error(\"No default environment found in project\");\n\t\t\t}\n\n\t\t\t// Step 3: Create compose service with docker_compose_raw\n\t\t\tstep3.status = \"running\";\n\t\t\tconst service = await coolifyFetch<CoolifyService>(input.target, \"/services\", {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: {\n\t\t\t\t\tproject_uuid: project.uuid,\n\t\t\t\t\tserver_uuid: server.uuid,\n\t\t\t\t\tenvironment_name: envName,\n\t\t\t\t\tenvironment_uuid: envUuid,\n\t\t\t\t\tdocker_compose_raw: input.composeYaml,\n\t\t\t\t\tname: input.projectName,\n\t\t\t\t\tdescription: input.description ?? \"Deployed via OpenClaw web builder\",\n\t\t\t\t\tinstant_deploy: false,\n\t\t\t\t},\n\t\t\t});\n\t\t\tresult.composeId = service.uuid;\n\t\t\tstep3.status = \"done\";\n\t\t\tstep3.detail = `Service: ${service.uuid}`;\n\n\t\t\t// Step 4: Set environment variables\n\t\t\tstep4.status = \"running\";\n\t\t\tconst envVars = parseEnvContent(input.envContent);\n\t\t\tif (envVars.length > 0) {\n\t\t\t\tawait coolifyFetch(input.target, `/services/${service.uuid}/envs`, {\n\t\t\t\t\tmethod: \"PATCH\",\n\t\t\t\t\tbody: envVars,\n\t\t\t\t});\n\t\t\t}\n\t\t\tstep4.status = \"done\";\n\t\t\tstep4.detail = `${envVars.length} variables set`;\n\n\t\t\t// Step 5: Trigger deployment\n\t\t\tstep5.status = \"running\";\n\t\t\tconst deployments = await coolifyFetch<{ deployments: CoolifyDeployment[] }>(\n\t\t\t\tinput.target,\n\t\t\t\t`/deploy?uuid=${service.uuid}&force=true`,\n\t\t\t);\n\t\t\tstep5.status = \"done\";\n\t\t\tstep5.detail = deployments?.deployments?.[0]?.deployment_uuid ?? \"Deployment triggered\";\n\n\t\t\tresult.success = true;\n\t\t\tconst base = input.target.instanceUrl.replace(/\\/+$/, \"\");\n\t\t\tresult.dashboardUrl = `${base}/project/${project.uuid}`;\n\t\t} catch (err) {\n\t\t\tconst failedStep = steps.find((s) => s.status === \"running\");\n\t\t\tif (failedStep) {\n\t\t\t\tfailedStep.status = \"error\";\n\t\t\t\tfailedStep.detail = err instanceof Error ? err.message : String(err);\n\t\t\t}\n\t\t\tresult.error = err instanceof Error ? err.message : String(err);\n\t\t}\n\n\t\treturn result;\n\t}\n}\n"],"mappings":";;AAqCA,SAAS,OAAO,QAAsB,MAAsB;AAE3D,QAAO,GADM,OAAO,YAAY,QAAQ,QAAQ,GAAG,CACpC,SAAS;;;;;;AAOzB,eAAe,aACd,QACA,MACA,UAA+C,EAAE,EACpC;CACb,MAAM,MAAM,MAAM,MAAM,OAAO,QAAQ,KAAK,EAAE;EAC7C,QAAQ,QAAQ,UAAU;EAC1B,SAAS;GACR,gBAAgB;GAChB,eAAe,UAAU,OAAO;GAChC;EACD,MAAM,QAAQ,OAAO,KAAK,UAAU,QAAQ,KAAK,GAAG;EACpD,CAAC;AAEF,KAAI,CAAC,IAAI,IAAI;EACZ,MAAM,OAAO,MAAM,IAAI,MAAM,CAAC,YAAY,GAAG;EAC7C,IAAI,SAAS;AACb,MAAI;GACH,MAAM,OAAO,KAAK,MAAM,KAAK;AAC7B,YAAS,KAAK,WAAW,KAAK,SAAS;UAChC;AAGR,QAAM,IAAI,MAAM,eAAe,IAAI,OAAO,IAAI,SAAS;;CAGxD,MAAM,OAAO,MAAM,IAAI,MAAM;AAC7B,KAAI,CAAC,KAAM,QAAO;AAClB,QAAO,KAAK,MAAM,KAAK;;;;;AAMxB,SAAS,gBAAgB,YAMrB;CACH,MAAM,SAMA,EAAE;AAER,MAAK,MAAM,QAAQ,WAAW,MAAM,KAAK,EAAE;EAC1C,MAAM,UAAU,KAAK,MAAM;AAC3B,MAAI,C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AAM,EAAE,WAAW,UAAU;AAC5D,OAAI,YAAY;AACf,eAAW,SAAS;AACpB,eAAW,SAAS,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI;;AAErE,UAAO,QAAQ,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI;;AAGhE,SAAO"}
1
+ {"version":3,"file":"coolify.mjs","names":[],"sources":["../../src/deployers/coolify.ts"],"sourcesContent":["/**\n * Coolify PaaS deployer\n *\n * Deploys Docker Compose stacks via Coolify v4 API\n *\n * Docs:\n * https://coolify.io/docs/api-reference/api\n *\n * Auth:\n * Authorization: Bearer <token>\n *\n * Base path:\n * /api/v1\n */\n\nimport { sanitizeComposeForPaas } from \"./strip-host-ports.js\";\nimport type { DeployInput, DeployResult, DeployStep, DeployTarget, PaasDeployer } from \"./types.js\";\n\n/* ----------------------------- */\n/* Coolify API Types */\n/* ----------------------------- */\n\ninterface CoolifyProject {\n\tuuid: string;\n\tname: string;\n\tenvironments?: {\n\t\tuuid: string;\n\t\tname: string;\n\t}[];\n}\n\ninterface CoolifyServer {\n\tuuid: string;\n\tname: string;\n\tip: string;\n}\n\ninterface CoolifyService {\n\tuuid: string;\n\tname: string;\n\tdocker_compose_raw?: string;\n}\n\ninterface CoolifyDeployment {\n\tmessage: string;\n\tresource_uuid: string;\n\tdeployment_uuid: string;\n}\n\n/* ----------------------------- */\n/* Utilities */\n/* ----------------------------- */\n\nfunction apiUrl(target: DeployTarget, path: string) {\n\tconst base = target.instanceUrl.replace(/\\/+$/, \"\");\n\treturn `${base}/api/v1${path}`;\n}\n\nasync function coolifyFetch<T>(\n\ttarget: DeployTarget,\n\tpath: string,\n\toptions: { method?: string; body?: unknown } = {},\n): Promise<T> {\n\tconst res = await fetch(apiUrl(target, path), {\n\t\tmethod: options.method ?? \"GET\",\n\t\theaders: {\n\t\t\t\"Content-Type\": \"application/json\",\n\t\t\tAuthorization: `Bearer ${target.apiKey}`,\n\t\t},\n\t\tbody: options.body ? JSON.stringify(options.body) : undefined,\n\t});\n\n\tif (!res.ok) {\n\t\tconst text = await res.text().catch(() => \"\");\n\t\tlet detail = text;\n\n\t\ttry {\n\t\t\tconst json = JSON.parse(text);\n\t\t\tdetail = json.message || json.error || text;\n\t\t} catch {}\n\n\t\tthrow new Error(`Coolify API ${res.status}: ${detail}`);\n\t}\n\n\tconst text = await res.text();\n\n\tif (!text) return undefined as T;\n\n\treturn JSON.parse(text);\n}\n\nfunction hashString(str: string) {\n\tlet hash = 0;\n\n\tfor (let i = 0; i < str.length; i++) {\n\t\thash = (hash << 5) - hash + str.charCodeAt(i);\n\t\thash |= 0;\n\t}\n\n\treturn hash;\n}\n\nfunction parseEnvContent(envContent?: string) {\n\tif (!envContent) return [];\n\n\tconst result = [];\n\n\tfor (const line of envContent.split(\"\\n\")) {\n\t\tconst trimmed = line.trim();\n\n\t\tif (!trimmed || trimmed.startsWith(\"#\")) continue;\n\n\t\tconst idx = trimmed.indexOf(\"=\");\n\n\t\tif (idx <= 0) continue;\n\n\t\tconst key = trimmed.slice(0, idx);\n\t\tconst value = trimmed.slice(idx + 1);\n\n\t\tresult.push({\n\t\t\tkey,\n\t\t\tvalue,\n\t\t\tis_preview: false,\n\t\t\tis_build_time: false,\n\t\t\tis_literal: true,\n\t\t});\n\t}\n\n\treturn result;\n}\n\n/* ----------------------------- */\n/* Coolify Deployer */\n/* ----------------------------- */\n\nexport class CoolifyDeployer implements PaasDeployer {\n\treadonly name = \"Coolify\";\n\treadonly id = \"coolify\";\n\n\tasync testConnection(target: DeployTarget) {\n\t\ttry {\n\t\t\tawait coolifyFetch(target, \"/version\");\n\n\t\t\treturn { ok: true };\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\terror: err instanceof Error ? err.message : String(err),\n\t\t\t};\n\t\t}\n\t}\n\n\tasync deploy(input: DeployInput): Promise<DeployResult> {\n\t\tconst step1: DeployStep = { step: \"Discover server\", status: \"pending\" };\n\t\tconst step2: DeployStep = {\n\t\t\tstep: \"Find or create project\",\n\t\t\tstatus: \"pending\",\n\t\t};\n\t\tconst step3: DeployStep = {\n\t\t\tstep: \"Find or create service\",\n\t\t\tstatus: \"pending\",\n\t\t};\n\t\tconst step4: DeployStep = {\n\t\t\tstep: \"Update environment variables\",\n\t\t\tstatus: \"pending\",\n\t\t};\n\t\tconst step5: DeployStep = { step: \"Trigger deployment\", status: \"pending\" };\n\t\tconst steps: DeployStep[] = [step1, step2, step3, step4, step5];\n\n\t\tconst result: DeployResult = { success: false, steps };\n\n\t\t// Strip host port bindings — Coolify routes via Traefik,\n\t\t// so host ports are unnecessary and cause \"port already allocated\" errors.\n\t\tconst composeYaml = sanitizeComposeForPaas(input.composeYaml);\n\n\t\ttry {\n\t\t\t/* ----------------------------- */\n\t\t\t/* STEP 1: Discover server */\n\t\t\t/* ----------------------------- */\n\n\t\t\tstep1.status = \"running\";\n\n\t\t\tconst servers = await coolifyFetch<CoolifyServer[]>(input.target, \"/servers\");\n\n\t\t\tif (!servers.length) {\n\t\t\t\tthrow new Error(\"No Coolify servers available\");\n\t\t\t}\n\n\t\t\tconst server = servers[0]!;\n\n\t\t\tstep1.status = \"done\";\n\t\t\tstep1.detail = `${server.name} (${server.ip})`;\n\n\t\t\t/* ----------------------------- */\n\t\t\t/* STEP 2: Find or create project */\n\t\t\t/* ----------------------------- */\n\n\t\t\tstep2.status = \"running\";\n\n\t\t\tconst projects = await coolifyFetch<CoolifyProject[]>(input.target, \"/projects\");\n\n\t\t\tlet project = projects.find((p) => p.name === input.projectName);\n\n\t\t\tif (!project) {\n\t\t\t\tproject = await coolifyFetch<CoolifyProject>(input.target, \"/projects\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tname: input.projectName,\n\t\t\t\t\t\tdescription: input.description ?? `Stack ${input.projectName}`,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tresult.projectId = project.uuid;\n\n\t\t\tstep2.status = \"done\";\n\t\t\tstep2.detail = project.uuid;\n\n\t\t\t/* ----------------------------- */\n\t\t\t/* Find environment */\n\t\t\t/* ----------------------------- */\n\n\t\t\tconst projectDetail = await coolifyFetch<CoolifyProject>(\n\t\t\t\tinput.target,\n\t\t\t\t`/projects/${project.uuid}`,\n\t\t\t);\n\n\t\t\tconst env =\n\t\t\t\tprojectDetail.environments?.find((e) => e.name === \"production\") ??\n\t\t\t\tprojectDetail.environments?.[0];\n\n\t\t\tif (!env) throw new Error(\"No environment found\");\n\n\t\t\t/* ----------------------------- */\n\t\t\t/* STEP 3: Find or create service */\n\t\t\t/* ----------------------------- */\n\n\t\t\tstep3.status = \"running\";\n\n\t\t\tconst services = await coolifyFetch<CoolifyService[]>(\n\t\t\t\tinput.target,\n\t\t\t\t`/projects/${project.uuid}/services`,\n\t\t\t);\n\n\t\t\tlet service = services.find((s) => s.name === input.projectName);\n\n\t\t\tif (!service) {\n\t\t\t\tservice = await coolifyFetch<CoolifyService>(input.target, \"/services\", {\n\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\tbody: {\n\t\t\t\t\t\tproject_uuid: project.uuid,\n\n\t\t\t\t\t\tserver_uuid: server.uuid,\n\n\t\t\t\t\t\tenvironment_uuid: env.uuid,\n\n\t\t\t\t\t\tenvironment_name: env.name,\n\n\t\t\t\t\t\tdocker_compose_raw: composeYaml,\n\n\t\t\t\t\t\tname: input.projectName,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst newHash = hashString(composeYaml);\n\t\t\t\tconst oldHash = hashString(service.docker_compose_raw ?? \"\");\n\n\t\t\t\tif (newHash !== oldHash) {\n\t\t\t\t\tawait coolifyFetch(input.target, `/services/${service.uuid}`, {\n\t\t\t\t\t\tmethod: \"PATCH\",\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tdocker_compose_raw: composeYaml,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tresult.composeId = service.uuid;\n\n\t\t\tstep3.status = \"done\";\n\t\t\tstep3.detail = service.uuid;\n\n\t\t\t/* ----------------------------- */\n\t\t\t/* STEP 4: Environment variables */\n\t\t\t/* ----------------------------- */\n\n\t\t\tstep4.status = \"running\";\n\n\t\t\tconst envVars = parseEnvContent(input.envContent);\n\n\t\t\tif (envVars.length) {\n\t\t\t\tawait coolifyFetch(input.target, `/services/${service.uuid}/envs`, {\n\t\t\t\t\tmethod: \"PATCH\",\n\t\t\t\t\tbody: envVars,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tstep4.status = \"done\";\n\t\t\tstep4.detail = `${envVars.length} vars`;\n\n\t\t\t/* ----------------------------- */\n\t\t\t/* STEP 5: Deploy */\n\t\t\t/* ----------------------------- */\n\n\t\t\tstep5.status = \"running\";\n\n\t\t\tconst deploy = await coolifyFetch<{ deployments: CoolifyDeployment[] }>(\n\t\t\t\tinput.target,\n\t\t\t\t`/deploy?uuid=${service.uuid}&force=true`,\n\t\t\t);\n\n\t\t\tstep5.status = \"done\";\n\t\t\tstep5.detail = deploy.deployments?.[0]?.deployment_uuid ?? \"Deployment started\";\n\n\t\t\tresult.success = true;\n\n\t\t\tconst base = input.target.instanceUrl.replace(/\\/+$/, \"\");\n\n\t\t\tresult.dashboardUrl = `${base}/project/${project.uuid}`;\n\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst running = steps.find((s) => s.status === \"running\");\n\n\t\t\tif (running) {\n\t\t\t\trunning.status = \"error\";\n\t\t\t\trunning.detail = err instanceof Error ? err.message : String(err);\n\t\t\t}\n\n\t\t\tresult.error = err instanceof Error ? err.message : String(err);\n\n\t\t\treturn result;\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqDA,SAAS,OAAO,QAAsB,MAAc;AAEnD,QAAO,GADM,OAAO,YAAY,QAAQ,QAAQ,GAAG,CACpC,SAAS;;AAGzB,eAAe,aACd,QACA,MACA,UAA+C,EAAE,EACpC;CACb,MAAM,MAAM,MAAM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