@kylecheng3146/agent-ops 0.1.2 → 0.1.3

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.
@@ -241,7 +241,9 @@ async function readWindowsProcessIdentity(processId) {
241
241
  ], {
242
242
  encoding: "utf8",
243
243
  maxBuffer: 4096,
244
- timeout: 2000,
244
+ // ponytail: cold PowerShell start on a loaded machine routinely
245
+ // passes two seconds; the lock budget above still bounds the wait.
246
+ timeout: 10_000,
245
247
  windowsHide: true
246
248
  });
247
249
  const startedAt = result.stdout.trim();
@@ -251,10 +253,27 @@ async function readWindowsProcessIdentity(processId) {
251
253
  return null;
252
254
  }
253
255
  }
256
+ /**
257
+ * A live process cannot change its own start time, so a successful self
258
+ * lookup never expires. Every other entry keeps the short TTL: foreign
259
+ * process IDs get recycled, and a failed self lookup must stay retryable
260
+ * instead of pinning the fallback identity for the whole run.
261
+ */
262
+ export function reuseCachedProcessIdentity(entry, processId, selfProcessId, now) {
263
+ if (entry === undefined) {
264
+ return false;
265
+ }
266
+ if (processId === selfProcessId &&
267
+ entry.identity !== null &&
268
+ !entry.identity.startsWith("runtime:")) {
269
+ return true;
270
+ }
271
+ return now - entry.checkedAt <= PROCESS_IDENTITY_CACHE_MS;
272
+ }
254
273
  async function readProcessIdentity(processId) {
255
274
  const cached = processIdentityCache.get(processId);
256
- if (cached !== undefined &&
257
- Date.now() - cached.checkedAt <= PROCESS_IDENTITY_CACHE_MS) {
275
+ if (reuseCachedProcessIdentity(cached, processId, process.pid, Date.now()) &&
276
+ cached !== undefined) {
258
277
  return cached.identity;
259
278
  }
260
279
  let identity;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kylecheng3146/agent-ops",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Evidence-driven development loops for Codex and Claude Code",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,6 +26,12 @@
26
26
  "items": {
27
27
  "$ref": "#/$defs/managedMarker"
28
28
  }
29
+ },
30
+ "hooks": {
31
+ "type": "array",
32
+ "items": {
33
+ "$ref": "#/$defs/managedHook"
34
+ }
29
35
  }
30
36
  },
31
37
  "$defs": {
@@ -104,6 +110,33 @@
104
110
  }
105
111
  }
106
112
  },
113
+ "managedHook": {
114
+ "type": "object",
115
+ "additionalProperties": false,
116
+ "required": ["id", "path", "harness", "events", "owner"],
117
+ "properties": {
118
+ "id": {
119
+ "$ref": "#/$defs/id"
120
+ },
121
+ "path": {
122
+ "$ref": "#/$defs/relativePath"
123
+ },
124
+ "harness": {
125
+ "enum": ["codex", "claude"]
126
+ },
127
+ "events": {
128
+ "type": "array",
129
+ "minItems": 1,
130
+ "uniqueItems": true,
131
+ "items": {
132
+ "enum": ["SessionStart", "PreToolUse", "Stop"]
133
+ }
134
+ },
135
+ "owner": {
136
+ "const": "agent-ops"
137
+ }
138
+ }
139
+ },
107
140
  "nonEmptyString": {
108
141
  "type": "string",
109
142
  "pattern": "[^\\s\\u0000]",