pi-harness-runtime 1.1.300 → 1.1.302
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/index.ts +60 -44
- package/package.json +1 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/architecture-generator/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard-plugin/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/e2e-tester/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/health-monitor/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/knowledge-graph/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/milestone-manager/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/observability/package.json +1 -1
- package/packages/okf-indexer/package.json +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-bootstrap/package.json +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/telegram/package.json +1 -1
- package/packages/tencentdb-memory/package.json +1 -1
- package/packages/tencentdb-sync/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/packages/write-review/package.json +1 -1
package/index.ts
CHANGED
|
@@ -903,6 +903,26 @@ async function initQdrant(): Promise<void> {
|
|
|
903
903
|
|
|
904
904
|
// --- telegram-notifications: Telegram bot for harness event notifications ------------
|
|
905
905
|
// Sends Telegram messages when jobs complete, tasks finish, or human input is needed.
|
|
906
|
+
|
|
907
|
+
// Shared Codex session state - accessible by both initTelegram() and the watcher
|
|
908
|
+
interface PlanEvent {
|
|
909
|
+
codexSessionId: string;
|
|
910
|
+
planPath: string;
|
|
911
|
+
planHash: string;
|
|
912
|
+
status: "observed" | "settling" | "ready" | "triggered" | "failed" | "manual_wait" | "done";
|
|
913
|
+
ordinal: number;
|
|
914
|
+
lastActivity: number;
|
|
915
|
+
settleTimer: ReturnType<typeof setTimeout> | null;
|
|
916
|
+
fileStableSince: number;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
const codexSessionState = {
|
|
920
|
+
deliveredEvents: new Map<string, PlanEvent>(),
|
|
921
|
+
currentCodexSessionId: null as string | null,
|
|
922
|
+
currentProjectRoot: null as string | null,
|
|
923
|
+
currentPlanCandidate: null as { ordinal: number; text: string; timestamp: number } | null,
|
|
924
|
+
};
|
|
925
|
+
|
|
906
926
|
async function initTelegram(pi: ExtensionAPI): Promise<void> {
|
|
907
927
|
addHarnessMessage("Telegram", "initializing", "wait");
|
|
908
928
|
try {
|
|
@@ -1002,10 +1022,10 @@ async function initTelegram(pi: ExtensionAPI): Promise<void> {
|
|
|
1002
1022
|
const [, sessionId, action] = taskCommandMatch;
|
|
1003
1023
|
|
|
1004
1024
|
// Find matching Codex session
|
|
1005
|
-
const matchingSession = deliveredEvents.get(sessionId) ||
|
|
1006
|
-
Array.from(deliveredEvents.values()).find(e => e.codexSessionId === sessionId);
|
|
1025
|
+
const matchingSession = codexSessionState.deliveredEvents.get(sessionId) ||
|
|
1026
|
+
Array.from(codexSessionState.deliveredEvents.values()).find(e => e.codexSessionId === sessionId);
|
|
1007
1027
|
|
|
1008
|
-
if (matchingSession && matchingSession.codexSessionId === currentCodexSessionId) {
|
|
1028
|
+
if (matchingSession && matchingSession.codexSessionId === codexSessionState.currentCodexSessionId) {
|
|
1009
1029
|
logToFile("[codex-trigger]", `Human command: ${action} for session ${sessionId}`);
|
|
1010
1030
|
|
|
1011
1031
|
if (action.toLowerCase() === "code") {
|
|
@@ -1028,15 +1048,15 @@ async function initTelegram(pi: ExtensionAPI): Promise<void> {
|
|
|
1028
1048
|
logToFile("[codex-trigger]", "Human marked session done:", sessionId);
|
|
1029
1049
|
}
|
|
1030
1050
|
return;
|
|
1031
|
-
|
|
1032
|
-
|
|
1051
|
+
} else {
|
|
1052
|
+
logToFile("[codex-trigger]", `Unknown session or wrong project: ${sessionId}`);
|
|
1053
|
+
}
|
|
1033
1054
|
}
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
});
|
|
1055
|
+
|
|
1056
|
+
logToFile("[TelegramInbound]", `Forwarding message to Pi: "${text.slice(0, 50)}..."`);
|
|
1057
|
+
// Forward the message to Pi as a user message
|
|
1058
|
+
await pi.sendUserMessage(text, { deliverAs: "steer" });
|
|
1059
|
+
});
|
|
1040
1060
|
|
|
1041
1061
|
// Wire to singleton nc() helper so all event emitters can reach Telegram
|
|
1042
1062
|
_nc = {
|
|
@@ -2190,10 +2210,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
2190
2210
|
// Collect async init promises so we can wait for them before showing startup notification
|
|
2191
2211
|
const asyncInitPromises: Promise<unknown>[] = [];
|
|
2192
2212
|
|
|
2193
|
-
//
|
|
2194
|
-
const deliveredEvents = new Map<string, PlanEvent>();
|
|
2195
|
-
let currentCodexSessionId: string | null = null;
|
|
2196
|
-
let currentProjectRoot: string | null = null;
|
|
2213
|
+
// Note: Session state moved to module-level codexSessionState object
|
|
2197
2214
|
|
|
2198
2215
|
// --- todo-bd-sync: Initialize two-way sync with bd ---------------
|
|
2199
2216
|
// Start async init but don't await - runs in background
|
|
@@ -2242,8 +2259,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
2242
2259
|
settleTimer: ReturnType<typeof setTimeout> | null;
|
|
2243
2260
|
fileStableSince: number;
|
|
2244
2261
|
}
|
|
2245
|
-
//
|
|
2246
|
-
let _currentPlanCandidate: { ordinal: number; text: string; timestamp: number } | null = null;
|
|
2262
|
+
// Use codexSessionState object for all session tracking
|
|
2247
2263
|
let lastActivityTime = 0;
|
|
2248
2264
|
|
|
2249
2265
|
// Check if plan file exists and is stable (mtime unchanged)
|
|
@@ -2276,8 +2292,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
2276
2292
|
// Trigger Pi to read the plan
|
|
2277
2293
|
async function triggerPiForPlan(event: PlanEvent): Promise<void> {
|
|
2278
2294
|
// Check cwd match
|
|
2279
|
-
if (_piSessionCwd && currentProjectRoot && _piSessionCwd !== currentProjectRoot) {
|
|
2280
|
-
logToFile("[codex-trigger]", "Cwd mismatch, skipping:", _piSessionCwd, "!=", currentProjectRoot);
|
|
2295
|
+
if (_piSessionCwd && codexSessionState.currentProjectRoot && _piSessionCwd !== codexSessionState.currentProjectRoot) {
|
|
2296
|
+
logToFile("[codex-trigger]", "Cwd mismatch, skipping:", _piSessionCwd, "!=", codexSessionState.currentProjectRoot);
|
|
2281
2297
|
return;
|
|
2282
2298
|
}
|
|
2283
2299
|
|
|
@@ -2303,15 +2319,15 @@ export default function (pi: ExtensionAPI) {
|
|
|
2303
2319
|
|
|
2304
2320
|
// Start settle timer for plan
|
|
2305
2321
|
function startSettleTimer(planPath: string, ordinal: number) {
|
|
2306
|
-
const eventKey = `${currentCodexSessionId}:${planPath}`;
|
|
2307
|
-
const existing = deliveredEvents.get(eventKey);
|
|
2322
|
+
const eventKey = `${codexSessionState.currentCodexSessionId}:${planPath}`;
|
|
2323
|
+
const existing = codexSessionState.deliveredEvents.get(eventKey);
|
|
2308
2324
|
if (existing && (existing.status === "triggered" || existing.status === "ready" || existing.status === "manual_wait")) {
|
|
2309
2325
|
logToFile("[codex-trigger]", "Event already handled:", eventKey);
|
|
2310
2326
|
return;
|
|
2311
2327
|
}
|
|
2312
2328
|
|
|
2313
2329
|
const event: PlanEvent = {
|
|
2314
|
-
codexSessionId: currentCodexSessionId ?? "",
|
|
2330
|
+
codexSessionId: codexSessionState.currentCodexSessionId ?? "",
|
|
2315
2331
|
planPath,
|
|
2316
2332
|
planHash: "",
|
|
2317
2333
|
status: "settling",
|
|
@@ -2320,7 +2336,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
2320
2336
|
settleTimer: null,
|
|
2321
2337
|
fileStableSince: 0,
|
|
2322
2338
|
};
|
|
2323
|
-
deliveredEvents.set(eventKey, event);
|
|
2339
|
+
codexSessionState.deliveredEvents.set(eventKey, event);
|
|
2324
2340
|
|
|
2325
2341
|
logToFile("[codex-trigger]", "Plan observed, starting settle timer:", planPath);
|
|
2326
2342
|
|
|
@@ -2357,20 +2373,20 @@ export default function (pi: ExtensionAPI) {
|
|
|
2357
2373
|
onSessionChange: (session) => {
|
|
2358
2374
|
if (session) {
|
|
2359
2375
|
logToFile("[codex]", `Session started: ${session.threadName}, root: ${session.projectRoot}`);
|
|
2360
|
-
currentCodexSessionId = session.id;
|
|
2361
|
-
currentProjectRoot = session.projectRoot;
|
|
2376
|
+
codexSessionState.currentCodexSessionId = session.id;
|
|
2377
|
+
codexSessionState.currentProjectRoot = session.projectRoot;
|
|
2362
2378
|
nc("CodexSessionStarted", {
|
|
2363
2379
|
requirement: `${session.threadName || "Codex session"} [${session.projectRoot || "unknown"}]`,
|
|
2364
2380
|
taskTitle: session.id,
|
|
2365
2381
|
});
|
|
2366
2382
|
} else {
|
|
2367
|
-
currentCodexSessionId = null;
|
|
2368
|
-
currentProjectRoot =
|
|
2369
|
-
currentPlanCandidate = null;
|
|
2383
|
+
codexSessionState.currentCodexSessionId = null;
|
|
2384
|
+
codexSessionState.currentProjectRoot = null;
|
|
2385
|
+
codexSessionState.currentPlanCandidate = null;
|
|
2370
2386
|
}
|
|
2371
2387
|
},
|
|
2372
2388
|
onMessages: (msgs) => {
|
|
2373
|
-
|
|
2389
|
+
if (!codexSessionState.currentCodexSessionId) return;
|
|
2374
2390
|
|
|
2375
2391
|
for (const msg of msgs) {
|
|
2376
2392
|
lastActivityTime = Date.now();
|
|
@@ -2388,11 +2404,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
2388
2404
|
|
|
2389
2405
|
// Only start settle timer for plans (not reviews)
|
|
2390
2406
|
// Reviews don't have a file to watch
|
|
2391
|
-
|
|
2392
|
-
const planPath = findPlanFile(currentProjectRoot);
|
|
2407
|
+
if (!hasReviewMarker && codexSessionState.currentProjectRoot) {
|
|
2408
|
+
const planPath = findPlanFile(codexSessionState.currentProjectRoot);
|
|
2393
2409
|
if (planPath) {
|
|
2394
2410
|
// Track plan candidate
|
|
2395
|
-
currentPlanCandidate = { ordinal: msg.ordinal, text: msg.text, timestamp: Date.now() };
|
|
2411
|
+
codexSessionState.currentPlanCandidate = { ordinal: msg.ordinal, text: msg.text, timestamp: Date.now() };
|
|
2396
2412
|
logToFile("[codex-trigger]", "Plan message + wiki file detected:", planPath);
|
|
2397
2413
|
startSettleTimer(planPath, msg.ordinal);
|
|
2398
2414
|
} else {
|
|
@@ -2402,28 +2418,28 @@ export default function (pi: ExtensionAPI) {
|
|
|
2402
2418
|
}
|
|
2403
2419
|
|
|
2404
2420
|
// Emit Telegram alert with full content
|
|
2405
|
-
const planPath = currentProjectRoot ? findPlanFile(currentProjectRoot) : undefined;
|
|
2421
|
+
const planPath = codexSessionState.currentProjectRoot ? findPlanFile(codexSessionState.currentProjectRoot) : undefined;
|
|
2406
2422
|
|
|
2407
2423
|
// Use event type based on stage
|
|
2408
2424
|
if (hasReviewMarker) {
|
|
2409
2425
|
nc("CodexReviewDetected", {
|
|
2410
2426
|
requirement: msg.text,
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2427
|
+
taskTitle: codexSessionState.currentCodexSessionId || `Ordinal ${msg.ordinal}`,
|
|
2428
|
+
details: {
|
|
2429
|
+
ordinal: msg.ordinal,
|
|
2430
|
+
stage: "review",
|
|
2431
|
+
projectRoot: codexSessionState.currentProjectRoot || undefined,
|
|
2416
2432
|
messageLength: msg.text.length,
|
|
2417
2433
|
},
|
|
2418
2434
|
});
|
|
2419
2435
|
} else {
|
|
2420
2436
|
nc("CodexPlanDetected", {
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2437
|
+
requirement: msg.text, // Full text, no truncation
|
|
2438
|
+
taskTitle: codexSessionState.currentCodexSessionId || `Ordinal ${msg.ordinal}`,
|
|
2439
|
+
details: {
|
|
2440
|
+
ordinal: msg.ordinal,
|
|
2441
|
+
stage: "plan",
|
|
2442
|
+
projectRoot: codexSessionState.currentProjectRoot || undefined,
|
|
2427
2443
|
planPath: planPath || undefined,
|
|
2428
2444
|
messageLength: msg.text.length,
|
|
2429
2445
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-harness/capability-registry",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.302",
|
|
4
4
|
"description": "Capability Registry for pi-harness-runtime — tracks model capabilities and enables capability-based routing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|