create-loopengine 0.1.55 → 0.1.57

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-loopengine",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
4
4
  "description": "Scaffold a new loopengine agent project — a runnable HTTP server with one example agent, in your own repo.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -2696,7 +2696,20 @@ async function handleSlackInteraction(req: IncomingMessage, res: ServerResponse,
2696
2696
  }
2697
2697
  }
2698
2698
 
2699
+ // Set once shutdown() starts, so /healthz turns 503 while the server
2700
+ // drains and a router or load balancer stops sending it new requests.
2701
+ let shuttingDown = false
2702
+
2699
2703
  const server = createServer(async (req, res) => {
2704
+ // Liveness for whatever runs this server (Docker, Fly, a router): no
2705
+ // login, nothing about the server in the answer, and not counted as
2706
+ // activity, so polling it never keeps an idle server awake.
2707
+ if ((req.method === 'GET' || req.method === 'HEAD') && (req.url ?? '/').split('?')[0] === '/healthz') {
2708
+ res.writeHead(shuttingDown ? 503 : 200, { 'content-type': 'application/json', 'cache-control': 'no-store' })
2709
+ res.end(req.method === 'HEAD' ? undefined : JSON.stringify({ ok: !shuttingDown }))
2710
+ return
2711
+ }
2712
+
2700
2713
  const slackHookMatch = req.method === 'POST' && (req.url ?? '/').split('?')[0].match(/^\/hooks\/slack\/([^/]+)$/)
2701
2714
  if (slackHookMatch) {
2702
2715
  try {
@@ -3334,6 +3347,7 @@ async function warmAgentTools(): Promise<void> {
3334
3347
  // process restart, just this one process's own event loop.
3335
3348
  async function shutdown() {
3336
3349
  console.log('[loopengine] shutting down — draining in-flight requests...')
3350
+ shuttingDown = true
3337
3351
  scheduler.stop()
3338
3352
  const graceMs = Number(process.env.LOOPENGINE_SHUTDOWN_GRACE_MS ?? 30000)
3339
3353
  const closed = new Promise<void>((resolve) => server.close(() => resolve()))
@@ -9,7 +9,7 @@
9
9
  "cli": "tsx adapters/cli.ts"
10
10
  },
11
11
  "dependencies": {
12
- "loopengine": "^0.1.70",
12
+ "loopengine": "^0.1.71",
13
13
  "actauth": "^0.0.12"
14
14
  },
15
15
  "devDependencies": {