fix(abiba): backport EADDRINUSE handler + private message to format to TS source
CI / validate (pull_request) Failing after 1s
CI / validate (pull_request) Failing after 1s
This commit is contained in:
Generated
+1
@@ -2668,6 +2668,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
"tsserver": "bin/tsserver"
|
"tsserver": "bin/tsserver"
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
|
import type { ExtensionAPI, ExtensionContext } from "@mariozechner/pi-coding-agent";
|
||||||
import { createClient } from "zulip-js";
|
import { createClient } from "zulip-js";
|
||||||
import { spawnSync } from "node:child_process";
|
import { spawnSync } from "node:child_process";
|
||||||
|
|
||||||
import http from "node:http";
|
import http from "node:http";
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
@@ -201,7 +202,8 @@ async function createZulipQueue(config: ZulipConfig) {
|
|||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
const formBody = new URLSearchParams();
|
const formBody = new URLSearchParams();
|
||||||
formBody.append("type", params.type);
|
formBody.append("type", params.type);
|
||||||
formBody.append("to", String(params.to));
|
// Zulip API: private messages need JSON array of user IDs, stream messages accept string/number
|
||||||
|
formBody.append("to", params.type === "private" ? JSON.stringify([params.to]) : String(params.to));
|
||||||
if (params.subject) formBody.append("subject", params.subject);
|
if (params.subject) formBody.append("subject", params.subject);
|
||||||
formBody.append("content", params.content);
|
formBody.append("content", params.content);
|
||||||
|
|
||||||
@@ -259,6 +261,14 @@ function startHealthServer(port: number, getState: () => Record<string, unknown>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
server.on("error", (err: any) => {
|
||||||
|
if (err.code === "EADDRINUSE") {
|
||||||
|
console.warn(`[zulip-ext] Port :${port} already in use — skipping health endpoint`);
|
||||||
|
} else {
|
||||||
|
console.error(`[zulip-ext] Health server error:`, err.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
server.listen(port, "127.0.0.1", () => {
|
server.listen(port, "127.0.0.1", () => {
|
||||||
console.log(`[zulip-ext] Health endpoint on :${port}`);
|
console.log(`[zulip-ext] Health endpoint on :${port}`);
|
||||||
});
|
});
|
||||||
@@ -597,7 +607,7 @@ export default async function (pi: ExtensionAPI) {
|
|||||||
// Usage: /zulip-send-test "targetEmail" "message body"
|
// Usage: /zulip-send-test "targetEmail" "message body"
|
||||||
pi.registerCommand("zulip-send-test", {
|
pi.registerCommand("zulip-send-test", {
|
||||||
description: "Send a test message to Zulip user: /zulip-send-test <email> <message>",
|
description: "Send a test message to Zulip user: /zulip-send-test <email> <message>",
|
||||||
handler: async (args: string, ctx: ExtensionCommandContext) => {
|
handler: async (args: string, ctx: ExtensionContext) => {
|
||||||
const parts = args.trim().match(/^([^\s]+)\s+(.+)$/);
|
const parts = args.trim().match(/^([^\s]+)\s+(.+)$/);
|
||||||
const targetEmail = parts?.[1] ?? config.agent.owner_email;
|
const targetEmail = parts?.[1] ?? config.agent.owner_email;
|
||||||
const message = parts?.[2] ?? "Test message from pi Zulip extension";
|
const message = parts?.[2] ?? "Test message from pi Zulip extension";
|
||||||
|
|||||||
Reference in New Issue
Block a user