@spinabot/brigade 1.4.0 → 1.5.0

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 (32) hide show
  1. package/README.md +20 -1
  2. package/dist/agents/channels/telegram/adapter.d.ts.map +1 -1
  3. package/dist/agents/channels/telegram/adapter.js +10 -3
  4. package/dist/agents/channels/telegram/adapter.js.map +1 -1
  5. package/dist/agents/channels/telegram/connection.d.ts +10 -0
  6. package/dist/agents/channels/telegram/connection.d.ts.map +1 -1
  7. package/dist/agents/channels/telegram/connection.js +161 -5
  8. package/dist/agents/channels/telegram/connection.js.map +1 -1
  9. package/dist/agents/channels/telegram/format.d.ts +17 -0
  10. package/dist/agents/channels/telegram/format.d.ts.map +1 -1
  11. package/dist/agents/channels/telegram/format.js +36 -0
  12. package/dist/agents/channels/telegram/format.js.map +1 -1
  13. package/dist/agents/channels/telegram/inbound-extras.d.ts +17 -1
  14. package/dist/agents/channels/telegram/inbound-extras.d.ts.map +1 -1
  15. package/dist/agents/channels/telegram/inbound-extras.js +68 -7
  16. package/dist/agents/channels/telegram/inbound-extras.js.map +1 -1
  17. package/dist/agents/channels/telegram/media.d.ts +8 -0
  18. package/dist/agents/channels/telegram/media.d.ts.map +1 -1
  19. package/dist/agents/channels/telegram/media.js +30 -2
  20. package/dist/agents/channels/telegram/media.js.map +1 -1
  21. package/dist/agents/extensions/types.d.ts +11 -0
  22. package/dist/agents/extensions/types.d.ts.map +1 -1
  23. package/dist/agents/extensions/types.js.map +1 -1
  24. package/dist/buildstamp.json +1 -1
  25. package/dist/cli/commands/convex-cmd.d.ts +2 -1
  26. package/dist/cli/commands/convex-cmd.d.ts.map +1 -1
  27. package/dist/cli/commands/convex-cmd.js +79 -6
  28. package/dist/cli/commands/convex-cmd.js.map +1 -1
  29. package/dist/cli/program/build-program.js +1 -1
  30. package/dist/cli/program/build-program.js.map +1 -1
  31. package/package.json +1 -1
  32. package/scripts/convex-dev.mjs +28 -2
@@ -15,7 +15,7 @@
15
15
  // logs/ — backend stderr captures
16
16
 
17
17
  import { spawn } from "node:child_process";
18
- import { mkdirSync, existsSync, writeFileSync, readFileSync } from "node:fs";
18
+ import { mkdirSync, existsSync, writeFileSync, readFileSync, unlinkSync } from "node:fs";
19
19
  import { randomBytes } from "node:crypto";
20
20
  import { createServer } from "node:http";
21
21
  import { readFile, stat } from "node:fs/promises";
@@ -24,7 +24,11 @@ import { fileURLToPath } from "node:url";
24
24
 
25
25
  const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..");
26
26
  const BIN_DIR = join(ROOT, "bin");
27
- const DATA_DIR = join(ROOT, ".convex-data");
27
+ // Honor the data dir the `brigade convex` command resolves + exports, so the
28
+ // pidfile (and all backend state) lands where `brigade convex stop` looks for
29
+ // it — whether launched via the CLI (global install → ~/.brigade/convex/data)
30
+ // or `npm run convex:dev` from a checkout (→ <root>/.convex-data, the default).
31
+ const DATA_DIR = process.env.BRIGADE_CONVEX_DATA_DIR?.trim() || join(ROOT, ".convex-data");
28
32
  const DASHBOARD_DIR = join(BIN_DIR, "dashboard");
29
33
  const BACKEND_BIN = join(BIN_DIR, process.platform === "win32" ? "convex-local-backend.exe" : "convex-local-backend");
30
34
 
@@ -136,6 +140,27 @@ const backend = spawn(BACKEND_BIN, [
136
140
  dbPath,
137
141
  ], { stdio: ["ignore", "pipe", "pipe"] });
138
142
 
143
+ // Record a pidfile so `brigade convex stop` can find and terminate this run.
144
+ // The orchestrator (this process) owns the dashboard server; the backend is
145
+ // its child — stop needs both pids. Removed in shutdown() below.
146
+ const PID_FILE = join(DATA_DIR, "convex.pid");
147
+ writeFileSync(
148
+ PID_FILE,
149
+ JSON.stringify(
150
+ {
151
+ orchestratorPid: process.pid,
152
+ backendPid: backend.pid,
153
+ host: BACKEND_HOST,
154
+ port: BACKEND_PORT,
155
+ sitePort: SITE_PROXY_PORT,
156
+ dashboardPort: DASHBOARD_PORT,
157
+ startedAt: new Date().toISOString(),
158
+ },
159
+ null,
160
+ 2,
161
+ ),
162
+ );
163
+
139
164
  backend.stdout.on("data", (b) => process.stdout.write(`\x1b[90m[backend]\x1b[0m ${b}`));
140
165
  backend.stderr.on("data", (b) => process.stderr.write(`\x1b[90m[backend]\x1b[0m ${b}`));
141
166
  backend.on("exit", (code) => {
@@ -308,6 +333,7 @@ function shutdown(code = 0) {
308
333
  if (shuttingDown) return;
309
334
  shuttingDown = true;
310
335
  console.log(`\n\x1b[36m▌ Stopping...\x1b[0m`);
336
+ try { unlinkSync(PID_FILE); } catch {}
311
337
  try { dashboardServer.close(); } catch {}
312
338
  try { backend.kill("SIGTERM"); } catch {}
313
339
  setTimeout(() => process.exit(code), 500);