ework-web 0.10.5 → 0.10.7
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/package.json +1 -1
- package/src/daemon-deploy.ts +1 -1
- package/src/opencode.ts +2 -1
- package/src/webhooks.ts +21 -1
package/package.json
CHANGED
package/src/daemon-deploy.ts
CHANGED
|
@@ -112,7 +112,7 @@ function buildSetupScript(envBlock: string, daemonPort: number, mysqlHostRaw: st
|
|
|
112
112
|
`EWORK_DAEMON_ENV_EOF`,
|
|
113
113
|
`echo "$DAEMON_ENDPOINT_LINE"; } > ~/.local/share/ework-aio/ework-daemon/.env`,
|
|
114
114
|
`echo "[4/5] starting daemon..."`,
|
|
115
|
-
`ework-aio start daemon`,
|
|
115
|
+
`ework-aio stop daemon 2>/dev/null; sleep 1; ework-aio start daemon`,
|
|
116
116
|
`echo "[5/5] verifying daemon is alive..."`,
|
|
117
117
|
`sleep 3`,
|
|
118
118
|
`curl -sf --max-time 5 http://127.0.0.1:${String(daemonPort)}/api/status 2>/dev/null && echo "DAEMON_ALIVE" || { echo "DAEMON_FAILED: status check failed"; echo "=== daemon log (last 20 lines) ==="; tail -20 ~/.local/share/ework-aio/run/daemon.log 2>/dev/null || echo "(no log)"; exit 1; }`,
|
package/src/opencode.ts
CHANGED
|
@@ -261,7 +261,8 @@ export class RemoteOpencodeClient implements OpencodeClientInterface {
|
|
|
261
261
|
private readonly base: string;
|
|
262
262
|
|
|
263
263
|
constructor(endpoint: string) {
|
|
264
|
-
|
|
264
|
+
const trimmed = endpoint.replace(/\/$/, "");
|
|
265
|
+
this.base = /^https?:\/\//.test(trimmed) ? trimmed : `http://${trimmed}`;
|
|
265
266
|
}
|
|
266
267
|
|
|
267
268
|
async listSessions(limit: number): Promise<SessionListItem[]> {
|
package/src/webhooks.ts
CHANGED
|
@@ -541,6 +541,25 @@ async function recordDelivery(
|
|
|
541
541
|
}
|
|
542
542
|
}
|
|
543
543
|
|
|
544
|
+
async function resolveDeliveryUrl(storedUrl: string): Promise<string> {
|
|
545
|
+
try {
|
|
546
|
+
const { getActiveDaemons } = await import("./coordination");
|
|
547
|
+
const daemons = await getActiveDaemons();
|
|
548
|
+
if (daemons.length === 0) return storedUrl;
|
|
549
|
+
const storedHost = storedUrl.replace(/^https?:\/\//, "").split("/")[0] ?? "";
|
|
550
|
+
const storedMatchesDaemon = daemons.some((d) => {
|
|
551
|
+
const daemonHost = d.endpoint.replace(/^https?:\/\//, "");
|
|
552
|
+
return daemonHost === storedHost;
|
|
553
|
+
});
|
|
554
|
+
if (storedMatchesDaemon) return storedUrl;
|
|
555
|
+
const best = daemons.sort((a, b) => a.id - b.id)[0]!;
|
|
556
|
+
const ep = /^https?:\/\//.test(best.endpoint) ? best.endpoint : `http://${best.endpoint}`;
|
|
557
|
+
return ep.replace(/\/$/, "") + "/webhook/gitea";
|
|
558
|
+
} catch {
|
|
559
|
+
return storedUrl;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
544
563
|
async function deliver(
|
|
545
564
|
webhook: WebhookRow,
|
|
546
565
|
event: WebhookEventName,
|
|
@@ -548,11 +567,12 @@ async function deliver(
|
|
|
548
567
|
): Promise<void> {
|
|
549
568
|
await acquireDeliverySlot();
|
|
550
569
|
try {
|
|
570
|
+
const targetUrl = await resolveDeliveryUrl(webhook.url);
|
|
551
571
|
for (const attempt of RETRY_DELAYS_MS) {
|
|
552
572
|
if (attempt > 0) await Bun.sleep(attempt);
|
|
553
573
|
const deliveryUuid = randomUUID();
|
|
554
574
|
const headers = buildHeaders(event, deliveryUuid, rawBody, webhook.secret);
|
|
555
|
-
const result = await postWithTimeout(
|
|
575
|
+
const result = await postWithTimeout(targetUrl, rawBody, headers);
|
|
556
576
|
const success = result.status !== null && result.status >= 200 && result.status < 300;
|
|
557
577
|
await recordDelivery(webhook.id, event, deliveryUuid, rawBody, result);
|
|
558
578
|
if (success) return;
|