aiterm-steer-delivery 0.5.1 → 0.5.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.5.2 (2026-11-03)
2
+
3
+ - Preserve safe OS failure details for process reads without exposing command lines or output.
4
+
1
5
  # Changelog
2
6
 
3
7
  ## Unreleased
package/README.md CHANGED
@@ -264,3 +264,7 @@ CI runs the tests on Ubuntu, macOS, and Windows. Pushing a `v<version>` tag publ
264
264
  ## License
265
265
 
266
266
  [MIT](LICENSE)
267
+
268
+ ## Architecture
269
+
270
+ [Product boundaries and source index](https://github.com/kitepon/aiterm-steer-delivery/blob/fix/process-probe-details-20261103/docs/architecture/README.md).
package/dist/process.js CHANGED
@@ -6,6 +6,15 @@ const isWin = process.platform === "win32";
6
6
  class ProcessTableError extends Error {
7
7
  code = 2;
8
8
  }
9
+ function processReadError(probe, failure, result) {
10
+ const code = result.error?.code;
11
+ // Native messages and output can contain argv and credentials.
12
+ const detail = { component: "aiterm-steer-delivery", probe, code: result.error
13
+ ? (code && ["ETIMEDOUT", "ENOBUFS", "EAGAIN", "ENOENT", "EACCES", "ENOMEM", "EMFILE", "ENFILE", "E2BIG", "EPERM"].includes(code) ? code : "UNKNOWN") : null,
14
+ status: result.status ?? null, signal: result.signal ?? null,
15
+ stdout_bytes: Buffer.byteLength(result.stdout ?? ""), stderr_bytes: Buffer.byteLength(result.stderr ?? "") };
16
+ return new ProcessTableError(`${failure} ${JSON.stringify(detail)}`);
17
+ }
9
18
  export function processIdentity(process) {
10
19
  return {
11
20
  pid: process.pid, process_group_id: process.process_group_id,
@@ -63,13 +72,13 @@ export function processExists(pid) {
63
72
  return error.code === "EPERM";
64
73
  }
65
74
  }
66
- function windowsJson(script, failure) {
75
+ function windowsJson(script, failure, probe) {
67
76
  const source = ["$ErrorActionPreference='Stop'", "[Console]::OutputEncoding=[Text.UTF8Encoding]::new($false)", script].join("\n");
68
77
  const result = spawnSync(resolveWindowsPowerShell7(), ["-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand", Buffer.from(source, "utf16le").toString("base64")], {
69
78
  encoding: "utf8", timeout: 15000, maxBuffer: 16 * 1024 * 1024, windowsHide: true,
70
79
  });
71
80
  if (result.error || result.status !== 0)
72
- throw new ProcessTableError(failure);
81
+ throw processReadError(probe, failure, result);
73
82
  try {
74
83
  return JSON.parse(result.stdout);
75
84
  }
@@ -111,7 +120,7 @@ export function readProcessIdentities(pids) {
111
120
  });
112
121
  // 該当するprocessが一つも無い時、psは何も出さずstatus 1で終わる。
113
122
  if (result.error || (result.status !== 0 && !(result.status === 1 && !result.stdout.trim()))) {
114
- throw new ProcessTableError("OSのprocess一覧を取得できません");
123
+ throw processReadError("identity", "OSのprocess一覧を取得できません", result);
115
124
  }
116
125
  return result.stdout.split("\n").filter(line => line.trim()).map(line => {
117
126
  const match = /^\s*(\d+)\s+(\S+\s+\S+\s+\d+\s+\S+\s+\d+)\s*$/.exec(line);
@@ -130,7 +139,7 @@ export function readProcessIdentities(pids) {
130
139
  " $rows += [ordered]@{ pid=[int]$id; started_identity=$started }",
131
140
  "}",
132
141
  "ConvertTo-Json -Compress -InputObject $rows",
133
- ].join("\n"), "Windowsのprocessの開始時刻を取得できません");
142
+ ].join("\n"), "Windowsのprocessの開始時刻を取得できません", "identity");
134
143
  if (!Array.isArray(rows))
135
144
  throw new ProcessTableError("Windows processの読みが配列ではありません");
136
145
  return rows.map(row => {
@@ -174,7 +183,7 @@ export function readProcessLineage(pid, depth = 8) {
174
183
  " $child=$started; $id=$parent",
175
184
  "}",
176
185
  "ConvertTo-Json -Compress -InputObject $rows",
177
- ].join("\n"), "Windowsのprocessの先祖を取得できません");
186
+ ].join("\n"), "Windowsのprocessの先祖を取得できません", "lineage");
178
187
  }
179
188
  catch {
180
189
  return readRuntimeProcesses();
@@ -224,7 +233,7 @@ export function readRuntimeProcesses() {
224
233
  encoding: "utf8", env: { ...process.env, LC_ALL: "C" }, timeout: 10000, maxBuffer: 16 * 1024 * 1024,
225
234
  });
226
235
  if (result.error || result.status !== 0)
227
- throw new ProcessTableError("OSのprocess一覧を取得できません");
236
+ throw processReadError("table", "OSのprocess一覧を取得できません", result);
228
237
  return parsePosixProcessTable(result.stdout);
229
238
  }
230
239
  const script = [
@@ -238,7 +247,7 @@ export function readRuntimeProcesses() {
238
247
  encoding: "utf8", timeout: 15000, maxBuffer: 16 * 1024 * 1024, windowsHide: true,
239
248
  });
240
249
  if (result.error || result.status !== 0)
241
- throw new ProcessTableError("Windowsのnative process一覧を取得できません");
250
+ throw processReadError("table", "Windowsのnative process一覧を取得できません", result);
242
251
  let rows;
243
252
  try {
244
253
  rows = JSON.parse(result.stdout);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiterm-steer-delivery",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "Aiterm's steer delivery as a library: deliver text to the parent AI session that called your MCP tool — steered into the running turn when it is busy, delivered normally when it is idle. Codex (official queue + sync hooks), Claude Code (asyncRewake hooks), Cursor (hooks + background receiver).",
5
5
  "type": "module",
6
6
  "license": "MIT",