pty-manager 1.10.2 → 1.11.1

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.
@@ -467,6 +467,7 @@ var PTYSession = class _PTYSession extends import_node_events.EventEmitter {
467
467
  }
468
468
  }
469
469
  }
470
+ adapter;
470
471
  ptyProcess = null;
471
472
  outputBuffer = "";
472
473
  _status = "pending";
@@ -967,6 +968,20 @@ var PTYSession = class _PTYSession extends import_node_events.EventEmitter {
967
968
  );
968
969
  }, _PTYSession.TASK_COMPLETE_DEBOUNCE_MS);
969
970
  }
971
+ /**
972
+ * Whether the adapter's `detectLoading()` currently classifies the
973
+ * session as actively processing work.
974
+ *
975
+ * This wraps `adapter.detectLoading(outputBuffer)` for consumers outside
976
+ * the PTY layer (e.g. milady's swarm idle watchdog) that need a
977
+ * reliable "is the agent busy right now?" signal without reimplementing
978
+ * heuristics over raw terminal output.
979
+ *
980
+ * Returns `false` if the adapter does not implement `detectLoading`.
981
+ */
982
+ isLoading() {
983
+ return this.adapter.detectLoading?.(this.outputBuffer) ?? false;
984
+ }
970
985
  /**
971
986
  * Adapter-level task completion check with compatibility fallback.
972
987
  * Prefer detectTaskComplete() because detectReady() may be broad for TUIs.
@@ -1983,6 +1998,20 @@ var PTYManager = class extends import_node_events2.EventEmitter {
1983
1998
  getSession(sessionId) {
1984
1999
  return this.sessions.get(sessionId);
1985
2000
  }
2001
+ /**
2002
+ * Whether the adapter currently classifies the session as actively
2003
+ * processing work (e.g. Codex's "esc to interrupt" status row).
2004
+ *
2005
+ * Orchestrators (like milady's swarm idle watchdog) should consult
2006
+ * this before assuming a session is idle based on output byte diffs,
2007
+ * which are fooled by TUIs that redraw the same status row in place.
2008
+ *
2009
+ * Returns `false` for unknown sessions or adapters that don't
2010
+ * implement `detectLoading`.
2011
+ */
2012
+ isSessionLoading(sessionId) {
2013
+ return this.sessions.get(sessionId)?.isLoading() ?? false;
2014
+ }
1986
2015
  // ─────────────────────────────────────────────────────────────────────────────
1987
2016
  // Stall Detection Configuration
1988
2017
  // ─────────────────────────────────────────────────────────────────────────────
@@ -2269,6 +2298,19 @@ async function handleKill(id, signal) {
2269
2298
  ack("kill", id, false, err instanceof Error ? err.message : String(err));
2270
2299
  }
2271
2300
  }
2301
+ function handleIsSessionLoading(id) {
2302
+ try {
2303
+ const loading = manager.isSessionLoading(id);
2304
+ emit({ event: "isSessionLoading", id, loading });
2305
+ } catch (err) {
2306
+ emit({
2307
+ event: "isSessionLoading",
2308
+ id,
2309
+ loading: false,
2310
+ error: err instanceof Error ? err.message : String(err)
2311
+ });
2312
+ }
2313
+ }
2272
2314
  function handleList() {
2273
2315
  const sessions = manager.list();
2274
2316
  const sessionList = sessions.map((s) => ({
@@ -2544,6 +2586,13 @@ function processCommand(line) {
2544
2586
  case "list":
2545
2587
  handleList();
2546
2588
  break;
2589
+ case "isSessionLoading":
2590
+ if (!command.id) {
2591
+ ack("isSessionLoading", command.id, false, "Missing id");
2592
+ return;
2593
+ }
2594
+ handleIsSessionLoading(command.id);
2595
+ break;
2547
2596
  case "shutdown":
2548
2597
  handleShutdown();
2549
2598
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pty-manager",
3
- "version": "1.10.2",
3
+ "version": "1.11.1",
4
4
  "description": "PTY session manager with lifecycle management, pluggable adapters, and blocking prompt detection",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -23,6 +23,17 @@
23
23
  "README.md",
24
24
  "LICENSE"
25
25
  ],
26
+ "scripts": {
27
+ "build": "tsup",
28
+ "dev": "tsup --watch",
29
+ "test": "vitest",
30
+ "test:run": "vitest run",
31
+ "test:coverage": "vitest --coverage",
32
+ "test:integration": "tsx test-integration.ts",
33
+ "type-check": "tsc --noEmit",
34
+ "clean": "rm -rf dist",
35
+ "prepublishOnly": "pnpm run build"
36
+ },
26
37
  "keywords": [
27
38
  "pty",
28
39
  "terminal",
@@ -41,16 +52,15 @@
41
52
  "license": "MIT",
42
53
  "repository": {
43
54
  "type": "git",
44
- "url": "https://github.com/HaruHunab1320/parallax.git",
45
- "directory": "packages/pty-manager"
55
+ "url": "https://github.com/HaruHunab1320/pty-manager.git"
46
56
  },
47
57
  "bugs": {
48
- "url": "https://github.com/HaruHunab1320/parallax/issues"
58
+ "url": "https://github.com/HaruHunab1320/pty-manager/issues"
49
59
  },
50
- "homepage": "https://github.com/HaruHunab1320/parallax/tree/main/packages/pty-manager#readme",
60
+ "homepage": "https://github.com/HaruHunab1320/pty-manager#readme",
51
61
  "dependencies": {
52
- "node-pty": "^1.0.0",
53
- "adapter-types": "^0.2.0"
62
+ "adapter-types": "^0.2.0",
63
+ "node-pty": "^1.0.0"
54
64
  },
55
65
  "devDependencies": {
56
66
  "@types/node": "^22.14.1",
@@ -61,15 +71,5 @@
61
71
  },
62
72
  "engines": {
63
73
  "node": ">=18"
64
- },
65
- "scripts": {
66
- "build": "tsup",
67
- "dev": "tsup --watch",
68
- "test": "vitest",
69
- "test:run": "vitest run",
70
- "test:coverage": "vitest --coverage",
71
- "test:integration": "tsx test-integration.ts",
72
- "type-check": "tsc --noEmit",
73
- "clean": "rm -rf dist"
74
74
  }
75
- }
75
+ }