kantban-cli 0.1.17 → 0.1.19

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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runGates
3
- } from "./chunk-4IUZAIFL.js";
3
+ } from "./chunk-APZG5K2J.js";
4
4
  import {
5
5
  ClaudeProvider,
6
6
  RalphLoop,
@@ -12,14 +12,14 @@ import {
12
12
  generateMcpConfig,
13
13
  parseJsonFromLlmOutput,
14
14
  parseStuckDetectionResponse
15
- } from "./chunk-4RQDDZLM.js";
15
+ } from "./chunk-D4T7ZUWI.js";
16
16
  import {
17
17
  LoopCheckpointSchema,
18
18
  VerdictSchema,
19
19
  parseGateConfig,
20
20
  parseTimeout,
21
21
  resolveGatesForColumn
22
- } from "./chunk-MN4H5NSU.js";
22
+ } from "./chunk-ZTQJMXJM.js";
23
23
 
24
24
  // src/commands/pipeline.ts
25
25
  import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync3, readFileSync as readFileSync2, unlinkSync as unlinkSync2, existsSync as existsSync2, appendFileSync as appendFileSync2 } from "fs";
@@ -2214,12 +2214,22 @@ var EventQueue = class {
2214
2214
 
2215
2215
  // src/lib/ws-client.ts
2216
2216
  import WebSocket from "ws";
2217
- var PipelineWsClient = class {
2217
+ var PipelineWsClient = class _PipelineWsClient {
2218
2218
  ws = null;
2219
2219
  client;
2220
2220
  options;
2221
2221
  pingTimer = null;
2222
2222
  stopped = false;
2223
+ sendBuffer = [];
2224
+ static CRITICAL_TYPES = /* @__PURE__ */ new Set([
2225
+ "pipeline:session-start",
2226
+ "pipeline:session-end",
2227
+ "pipeline:stopped",
2228
+ "board:subscribe"
2229
+ ]);
2230
+ static BUFFER_MAX = 100;
2231
+ static BUFFER_TTL_MS = 3e4;
2232
+ // 30 seconds
2223
2233
  constructor(client, options) {
2224
2234
  this.client = client;
2225
2235
  this.options = options;
@@ -2239,7 +2249,7 @@ var PipelineWsClient = class {
2239
2249
  }
2240
2250
  this.cleanupPing();
2241
2251
  const { ticket } = await this.client.post("/ws-ticket");
2242
- const wsUrl = this.client.baseUrl.replace(/^http/, "ws") + `/ws?ticket=${ticket}`;
2252
+ const wsUrl = this.client.baseUrl.replace(/^http/, "ws") + `/ws?ticket=${ticket}&clientType=cli`;
2243
2253
  return new Promise((resolve, reject) => {
2244
2254
  let resolved = false;
2245
2255
  this.ws = new WebSocket(wsUrl);
@@ -2253,6 +2263,7 @@ var PipelineWsClient = class {
2253
2263
  if (!subscribed) {
2254
2264
  subscribed = true;
2255
2265
  this.send({ type: "board:subscribe", payload: { boardId: this.options.boardId, projectId: this.options.projectId } });
2266
+ this.flushBuffer();
2256
2267
  this.options.onConnect();
2257
2268
  if (!resolved) {
2258
2269
  resolved = true;
@@ -2294,6 +2305,7 @@ var PipelineWsClient = class {
2294
2305
  }
2295
2306
  }
2296
2307
  stop() {
2308
+ this.sendBuffer = [];
2297
2309
  this.stopped = true;
2298
2310
  this.cleanupPing();
2299
2311
  if (this.ws) {
@@ -2308,6 +2320,29 @@ var PipelineWsClient = class {
2308
2320
  send(data) {
2309
2321
  if (this.ws?.readyState === WebSocket.OPEN) {
2310
2322
  this.ws.send(JSON.stringify(data));
2323
+ return;
2324
+ }
2325
+ const event = data;
2326
+ const isCritical = _PipelineWsClient.CRITICAL_TYPES.has(event.type ?? "");
2327
+ if (isCritical) {
2328
+ if (this.sendBuffer.length < _PipelineWsClient.BUFFER_MAX) {
2329
+ this.sendBuffer.push({ data, critical: true, timestamp: Date.now() });
2330
+ }
2331
+ console.warn(`[WS] Buffered critical event (WS not open): ${event.type}`);
2332
+ } else if (event.type !== "ping") {
2333
+ console.debug?.(`[WS] Dropped non-critical event (WS not open): ${event.type}`);
2334
+ }
2335
+ }
2336
+ flushBuffer() {
2337
+ const now = Date.now();
2338
+ const valid = this.sendBuffer.filter((e) => now - e.timestamp < _PipelineWsClient.BUFFER_TTL_MS);
2339
+ this.sendBuffer = [];
2340
+ for (const entry of valid) {
2341
+ if (this.ws?.readyState === WebSocket.OPEN) {
2342
+ this.ws.send(JSON.stringify(entry.data));
2343
+ const event = entry.data;
2344
+ console.log(`[WS] Replayed buffered event: ${event.type}`);
2345
+ }
2311
2346
  }
2312
2347
  }
2313
2348
  cleanupPing() {
@@ -4253,4 +4288,4 @@ export {
4253
4288
  runPipeline,
4254
4289
  stopPipeline
4255
4290
  };
4256
- //# sourceMappingURL=pipeline-O2JPCI2C.js.map
4291
+ //# sourceMappingURL=pipeline-5LJYH46J.js.map