opencode-orchestrator 1.2.13 → 1.2.15
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/dist/core/agents/manager/task-poller.d.ts +2 -1
- package/dist/core/loop/continuation-lock.d.ts +57 -0
- package/dist/core/loop/verification.d.ts +5 -44
- package/dist/core/session/session-health.d.ts +93 -0
- package/dist/index.js +455 -141
- package/dist/shared/constants/system-messages.d.ts +1 -1
- package/dist/shared/core/constants/memory-hooks.d.ts +4 -0
- package/package.json +1 -1
|
@@ -14,9 +14,10 @@ export declare class TaskPoller {
|
|
|
14
14
|
private scheduleCleanup;
|
|
15
15
|
private pruneExpiredTasks;
|
|
16
16
|
private onTaskComplete?;
|
|
17
|
+
private onTaskError?;
|
|
17
18
|
private pollingInterval?;
|
|
18
19
|
private messageCache;
|
|
19
|
-
constructor(client: OpencodeClient, store: TaskStore, concurrency: ConcurrencyController, notifyParentIfAllComplete: (parentSessionID: string) => Promise<void>, scheduleCleanup: (taskId: string) => void, pruneExpiredTasks: () => void, onTaskComplete?: ((task: ParallelTask) => void | Promise<void>) | undefined);
|
|
20
|
+
constructor(client: OpencodeClient, store: TaskStore, concurrency: ConcurrencyController, notifyParentIfAllComplete: (parentSessionID: string) => Promise<void>, scheduleCleanup: (taskId: string) => void, pruneExpiredTasks: () => void, onTaskComplete?: ((task: ParallelTask) => void | Promise<void>) | undefined, onTaskError?: ((taskId: string, error: unknown) => void) | undefined);
|
|
20
21
|
start(): void;
|
|
21
22
|
stop(): void;
|
|
22
23
|
isRunning(): boolean;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Continuation Lock - Ensures single execution of continuation logic
|
|
3
|
+
*
|
|
4
|
+
* Prevents simultaneous execution of Mission Loop and Todo Continuation systems.
|
|
5
|
+
* This resolves infinite loading issues caused by duplicate prompt injections.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* if (!tryAcquireContinuationLock(sessionID)) {
|
|
9
|
+
* return; // Another system is already processing
|
|
10
|
+
* }
|
|
11
|
+
* try {
|
|
12
|
+
* // continuation logic
|
|
13
|
+
* } finally {
|
|
14
|
+
* releaseContinuationLock(sessionID);
|
|
15
|
+
* }
|
|
16
|
+
*/
|
|
17
|
+
interface ContinuationLockState {
|
|
18
|
+
acquired: boolean;
|
|
19
|
+
timestamp: number;
|
|
20
|
+
source?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Try to acquire the continuation lock
|
|
24
|
+
*
|
|
25
|
+
* @param sessionID - Session ID
|
|
26
|
+
* @param source - Source requesting the lock (for debugging)
|
|
27
|
+
* @returns true if acquired, false otherwise
|
|
28
|
+
*/
|
|
29
|
+
export declare function tryAcquireContinuationLock(sessionID: string, source?: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Release the continuation lock
|
|
32
|
+
*
|
|
33
|
+
* @param sessionID - Session ID
|
|
34
|
+
*/
|
|
35
|
+
export declare function releaseContinuationLock(sessionID: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Check if the lock is currently active
|
|
38
|
+
*
|
|
39
|
+
* @param sessionID - Session ID
|
|
40
|
+
* @returns true if lock is held
|
|
41
|
+
*/
|
|
42
|
+
export declare function hasContinuationLock(sessionID: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Cleanup lock when session is cleaned up
|
|
45
|
+
*
|
|
46
|
+
* @param sessionID - Session ID
|
|
47
|
+
*/
|
|
48
|
+
export declare function cleanupContinuationLock(sessionID: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Clear all locks (for testing)
|
|
51
|
+
*/
|
|
52
|
+
export declare function clearAllLocks(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Get lock status (for debugging)
|
|
55
|
+
*/
|
|
56
|
+
export declare function getLockStatus(sessionID: string): ContinuationLockState | undefined;
|
|
57
|
+
export {};
|
|
@@ -5,62 +5,23 @@
|
|
|
5
5
|
*
|
|
6
6
|
* The LLM creates and checks items in .opencode/verification-checklist.md
|
|
7
7
|
* The hook system verifies all items are checked before allowing CONCLUDE.
|
|
8
|
-
*
|
|
9
|
-
* This approach:
|
|
10
|
-
* 1. LLM discovers environment and creates appropriate checklist items
|
|
11
|
-
* 2. LLM executes and marks items as complete
|
|
12
|
-
* 3. Hook verifies all items are checked (hard gate)
|
|
13
8
|
*/
|
|
14
9
|
import { type ChecklistCategory, type ChecklistItem, type ChecklistVerificationResult, type VerificationResult } from "../../shared/index.js";
|
|
15
10
|
export type { ChecklistItem, ChecklistCategory, ChecklistVerificationResult, VerificationResult };
|
|
16
|
-
/** Path to the verification checklist file (re-export for convenience) */
|
|
17
11
|
export declare const CHECKLIST_FILE: ".opencode/verification-checklist.md";
|
|
18
|
-
/**
|
|
19
|
-
* Parse checklist from markdown content
|
|
20
|
-
*/
|
|
21
12
|
export declare function parseChecklist(content: string): ChecklistItem[];
|
|
22
|
-
/**
|
|
23
|
-
* Read checklist from file
|
|
24
|
-
*/
|
|
25
13
|
export declare function readChecklist(directory: string): ChecklistItem[];
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*/
|
|
14
|
+
export declare function readChecklistAsync(directory: string): Promise<ChecklistItem[]>;
|
|
15
|
+
export declare function clearVerificationCache(): void;
|
|
29
16
|
export declare function verifyChecklist(directory: string): ChecklistVerificationResult;
|
|
30
|
-
|
|
31
|
-
* Quick check if checklist exists and has items
|
|
32
|
-
*/
|
|
17
|
+
export declare function verifyChecklistAsync(directory: string): Promise<ChecklistVerificationResult>;
|
|
33
18
|
export declare function hasValidChecklist(directory: string): boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Get checklist summary for display
|
|
36
|
-
*/
|
|
37
19
|
export declare function getChecklistSummary(directory: string): string;
|
|
38
|
-
/**
|
|
39
|
-
* Build prompt for when checklist verification fails
|
|
40
|
-
*/
|
|
41
20
|
export declare function buildChecklistFailurePrompt(result: ChecklistVerificationResult): string;
|
|
42
|
-
/**
|
|
43
|
-
* Build checklist creation prompt (for inclusion in agent prompts)
|
|
44
|
-
*/
|
|
45
21
|
export declare function getChecklistCreationInstructions(): string;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
*
|
|
49
|
-
* Checks (in order):
|
|
50
|
-
* 1. Verification checklist (primary - if exists)
|
|
51
|
-
* 2. TODO completion rate (fallback)
|
|
52
|
-
* 3. Sync issues (always checked)
|
|
53
|
-
*/
|
|
22
|
+
export declare function verifyMissionCompletionSync(directory: string): VerificationResult;
|
|
23
|
+
export declare function verifyMissionCompletionAsync(directory: string): Promise<VerificationResult>;
|
|
54
24
|
export declare function verifyMissionCompletion(directory: string): VerificationResult;
|
|
55
|
-
/**
|
|
56
|
-
* Build prompt for when conclusion is rejected due to verification failure
|
|
57
|
-
*/
|
|
58
25
|
export declare function buildVerificationFailurePrompt(result: VerificationResult): string;
|
|
59
|
-
/**
|
|
60
|
-
* Build prompt for when TODO is incomplete
|
|
61
|
-
*/
|
|
62
26
|
export declare function buildTodoIncompletePrompt(result: VerificationResult): string;
|
|
63
|
-
/**
|
|
64
|
-
* Build a concise status summary for logs
|
|
65
|
-
*/
|
|
66
27
|
export declare function buildVerificationSummary(result: VerificationResult): string;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Health Monitor
|
|
3
|
+
*
|
|
4
|
+
* Periodically checks session health and detects stale sessions.
|
|
5
|
+
* Early detection of infinite loading states improves system stability.
|
|
6
|
+
*/
|
|
7
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
8
|
+
type OpencodeClient = PluginInput["client"];
|
|
9
|
+
interface SessionHealthState {
|
|
10
|
+
sessionID: string;
|
|
11
|
+
lastActiveTime: number;
|
|
12
|
+
lastResponseTime: number;
|
|
13
|
+
isStale: boolean;
|
|
14
|
+
activityCount: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Record session activity
|
|
18
|
+
*
|
|
19
|
+
* Call this when an activity occurs in the session.
|
|
20
|
+
* (e.g., sending prompt, tool execution)
|
|
21
|
+
*
|
|
22
|
+
* @param sessionID - Session ID
|
|
23
|
+
*/
|
|
24
|
+
export declare function recordSessionActivity(sessionID: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Record session response receipt
|
|
27
|
+
*
|
|
28
|
+
* Call this when a response is received from the session.
|
|
29
|
+
* (e.g., assistant message received)
|
|
30
|
+
*
|
|
31
|
+
* @param sessionID - Session ID
|
|
32
|
+
*/
|
|
33
|
+
export declare function recordSessionResponse(sessionID: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Check if session is stale
|
|
36
|
+
*
|
|
37
|
+
* @param sessionID - Session ID
|
|
38
|
+
* @returns true if stale
|
|
39
|
+
*/
|
|
40
|
+
export declare function isSessionStale(sessionID: string): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Get session response age
|
|
43
|
+
*
|
|
44
|
+
* @param sessionID - Session ID
|
|
45
|
+
* @returns Time elapsed since last response (ms), or -1 if session not found
|
|
46
|
+
*/
|
|
47
|
+
export declare function getSessionResponseAge(sessionID: string): number;
|
|
48
|
+
/**
|
|
49
|
+
* Get all stale session IDs
|
|
50
|
+
*
|
|
51
|
+
* @returns Array of stale session IDs
|
|
52
|
+
*/
|
|
53
|
+
export declare function getStaleSessions(): string[];
|
|
54
|
+
/**
|
|
55
|
+
* Start health check monitor
|
|
56
|
+
*
|
|
57
|
+
* @param opencodeClient - OpenCode Client
|
|
58
|
+
*/
|
|
59
|
+
export declare function startHealthCheck(opencodeClient: OpencodeClient): void;
|
|
60
|
+
/**
|
|
61
|
+
* Stop health check monitor
|
|
62
|
+
*/
|
|
63
|
+
export declare function stopHealthCheck(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Perform actual health check (Exported for testing)
|
|
66
|
+
*/
|
|
67
|
+
export declare function performHealthCheck(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Cleanup session health state
|
|
70
|
+
*
|
|
71
|
+
* @param sessionID - Session ID
|
|
72
|
+
*/
|
|
73
|
+
export declare function cleanupSessionHealth(sessionID: string): void;
|
|
74
|
+
/**
|
|
75
|
+
* Clear all session health info (for testing)
|
|
76
|
+
*/
|
|
77
|
+
export declare function clearAllSessionHealth(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Get session health info (for debugging)
|
|
80
|
+
*
|
|
81
|
+
* @param sessionID - Session ID
|
|
82
|
+
*/
|
|
83
|
+
export declare function getSessionHealth(sessionID: string): SessionHealthState | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Get overall health stats (for debugging)
|
|
86
|
+
*/
|
|
87
|
+
export declare function getHealthStats(): {
|
|
88
|
+
total: number;
|
|
89
|
+
stale: number;
|
|
90
|
+
healthy: number;
|
|
91
|
+
avgResponseAge: number;
|
|
92
|
+
};
|
|
93
|
+
export {};
|