oh-my-codex 0.22.4 → 0.22.6
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/Cargo.lock +6 -6
- package/Cargo.toml +1 -1
- package/crates/omx-api/src/lib.rs +7 -2
- package/crates/omx-api/tests/cli.rs +58 -0
- package/dist/cli/__tests__/cleanup.test.js +58 -73
- package/dist/cli/__tests__/cleanup.test.js.map +1 -1
- package/dist/cli/__tests__/launch-fallback.test.js +41 -0
- package/dist/cli/__tests__/launch-fallback.test.js.map +1 -1
- package/dist/cli/__tests__/question.test.js +193 -2
- package/dist/cli/__tests__/question.test.js.map +1 -1
- package/dist/cli/cleanup.d.ts +0 -16
- package/dist/cli/cleanup.d.ts.map +1 -1
- package/dist/cli/cleanup.js +2 -71
- package/dist/cli/cleanup.js.map +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +8 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/question.d.ts.map +1 -1
- package/dist/cli/question.js +38 -20
- package/dist/cli/question.js.map +1 -1
- package/dist/mcp/__tests__/memory-server-concurrency.test.d.ts +2 -0
- package/dist/mcp/__tests__/memory-server-concurrency.test.d.ts.map +1 -0
- package/dist/mcp/__tests__/memory-server-concurrency.test.js +128 -0
- package/dist/mcp/__tests__/memory-server-concurrency.test.js.map +1 -0
- package/dist/mcp/memory-server.d.ts.map +1 -1
- package/dist/mcp/memory-server.js +40 -49
- package/dist/mcp/memory-server.js.map +1 -1
- package/dist/notifications/__tests__/reply-routing-realtmux.test.d.ts +2 -0
- package/dist/notifications/__tests__/reply-routing-realtmux.test.d.ts.map +1 -0
- package/dist/notifications/__tests__/reply-routing-realtmux.test.js +133 -0
- package/dist/notifications/__tests__/reply-routing-realtmux.test.js.map +1 -0
- package/dist/notifications/index.d.ts.map +1 -1
- package/dist/notifications/index.js +5 -1
- package/dist/notifications/index.js.map +1 -1
- package/dist/notifications/reply-listener.d.ts +2 -1
- package/dist/notifications/reply-listener.d.ts.map +1 -1
- package/dist/notifications/reply-listener.js +13 -5
- package/dist/notifications/reply-listener.js.map +1 -1
- package/dist/notifications/session-registry.d.ts +2 -0
- package/dist/notifications/session-registry.d.ts.map +1 -1
- package/dist/notifications/session-registry.js.map +1 -1
- package/dist/notifications/tmux-detector.d.ts +12 -0
- package/dist/notifications/tmux-detector.d.ts.map +1 -1
- package/dist/notifications/tmux-detector.js +46 -2
- package/dist/notifications/tmux-detector.js.map +1 -1
- package/dist/question/__tests__/renderer.test.js +84 -50
- package/dist/question/__tests__/renderer.test.js.map +1 -1
- package/dist/question/__tests__/state.test.js +192 -2
- package/dist/question/__tests__/state.test.js.map +1 -1
- package/dist/question/__tests__/ui.test.js +82 -1
- package/dist/question/__tests__/ui.test.js.map +1 -1
- package/dist/question/renderer.d.ts +2 -2
- package/dist/question/renderer.d.ts.map +1 -1
- package/dist/question/renderer.js +14 -22
- package/dist/question/renderer.js.map +1 -1
- package/dist/question/state.d.ts +4 -0
- package/dist/question/state.d.ts.map +1 -1
- package/dist/question/state.js +76 -23
- package/dist/question/state.js.map +1 -1
- package/dist/question/ui.d.ts.map +1 -1
- package/dist/question/ui.js +8 -2
- package/dist/question/ui.js.map +1 -1
- package/dist/scripts/__tests__/worker-stop-task-read.test.d.ts +2 -0
- package/dist/scripts/__tests__/worker-stop-task-read.test.d.ts.map +1 -0
- package/dist/scripts/__tests__/worker-stop-task-read.test.js +76 -0
- package/dist/scripts/__tests__/worker-stop-task-read.test.js.map +1 -0
- package/dist/scripts/codex-native-hook.d.ts.map +1 -1
- package/dist/scripts/codex-native-hook.js +28 -14
- package/dist/scripts/codex-native-hook.js.map +1 -1
- package/dist/scripts/notify-hook/team-dispatch.d.ts.map +1 -1
- package/dist/scripts/notify-hook/team-dispatch.js +137 -128
- package/dist/scripts/notify-hook/team-dispatch.js.map +1 -1
- package/dist/subagents/tracker.d.ts.map +1 -1
- package/dist/subagents/tracker.js +12 -2
- package/dist/subagents/tracker.js.map +1 -1
- package/dist/team/__tests__/lock-recovery.test.d.ts +2 -0
- package/dist/team/__tests__/lock-recovery.test.d.ts.map +1 -0
- package/dist/team/__tests__/lock-recovery.test.js +304 -0
- package/dist/team/__tests__/lock-recovery.test.js.map +1 -0
- package/dist/team/__tests__/state.test.js +8 -6
- package/dist/team/__tests__/state.test.js.map +1 -1
- package/dist/team/state/dispatch-lock.d.ts.map +1 -1
- package/dist/team/state/dispatch-lock.js +3 -11
- package/dist/team/state/dispatch-lock.js.map +1 -1
- package/dist/team/state/locks.d.ts +1 -0
- package/dist/team/state/locks.d.ts.map +1 -1
- package/dist/team/state/locks.js +29 -13
- package/dist/team/state/locks.js.map +1 -1
- package/dist/vscode/__tests__/index.test.js +21 -0
- package/dist/vscode/__tests__/index.test.js.map +1 -1
- package/dist/vscode/index.d.ts.map +1 -1
- package/dist/vscode/index.js +8 -4
- package/dist/vscode/index.js.map +1 -1
- package/package.json +1 -1
- package/plugins/oh-my-codex/.codex-plugin/plugin.json +1 -1
- package/src/scripts/__tests__/worker-stop-task-read.test.ts +77 -0
- package/src/scripts/codex-native-hook.ts +25 -11
- package/src/scripts/notify-hook/team-dispatch.ts +133 -125
|
@@ -8,6 +8,7 @@ import { safeString } from './utils.js';
|
|
|
8
8
|
import { getDefaultBridge, isRuntimeTransportError, isStrictDispatchRecord, preflightRuntimeBridge, resolveBridgeStateDir, RuntimeBridgeError } from '../../runtime/bridge.js';
|
|
9
9
|
import { hasRuntimeAuthority, hasRuntimeDispatchIdentity, recordRuntimeFinalization, reconcileRuntimeFinalizations } from '../../team/state/dispatch-recovery.js';
|
|
10
10
|
import { readDispatchRequests } from '../../team/state.js';
|
|
11
|
+
import { assertTeamLockNotStale } from '../../team/state/locks.js';
|
|
11
12
|
import { appendTeamDeliveryLog } from '../../team/delivery-log.js';
|
|
12
13
|
import { hasUniqueScopedMailboxMatch, mailboxMessageContentMatches, mailboxMessageIdentity, mailboxRecordBelongsToTeam, normalizeBridgeMailboxMessage, readLegacyMailboxMessageIds } from '../../team/state/mailbox.js';
|
|
13
14
|
|
|
@@ -298,15 +299,7 @@ async function withLockDirectory(lockDir, timeoutError, fn) {
|
|
|
298
299
|
break;
|
|
299
300
|
} catch (error) {
|
|
300
301
|
if (error?.code !== 'EEXIST') throw error;
|
|
301
|
-
|
|
302
|
-
const info = await stat(lockDir);
|
|
303
|
-
if (Date.now() - info.mtimeMs > DISPATCH_LOCK_STALE_MS) {
|
|
304
|
-
await rm(lockDir, { recursive: true, force: true });
|
|
305
|
-
continue;
|
|
306
|
-
}
|
|
307
|
-
} catch {
|
|
308
|
-
// best effort
|
|
309
|
-
}
|
|
302
|
+
await assertTeamLockNotStale(lockDir, DISPATCH_LOCK_STALE_MS);
|
|
310
303
|
if (Date.now() > deadline) throw new Error(timeoutError);
|
|
311
304
|
await new Promise((resolveDelay) => setTimeout(resolveDelay, 25));
|
|
312
305
|
}
|
|
@@ -1188,136 +1181,151 @@ export async function drainPendingTeamDispatch({
|
|
|
1188
1181
|
const requestsPath = join(teamDirPath, 'dispatch', 'requests.json');
|
|
1189
1182
|
const config = await readJson(existsSync(manifestPath) ? manifestPath : configPath, {});
|
|
1190
1183
|
const claims = [];
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
authoritativeRecords
|
|
1197
|
-
if (
|
|
1198
|
-
|
|
1199
|
-
|
|
1184
|
+
let lockAcquired = false;
|
|
1185
|
+
try {
|
|
1186
|
+
await withDispatchLock(teamDirPath, async () => {
|
|
1187
|
+
lockAcquired = true;
|
|
1188
|
+
await reconcileRuntimeFinalizations(stateDir, teamName);
|
|
1189
|
+
let authoritativeRecords;
|
|
1190
|
+
if (hasRuntimeAuthority(stateDir)) {
|
|
1191
|
+
if (process.env.OMX_RUNTIME_BRIDGE === '0') throw new Error('runtime dispatch authority requires an enabled bridge');
|
|
1192
|
+
authoritativeRecords = await refreshDispatchProjection(stateDir);
|
|
1193
|
+
if (!authoritativeRecords) {
|
|
1194
|
+
const records = getDefaultBridge(stateDir).readCompatFile('dispatch.json')?.records;
|
|
1195
|
+
if (Array.isArray(records)) authoritativeRecords = records;
|
|
1196
|
+
}
|
|
1200
1197
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
preflightRuntimeBridge(stateDir);
|
|
1206
|
-
}
|
|
1207
|
-
const issueCooldownState = await readIssueCooldownState(teamDirPath);
|
|
1208
|
-
const triggerCooldownState = await readTriggerCooldownState(teamDirPath);
|
|
1209
|
-
const issueCooldownByIssue = issueCooldownState.by_issue || {};
|
|
1210
|
-
const triggerCooldownByKey = triggerCooldownState.by_trigger || {};
|
|
1211
|
-
const nowMs = Date.now();
|
|
1212
|
-
|
|
1213
|
-
let mutated = false;
|
|
1214
|
-
for (const request of requests) {
|
|
1215
|
-
if (processed + claims.length >= maxPerTick) break;
|
|
1216
|
-
if (!request || typeof request !== 'object') continue;
|
|
1217
|
-
if (shouldSkipRequest(request)) {
|
|
1218
|
-
skipped += 1;
|
|
1219
|
-
continue;
|
|
1198
|
+
const requests = await readBridgeDispatchRequests(stateDir, teamName, cwd, authoritativeRecords);
|
|
1199
|
+
if (!Array.isArray(requests)) return;
|
|
1200
|
+
if (requests.some((request) => request && typeof request === 'object' && !shouldSkipRequest(request))) {
|
|
1201
|
+
preflightRuntimeBridge(stateDir);
|
|
1220
1202
|
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
if (!
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
request_id: request.request_id,
|
|
1235
|
-
worker: request.to_worker,
|
|
1236
|
-
to_worker: request.to_worker,
|
|
1237
|
-
message_id: request.message_id || null,
|
|
1238
|
-
reason: LEADER_PANE_MISSING_DEFERRED_REASON,
|
|
1239
|
-
status: 'pending',
|
|
1240
|
-
tmux_session: safeString(config?.tmux_session).trim() || null,
|
|
1241
|
-
leader_pane_id: safeString(config?.leader_pane_id).trim() || null,
|
|
1242
|
-
tmux_injection_attempted: false,
|
|
1243
|
-
pane_target: null,
|
|
1244
|
-
pane_source: null,
|
|
1245
|
-
readiness_evidence: null,
|
|
1246
|
-
pane_current_command: null,
|
|
1247
|
-
});
|
|
1248
|
-
await appendDeliveryTelemetry(logsDir, {
|
|
1249
|
-
event: 'dispatch_result',
|
|
1250
|
-
team: teamName,
|
|
1251
|
-
request_id: request.request_id,
|
|
1252
|
-
message_id: request.message_id || null,
|
|
1253
|
-
to_worker: request.to_worker,
|
|
1254
|
-
transport: 'send-keys',
|
|
1255
|
-
result: 'deferred',
|
|
1256
|
-
reason: LEADER_PANE_MISSING_DEFERRED_REASON,
|
|
1257
|
-
});
|
|
1258
|
-
await appendLeaderNotificationDeferredEvent({
|
|
1259
|
-
stateDir,
|
|
1260
|
-
teamName,
|
|
1261
|
-
request,
|
|
1262
|
-
reason: LEADER_PANE_MISSING_DEFERRED_REASON,
|
|
1263
|
-
nowIso,
|
|
1264
|
-
tmuxSession: safeString(config?.tmux_session).trim(),
|
|
1265
|
-
leaderPaneId: safeString(config?.leader_pane_id).trim(),
|
|
1266
|
-
sourceType: 'team_dispatch',
|
|
1267
|
-
});
|
|
1203
|
+
const issueCooldownState = await readIssueCooldownState(teamDirPath);
|
|
1204
|
+
const triggerCooldownState = await readTriggerCooldownState(teamDirPath);
|
|
1205
|
+
const issueCooldownByIssue = issueCooldownState.by_issue || {};
|
|
1206
|
+
const triggerCooldownByKey = triggerCooldownState.by_trigger || {};
|
|
1207
|
+
const nowMs = Date.now();
|
|
1208
|
+
|
|
1209
|
+
let mutated = false;
|
|
1210
|
+
for (const request of requests) {
|
|
1211
|
+
if (processed + claims.length >= maxPerTick) break;
|
|
1212
|
+
if (!request || typeof request !== 'object') continue;
|
|
1213
|
+
if (shouldSkipRequest(request)) {
|
|
1214
|
+
skipped += 1;
|
|
1215
|
+
continue;
|
|
1268
1216
|
}
|
|
1269
|
-
continue;
|
|
1270
|
-
}
|
|
1271
1217
|
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1218
|
+
if (request.to_worker === 'leader-fixed' && !resolveLeaderPaneId(config) && !explicitPaneIdentity(request.pane_id).provided) {
|
|
1219
|
+
const nowIso = new Date().toISOString();
|
|
1220
|
+
const alreadyDeferred = safeString(request.last_reason).trim() === LEADER_PANE_MISSING_DEFERRED_REASON;
|
|
1221
|
+
request.updated_at = nowIso;
|
|
1222
|
+
request.last_reason = LEADER_PANE_MISSING_DEFERRED_REASON;
|
|
1223
|
+
request.status = 'pending';
|
|
1276
1224
|
skipped += 1;
|
|
1225
|
+
mutated = true;
|
|
1226
|
+
if (!alreadyDeferred) {
|
|
1227
|
+
await appendDispatchLog(logsDir, {
|
|
1228
|
+
type: 'dispatch_deferred',
|
|
1229
|
+
team: teamName,
|
|
1230
|
+
request_id: request.request_id,
|
|
1231
|
+
worker: request.to_worker,
|
|
1232
|
+
to_worker: request.to_worker,
|
|
1233
|
+
message_id: request.message_id || null,
|
|
1234
|
+
reason: LEADER_PANE_MISSING_DEFERRED_REASON,
|
|
1235
|
+
status: 'pending',
|
|
1236
|
+
tmux_session: safeString(config?.tmux_session).trim() || null,
|
|
1237
|
+
leader_pane_id: safeString(config?.leader_pane_id).trim() || null,
|
|
1238
|
+
tmux_injection_attempted: false,
|
|
1239
|
+
pane_target: null,
|
|
1240
|
+
pane_source: null,
|
|
1241
|
+
readiness_evidence: null,
|
|
1242
|
+
pane_current_command: null,
|
|
1243
|
+
});
|
|
1244
|
+
await appendDeliveryTelemetry(logsDir, {
|
|
1245
|
+
event: 'dispatch_result',
|
|
1246
|
+
team: teamName,
|
|
1247
|
+
request_id: request.request_id,
|
|
1248
|
+
message_id: request.message_id || null,
|
|
1249
|
+
to_worker: request.to_worker,
|
|
1250
|
+
transport: 'send-keys',
|
|
1251
|
+
result: 'deferred',
|
|
1252
|
+
reason: LEADER_PANE_MISSING_DEFERRED_REASON,
|
|
1253
|
+
});
|
|
1254
|
+
await appendLeaderNotificationDeferredEvent({
|
|
1255
|
+
stateDir,
|
|
1256
|
+
teamName,
|
|
1257
|
+
request,
|
|
1258
|
+
reason: LEADER_PANE_MISSING_DEFERRED_REASON,
|
|
1259
|
+
nowIso,
|
|
1260
|
+
tmuxSession: safeString(config?.tmux_session).trim(),
|
|
1261
|
+
leaderPaneId: safeString(config?.leader_pane_id).trim(),
|
|
1262
|
+
sourceType: 'team_dispatch',
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1277
1265
|
continue;
|
|
1278
1266
|
}
|
|
1279
|
-
}
|
|
1280
1267
|
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1268
|
+
const issueKey = extractIssueKey(request.trigger_message);
|
|
1269
|
+
if (issueCooldownMs > 0 && issueKey) {
|
|
1270
|
+
const lastInjectedMs = Number(issueCooldownByIssue[issueKey]);
|
|
1271
|
+
if (Number.isFinite(lastInjectedMs) && lastInjectedMs > 0 && nowMs - lastInjectedMs < issueCooldownMs) {
|
|
1272
|
+
skipped += 1;
|
|
1273
|
+
continue;
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
const triggerKey = normalizeTriggerKey(request.trigger_message);
|
|
1278
|
+
if (triggerCooldownMs > 0 && triggerKey) {
|
|
1279
|
+
const parsed = parseTriggerCooldownEntry(triggerCooldownByKey[triggerKey]);
|
|
1280
|
+
const withinCooldown = Number.isFinite(parsed.at) && parsed.at > 0 && nowMs - parsed.at < triggerCooldownMs;
|
|
1281
|
+
const sameRequestRetry = parsed.lastRequestId !== '' && parsed.lastRequestId === safeString(request.request_id).trim();
|
|
1282
|
+
if (withinCooldown && !sameRequestRetry) {
|
|
1283
|
+
skipped += 1;
|
|
1284
|
+
continue;
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
const lease = await tryAcquireDispatchRequestLease(teamDirPath, request.request_id);
|
|
1289
|
+
if (!lease) {
|
|
1287
1290
|
skipped += 1;
|
|
1288
1291
|
continue;
|
|
1289
1292
|
}
|
|
1293
|
+
mutated = reserveDispatchCooldowns({
|
|
1294
|
+
issueCooldownMs,
|
|
1295
|
+
triggerCooldownMs,
|
|
1296
|
+
issueCooldownByIssue,
|
|
1297
|
+
triggerCooldownByKey,
|
|
1298
|
+
issueKey,
|
|
1299
|
+
triggerKey,
|
|
1300
|
+
requestId: request.request_id,
|
|
1301
|
+
}) || mutated;
|
|
1302
|
+
claims.push({
|
|
1303
|
+
request: { ...request },
|
|
1304
|
+
authoritativeRecords,
|
|
1305
|
+
lease,
|
|
1306
|
+
});
|
|
1290
1307
|
}
|
|
1291
1308
|
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1309
|
+
if (mutated) {
|
|
1310
|
+
issueCooldownState.by_issue = issueCooldownByIssue;
|
|
1311
|
+
await writeJsonAtomic(issueCooldownStatePath(teamDirPath), issueCooldownState);
|
|
1312
|
+
triggerCooldownState.by_trigger = triggerCooldownByKey;
|
|
1313
|
+
await writeJsonAtomic(triggerCooldownStatePath(teamDirPath), triggerCooldownState);
|
|
1314
|
+
await writeJsonAtomic(requestsPath, requests);
|
|
1296
1315
|
}
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
});
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
if (mutated) {
|
|
1314
|
-
issueCooldownState.by_issue = issueCooldownByIssue;
|
|
1315
|
-
await writeJsonAtomic(issueCooldownStatePath(teamDirPath), issueCooldownState);
|
|
1316
|
-
triggerCooldownState.by_trigger = triggerCooldownByKey;
|
|
1317
|
-
await writeJsonAtomic(triggerCooldownStatePath(teamDirPath), triggerCooldownState);
|
|
1318
|
-
await writeJsonAtomic(requestsPath, requests);
|
|
1319
|
-
}
|
|
1320
|
-
});
|
|
1316
|
+
});
|
|
1317
|
+
} catch (error) {
|
|
1318
|
+
// An abandoned dispatch lock needs manual recovery for this team only: keep the lock,
|
|
1319
|
+
// report it, and let the other teams under the same state root drain.
|
|
1320
|
+
if (lockAcquired || !safeString(error?.message).startsWith('team_lock_recovery_required:')) throw error;
|
|
1321
|
+
failed += 1;
|
|
1322
|
+
await appendDispatchLog(logsDir, {
|
|
1323
|
+
type: 'dispatch_lock_recovery_required',
|
|
1324
|
+
team: teamName,
|
|
1325
|
+
reason: safeString(error.message),
|
|
1326
|
+
});
|
|
1327
|
+
continue;
|
|
1328
|
+
}
|
|
1321
1329
|
|
|
1322
1330
|
try {
|
|
1323
1331
|
for (const claim of claims) {
|