@shawnowen/comet-mcp 2.3.1 → 2.4.1
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/README.md +86 -19
- package/dist/alert-dispatcher.d.ts +23 -0
- package/dist/alert-dispatcher.js +101 -0
- package/dist/bound-session.d.ts +23 -0
- package/dist/bound-session.js +119 -0
- package/dist/bridge-config.d.ts +6 -0
- package/dist/bridge-config.js +78 -0
- package/dist/cdp-client.d.ts +40 -4
- package/dist/cdp-client.js +502 -155
- package/dist/comet-ai.d.ts +15 -0
- package/dist/comet-ai.js +114 -38
- package/dist/delegate-binding.d.ts +19 -0
- package/dist/delegate-binding.js +73 -0
- package/dist/discovery/capability-entry.d.ts +215 -0
- package/dist/discovery/capability-entry.js +13 -0
- package/dist/discovery/description-template.d.ts +40 -0
- package/dist/discovery/description-template.js +61 -0
- package/dist/discovery/golden-queries.fixture.d.ts +22 -0
- package/dist/discovery/golden-queries.fixture.js +137 -0
- package/dist/discovery/mcp-source.d.ts +38 -0
- package/dist/discovery/mcp-source.js +70 -0
- package/dist/discovery/metadata-completeness.d.ts +48 -0
- package/dist/discovery/metadata-completeness.js +83 -0
- package/dist/discovery/registry.d.ts +35 -0
- package/dist/discovery/registry.js +35 -0
- package/dist/discovery/safety.d.ts +44 -0
- package/dist/discovery/safety.js +59 -0
- package/dist/discovery/schema-validator.d.ts +36 -0
- package/dist/discovery/schema-validator.js +257 -0
- package/dist/discovery/source-error.d.ts +47 -0
- package/dist/discovery/source-error.js +95 -0
- package/dist/discovery/tool-meta.d.ts +41 -0
- package/dist/discovery/tool-meta.js +229 -0
- package/dist/discovery/virtual-tools.d.ts +20 -0
- package/dist/discovery/virtual-tools.js +69 -0
- package/dist/http-server.js +2067 -47
- package/dist/index.js +3163 -710
- package/dist/observer.d.ts +47 -0
- package/dist/observer.js +516 -0
- package/dist/session-registry.d.ts +57 -0
- package/dist/session-registry.js +500 -0
- package/dist/sidecar-artifacts.d.ts +49 -0
- package/dist/sidecar-artifacts.js +146 -0
- package/dist/snapshot-capture.d.ts +3 -0
- package/dist/snapshot-capture.js +91 -0
- package/dist/tab-group-archive.js +3 -1
- package/dist/tab-groups.d.ts +7 -0
- package/dist/tab-groups.js +21 -3
- package/dist/task-thread-aggregator.d.ts +34 -0
- package/dist/task-thread-aggregator.js +480 -0
- package/dist/task-thread-canonical.d.ts +142 -0
- package/dist/task-thread-canonical.js +116 -0
- package/dist/types.d.ts +237 -0
- package/dist/window-bindings.d.ts +112 -0
- package/dist/window-bindings.js +476 -0
- package/extension/background.js +1556 -300
- package/extension/icons/icon.svg +9 -0
- package/extension/icons/icon128.png +0 -0
- package/extension/icons/icon16.png +0 -0
- package/extension/icons/icon48.png +0 -0
- package/extension/manifest.json +19 -4
- package/extension/session-logic.js +2383 -0
- package/extension/session-manager.html +299 -0
- package/extension/sidepanel.css +5323 -528
- package/extension/sidepanel.html +282 -2
- package/extension/sidepanel.js +10075 -951
- package/extension/window-policy.js +162 -0
- package/package.json +10 -7
- package/vendor/lifecycle-mcp-adapter.mjs +103 -0
- package/vendor/lifecycle-metadata.mjs +252 -0
- package/vendor/readiness-report.mjs +742 -0
- package/dist/cdp-client.d.ts.map +0 -1
- package/dist/cdp-client.js.map +0 -1
- package/dist/comet-ai.d.ts.map +0 -1
- package/dist/comet-ai.js.map +0 -1
- package/dist/http-server.d.ts.map +0 -1
- package/dist/http-server.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/tab-group-archive.d.ts.map +0 -1
- package/dist/tab-group-archive.js.map +0 -1
- package/dist/tab-groups.d.ts.map +0 -1
- package/dist/tab-groups.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical Task Thread Types & Status Rule Set — Phase A
|
|
3
|
+
*
|
|
4
|
+
* AUTHORITATIVE LOCATION (FR-004): This file is the single source of truth
|
|
5
|
+
* for the Phase A canonical status vocabulary, conflict-resolution precedence,
|
|
6
|
+
* and valid lifecycle transition rules for the Comet browser surface worktree.
|
|
7
|
+
*
|
|
8
|
+
* In Phase B this document MUST link to or be replaced by the canonical rule
|
|
9
|
+
* from equa-taskthreads spec 003 (core API).
|
|
10
|
+
*
|
|
11
|
+
* Spec: specs/041-task-thread-sync/spec.md
|
|
12
|
+
* Plan: specs/041-task-thread-sync/plan.md §Canonical Status Rule Set
|
|
13
|
+
*/
|
|
14
|
+
/** Terminal statuses — once set by the lifecycle layer, cannot revert (FR-008) */
|
|
15
|
+
export const TERMINAL_STATUSES = new Set(["Completed", "Aborted", "Archived"]);
|
|
16
|
+
export function isTerminal(status) {
|
|
17
|
+
return TERMINAL_STATUSES.has(status);
|
|
18
|
+
}
|
|
19
|
+
// ─── State Machine — Valid Transitions (FR-017, FR-019) ──────────────────────
|
|
20
|
+
/**
|
|
21
|
+
* Maps each canonical status to the set of write actions the user may invoke
|
|
22
|
+
* from that state. The extension renders exactly these buttons (FR-017).
|
|
23
|
+
*
|
|
24
|
+
* Action names match the payload `action` field for POST /api/task-threads/:id/transition.
|
|
25
|
+
*/
|
|
26
|
+
export const VALID_TRANSITIONS = {
|
|
27
|
+
Dispatched: ["Start", "Abort"],
|
|
28
|
+
Running: ["Pause", "Mark Complete", "Abort"],
|
|
29
|
+
Paused: ["Resume", "Abort"],
|
|
30
|
+
Completed: ["Archive"],
|
|
31
|
+
Aborted: ["Archive"],
|
|
32
|
+
Archived: [], // terminal — no further transitions
|
|
33
|
+
};
|
|
34
|
+
// ─── Canonical Status Resolver (FR-002, FR-006–FR-009) ───────────────────────
|
|
35
|
+
/**
|
|
36
|
+
* Derives exactly one canonical status from the union of underlying layer states.
|
|
37
|
+
*
|
|
38
|
+
* Precedence (FR-006, FR-007):
|
|
39
|
+
* 1. Lifecycle layer (highest authority — Lifecycle wins)
|
|
40
|
+
* 2. Snapshot layer
|
|
41
|
+
* 3. Session manifest layer
|
|
42
|
+
* 4. Archive layer
|
|
43
|
+
* 5. Alert log layer
|
|
44
|
+
* 6. Unknown → Archived (safe display fallback)
|
|
45
|
+
*
|
|
46
|
+
* Terminal states (Completed, Aborted, Archived) are sticky once set by
|
|
47
|
+
* the lifecycle layer (FR-008).
|
|
48
|
+
*/
|
|
49
|
+
export function resolveCanonicalStatus(layers) {
|
|
50
|
+
// 1. Lifecycle layer — highest authority
|
|
51
|
+
if (layers.lifecycle !== null) {
|
|
52
|
+
switch (layers.lifecycle) {
|
|
53
|
+
case "started": return "Running";
|
|
54
|
+
case "dispatched": return "Dispatched";
|
|
55
|
+
case "paused": return "Paused";
|
|
56
|
+
case "completed": return "Completed"; // terminal — sticky
|
|
57
|
+
case "aborted": return "Aborted"; // terminal — sticky
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// 2. Snapshot layer
|
|
61
|
+
if (layers.snapshot !== null) {
|
|
62
|
+
switch (layers.snapshot) {
|
|
63
|
+
case "success": return "Completed";
|
|
64
|
+
case "failed":
|
|
65
|
+
case "abandoned": return "Aborted";
|
|
66
|
+
case "in-progress": return "Running";
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// 3. Session manifest layer
|
|
70
|
+
if (layers.sessionManifest !== null) {
|
|
71
|
+
switch (layers.sessionManifest) {
|
|
72
|
+
case "active":
|
|
73
|
+
case "disconnecting": return "Running";
|
|
74
|
+
case "orphaned": return "Aborted"; // agent dead, no explicit transition
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// 4. Archive layer
|
|
78
|
+
if (layers.archive !== null) {
|
|
79
|
+
switch (layers.archive) {
|
|
80
|
+
case "archived":
|
|
81
|
+
case "saved": return "Archived";
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// 5. Alert log layer
|
|
85
|
+
if (layers.alertLog !== null) {
|
|
86
|
+
if (layers.alertLog === "ORPHAN_DETECTED" || layers.alertLog === "ORPHAN_REAPED") {
|
|
87
|
+
return "Aborted";
|
|
88
|
+
}
|
|
89
|
+
// Other alert types — fallthrough to Archived as safe default
|
|
90
|
+
}
|
|
91
|
+
// 6. No layer has a record — safe display fallback
|
|
92
|
+
return "Archived";
|
|
93
|
+
}
|
|
94
|
+
// ─── Transition Validation (FR-019) ──────────────────────────────────────────
|
|
95
|
+
export class InvalidTransitionError extends Error {
|
|
96
|
+
fromStatus;
|
|
97
|
+
action;
|
|
98
|
+
constructor(fromStatus, action) {
|
|
99
|
+
super(`Action "${action}" is not valid from status "${fromStatus}". ` +
|
|
100
|
+
`Valid actions: ${VALID_TRANSITIONS[fromStatus].join(", ") || "none"}.`);
|
|
101
|
+
this.fromStatus = fromStatus;
|
|
102
|
+
this.action = action;
|
|
103
|
+
this.name = "InvalidTransitionError";
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Throws InvalidTransitionError if the action is not valid from the given status.
|
|
108
|
+
* Does NOT perform the transition — call this before executing any write.
|
|
109
|
+
*/
|
|
110
|
+
export function assertValidTransition(status, action) {
|
|
111
|
+
const allowed = VALID_TRANSITIONS[status];
|
|
112
|
+
if (!allowed.includes(action)) {
|
|
113
|
+
throw new InvalidTransitionError(status, action);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=task-thread-canonical.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CodexSessionIdentity, CodexWindowBinding } from "./window-bindings.js";
|
|
1
2
|
export interface CDPTarget {
|
|
2
3
|
id: string;
|
|
3
4
|
type: string;
|
|
@@ -41,6 +42,8 @@ export interface CometState {
|
|
|
41
42
|
port: number;
|
|
42
43
|
currentUrl?: string;
|
|
43
44
|
activeTabId?: string;
|
|
45
|
+
profileId?: string;
|
|
46
|
+
profileOwner?: "agent" | "human" | "shared_legacy" | "unknown";
|
|
44
47
|
}
|
|
45
48
|
export interface NetworkIdleResult {
|
|
46
49
|
idle: boolean;
|
|
@@ -67,4 +70,238 @@ export interface TabInfo {
|
|
|
67
70
|
url: string;
|
|
68
71
|
active: boolean;
|
|
69
72
|
}
|
|
73
|
+
export type AgentActivityStatus = "active" | "idle" | "orphaned";
|
|
74
|
+
export interface ObserverAgentStatus {
|
|
75
|
+
agentId: string;
|
|
76
|
+
agentType: string;
|
|
77
|
+
label: string;
|
|
78
|
+
status: AgentActivityStatus;
|
|
79
|
+
lastHeartbeat: string;
|
|
80
|
+
lastActivity: string | null;
|
|
81
|
+
idleSince: string | null;
|
|
82
|
+
}
|
|
83
|
+
export interface ObserverTabInfo {
|
|
84
|
+
id: string;
|
|
85
|
+
url: string;
|
|
86
|
+
title: string;
|
|
87
|
+
loadState: "complete" | "loading" | "error";
|
|
88
|
+
thumbnail: string | null;
|
|
89
|
+
}
|
|
90
|
+
export interface ObserverBindingInfo {
|
|
91
|
+
bindingId: string;
|
|
92
|
+
codexSessionId: string;
|
|
93
|
+
projectThreadId: string;
|
|
94
|
+
repoSlug: string;
|
|
95
|
+
worktreePath: string;
|
|
96
|
+
branchName: string;
|
|
97
|
+
sessionKey: string;
|
|
98
|
+
role: CodexSessionIdentity["role"];
|
|
99
|
+
sidecarContextKey: string;
|
|
100
|
+
status: CodexWindowBinding["status"];
|
|
101
|
+
windowId: number;
|
|
102
|
+
tabGroupId: number | null;
|
|
103
|
+
targetId: string | null;
|
|
104
|
+
runIds: string[];
|
|
105
|
+
updatedAt: string;
|
|
106
|
+
}
|
|
107
|
+
export interface ObserverWindowBindingInfo {
|
|
108
|
+
windowId: number;
|
|
109
|
+
binding: ObserverBindingInfo | null;
|
|
110
|
+
bindingStatus: CodexWindowBinding["status"] | "unbound";
|
|
111
|
+
}
|
|
112
|
+
export interface ObserverTabGroupInfo {
|
|
113
|
+
id: number;
|
|
114
|
+
title: string;
|
|
115
|
+
color: string;
|
|
116
|
+
collapsed: boolean;
|
|
117
|
+
windowId: number;
|
|
118
|
+
tabs: ObserverTabInfo[];
|
|
119
|
+
tabCount: number;
|
|
120
|
+
agent: ObserverAgentStatus | null;
|
|
121
|
+
binding: ObserverBindingInfo | null;
|
|
122
|
+
bindingStatus: CodexWindowBinding["status"] | "unbound";
|
|
123
|
+
}
|
|
124
|
+
export interface BrowserHealth {
|
|
125
|
+
running: boolean;
|
|
126
|
+
cdpConnected: boolean;
|
|
127
|
+
extensionAvailable: boolean;
|
|
128
|
+
tabCount: number;
|
|
129
|
+
groupCount: number;
|
|
130
|
+
}
|
|
131
|
+
export interface BrowserSnapshot {
|
|
132
|
+
timestamp: string;
|
|
133
|
+
browser: BrowserHealth;
|
|
134
|
+
groups: ObserverTabGroupInfo[];
|
|
135
|
+
ungroupedTabs: ObserverTabInfo[];
|
|
136
|
+
windows: ObserverWindowBindingInfo[];
|
|
137
|
+
bindings: ObserverBindingInfo[];
|
|
138
|
+
totalTabs: number;
|
|
139
|
+
totalGroups: number;
|
|
140
|
+
}
|
|
141
|
+
export interface ObserverFilters {
|
|
142
|
+
group?: string;
|
|
143
|
+
agentId?: string;
|
|
144
|
+
urlPattern?: string;
|
|
145
|
+
thumbnails?: boolean;
|
|
146
|
+
codexIdentity?: CodexSessionIdentity;
|
|
147
|
+
}
|
|
148
|
+
export interface AgentRegistryEntry {
|
|
149
|
+
agentId: string;
|
|
150
|
+
agentType: string;
|
|
151
|
+
label: string;
|
|
152
|
+
lane: number;
|
|
153
|
+
status: string;
|
|
154
|
+
taskGroup: string | null;
|
|
155
|
+
tabGroupId: number | null;
|
|
156
|
+
tabGroupColor: string | null;
|
|
157
|
+
currentUrl: string | null;
|
|
158
|
+
taskDescription: string | null;
|
|
159
|
+
startedAt: string | null;
|
|
160
|
+
lastHeartbeat: string;
|
|
161
|
+
completedAt: string | null;
|
|
162
|
+
errorMessage: string | null;
|
|
163
|
+
capabilities?: string[];
|
|
164
|
+
}
|
|
165
|
+
export interface AgentRegistry {
|
|
166
|
+
schema: string;
|
|
167
|
+
lastUpdated: string;
|
|
168
|
+
agents: Record<string, AgentRegistryEntry>;
|
|
169
|
+
}
|
|
170
|
+
export type ConsumerRole = "orchestrator" | "subagent";
|
|
171
|
+
export type ErrorEventType = "PERPLEXITY_VOICE_MODE" | "PERPLEXITY_IDLE_NO_NAV" | "PERPLEXITY_CONTEXT_BLEED" | "BROWSER_CRASH" | "CRASH_LOOP_CAP" | "CDP_DISCONNECT" | "ORPHAN_DETECTED" | "ORPHAN_REAPED" | "DUPLICATE_PROCESS" | "PROTOCOL_VIOLATION";
|
|
172
|
+
export type ErrorSeverity = "critical" | "operational" | "warning";
|
|
173
|
+
export type AlertRoutingTarget = "operator-direct" | "orchestrator-first" | "orchestrator-only";
|
|
174
|
+
export interface DeliveryStatus {
|
|
175
|
+
macosNotification: boolean;
|
|
176
|
+
logFile: boolean;
|
|
177
|
+
mcpQueue: boolean;
|
|
178
|
+
}
|
|
179
|
+
export interface ErrorEvent {
|
|
180
|
+
id: string;
|
|
181
|
+
timestamp: string;
|
|
182
|
+
type: ErrorEventType;
|
|
183
|
+
severity: ErrorSeverity;
|
|
184
|
+
consumerId: string | null;
|
|
185
|
+
sessionKey: string | null;
|
|
186
|
+
message: string;
|
|
187
|
+
context: Record<string, unknown>;
|
|
188
|
+
suggestedAction: string;
|
|
189
|
+
delivered: DeliveryStatus;
|
|
190
|
+
}
|
|
191
|
+
export interface AlertRouting {
|
|
192
|
+
critical: AlertRoutingTarget;
|
|
193
|
+
operational: AlertRoutingTarget;
|
|
194
|
+
warning: AlertRoutingTarget;
|
|
195
|
+
}
|
|
196
|
+
export interface RoleConfig {
|
|
197
|
+
operatorId: string;
|
|
198
|
+
orchestratorAgentId: string | null;
|
|
199
|
+
}
|
|
200
|
+
export interface BridgeConfig {
|
|
201
|
+
version: string;
|
|
202
|
+
cleanup: {
|
|
203
|
+
orphanThresholdMinutes: number;
|
|
204
|
+
snapshotBeforeClose: boolean;
|
|
205
|
+
snapshotDir: string;
|
|
206
|
+
};
|
|
207
|
+
crashRecovery: {
|
|
208
|
+
maxRestarts: number;
|
|
209
|
+
windowMinutes: number;
|
|
210
|
+
autoRestart: boolean;
|
|
211
|
+
crashHistoryPath: string;
|
|
212
|
+
};
|
|
213
|
+
alerts: {
|
|
214
|
+
logPath: string;
|
|
215
|
+
macosNotifications: boolean;
|
|
216
|
+
mcpErrorQueue: boolean;
|
|
217
|
+
routing: AlertRouting;
|
|
218
|
+
};
|
|
219
|
+
roles: RoleConfig;
|
|
220
|
+
protocolEnforcement: {
|
|
221
|
+
requireConnectBeforeBrowse: boolean;
|
|
222
|
+
warnMissingTabGroup: boolean;
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
export interface TabSnapshot {
|
|
226
|
+
url: string;
|
|
227
|
+
title: string;
|
|
228
|
+
chromeTabId: number;
|
|
229
|
+
targetId: string;
|
|
230
|
+
active: boolean;
|
|
231
|
+
}
|
|
232
|
+
export interface SidecarSnapshot {
|
|
233
|
+
threadUrl: string;
|
|
234
|
+
parentTabUrl: string;
|
|
235
|
+
lastQuery: string | null;
|
|
236
|
+
}
|
|
237
|
+
export interface WindowMetadata {
|
|
238
|
+
windowId: number;
|
|
239
|
+
x: number;
|
|
240
|
+
y: number;
|
|
241
|
+
width: number;
|
|
242
|
+
height: number;
|
|
243
|
+
displayIndex: number;
|
|
244
|
+
}
|
|
245
|
+
export type SnapshotReason = "orphan-cleanup" | "completion" | "crash" | "manual";
|
|
246
|
+
export type TaskThreadStatus = "success" | "failed" | "abandoned" | "in-progress";
|
|
247
|
+
export interface TaskThreadSnapshot {
|
|
248
|
+
sessionKey: string;
|
|
249
|
+
agentId: string;
|
|
250
|
+
taskThreadId: string;
|
|
251
|
+
capturedAt: string;
|
|
252
|
+
reason: SnapshotReason;
|
|
253
|
+
taskStatus: TaskThreadStatus;
|
|
254
|
+
tabs: TabSnapshot[];
|
|
255
|
+
sidecarThreads: SidecarSnapshot[];
|
|
256
|
+
windowMetadata: WindowMetadata | null;
|
|
257
|
+
tabGroupId: number | null;
|
|
258
|
+
tabGroupColor: TabGroupColor;
|
|
259
|
+
}
|
|
260
|
+
export type SessionStatus = "active" | "disconnecting" | "orphaned";
|
|
261
|
+
export interface AgentSession {
|
|
262
|
+
agentId: string;
|
|
263
|
+
taskThreadId: string;
|
|
264
|
+
sessionKey: string;
|
|
265
|
+
targetId: string;
|
|
266
|
+
chromeTabId: number | null;
|
|
267
|
+
tabGroupId: number | null;
|
|
268
|
+
tabGroupColor: TabGroupColor;
|
|
269
|
+
createdAt: number;
|
|
270
|
+
lastActivity: number;
|
|
271
|
+
status: SessionStatus;
|
|
272
|
+
role: ConsumerRole | null;
|
|
273
|
+
sessionName?: string;
|
|
274
|
+
taskGoal?: string;
|
|
275
|
+
orchestratorUrl?: string;
|
|
276
|
+
parentSessionId?: string | null;
|
|
277
|
+
codexIdentity?: CodexSessionIdentity;
|
|
278
|
+
codexBinding?: CodexWindowBinding;
|
|
279
|
+
profileId?: string;
|
|
280
|
+
profileOwner?: "agent" | "human" | "shared_legacy" | "unknown";
|
|
281
|
+
profileAlias?: string | null;
|
|
282
|
+
}
|
|
283
|
+
export interface ManifestEntry {
|
|
284
|
+
sessionKey: string;
|
|
285
|
+
agentId: string;
|
|
286
|
+
taskThreadId: string;
|
|
287
|
+
targetId: string;
|
|
288
|
+
tabGroupId: number | null;
|
|
289
|
+
createdAt: number;
|
|
290
|
+
lastActivity: number;
|
|
291
|
+
pid: number;
|
|
292
|
+
sessionName?: string;
|
|
293
|
+
taskGoal?: string;
|
|
294
|
+
orchestratorUrl?: string;
|
|
295
|
+
role?: "orchestrator" | "subagent";
|
|
296
|
+
parentSessionId?: string | null;
|
|
297
|
+
codexIdentity?: CodexSessionIdentity;
|
|
298
|
+
codexBinding?: CodexWindowBinding;
|
|
299
|
+
profileId?: string;
|
|
300
|
+
profileOwner?: "agent" | "human" | "shared_legacy" | "unknown";
|
|
301
|
+
profileAlias?: string | null;
|
|
302
|
+
}
|
|
303
|
+
export interface SessionManifest {
|
|
304
|
+
sessions: ManifestEntry[];
|
|
305
|
+
lastUpdated: number;
|
|
306
|
+
}
|
|
70
307
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
export type CodexBindingStatus = "active" | "completed" | "stale" | "reaped" | "conflict";
|
|
2
|
+
export type CodexSessionRole = "session_agent" | "worktree_orchestrator" | "fleet_orchestrator";
|
|
3
|
+
export type ProfileOwnershipDomain = "agent" | "human" | "shared_legacy" | "unknown";
|
|
4
|
+
export interface CodexSessionIdentity {
|
|
5
|
+
codexSessionId: string;
|
|
6
|
+
projectThreadId: string;
|
|
7
|
+
projectThreadFamily?: string;
|
|
8
|
+
worktreePath: string;
|
|
9
|
+
repoSlug: string;
|
|
10
|
+
branchName: string;
|
|
11
|
+
sessionKey: string;
|
|
12
|
+
role: CodexSessionRole;
|
|
13
|
+
}
|
|
14
|
+
export interface CodexIdentityInput {
|
|
15
|
+
codexSessionId?: string;
|
|
16
|
+
projectThreadId?: string;
|
|
17
|
+
projectThreadFamily?: string;
|
|
18
|
+
worktreePath?: string;
|
|
19
|
+
repoSlug?: string;
|
|
20
|
+
branchName?: string;
|
|
21
|
+
sessionKey?: string;
|
|
22
|
+
role?: string;
|
|
23
|
+
strict?: boolean;
|
|
24
|
+
fallbackAgentId?: string;
|
|
25
|
+
fallbackTaskThreadId?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface CodexIdentityContext {
|
|
28
|
+
env?: NodeJS.ProcessEnv;
|
|
29
|
+
cwd?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface CodexWindowBinding extends CodexSessionIdentity {
|
|
32
|
+
bindingId: string;
|
|
33
|
+
runIds: string[];
|
|
34
|
+
windowId: number;
|
|
35
|
+
tabGroupId: number | null;
|
|
36
|
+
targetId: string | null;
|
|
37
|
+
profileId: string;
|
|
38
|
+
profileAlias: string | null;
|
|
39
|
+
profileOwner: ProfileOwnershipDomain;
|
|
40
|
+
sidecarContextKey: string;
|
|
41
|
+
status: CodexBindingStatus;
|
|
42
|
+
createdAt: string;
|
|
43
|
+
updatedAt: string;
|
|
44
|
+
}
|
|
45
|
+
export interface RunBindingIndexEntry {
|
|
46
|
+
runId: string;
|
|
47
|
+
bindingId: string;
|
|
48
|
+
updatedAt: string;
|
|
49
|
+
}
|
|
50
|
+
export interface WindowBindingSnapshot {
|
|
51
|
+
version: 1;
|
|
52
|
+
bindings: Record<string, CodexWindowBinding>;
|
|
53
|
+
runBindingIndex: Record<string, RunBindingIndexEntry>;
|
|
54
|
+
updatedAt: string;
|
|
55
|
+
}
|
|
56
|
+
export interface CreateBindingInput extends CodexSessionIdentity {
|
|
57
|
+
windowId: number;
|
|
58
|
+
tabGroupId?: number | null;
|
|
59
|
+
targetId?: string | null;
|
|
60
|
+
profileId?: string;
|
|
61
|
+
profileAlias?: string | null;
|
|
62
|
+
profileOwner?: ProfileOwnershipDomain;
|
|
63
|
+
runIds?: string[];
|
|
64
|
+
sidecarContextKey?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface CreateOrReuseResult {
|
|
67
|
+
binding: CodexWindowBinding;
|
|
68
|
+
action: "created" | "reused" | "repaired";
|
|
69
|
+
}
|
|
70
|
+
export interface BindingMutationOptions {
|
|
71
|
+
targetBindingId?: string;
|
|
72
|
+
reason?: string;
|
|
73
|
+
audit?: boolean;
|
|
74
|
+
}
|
|
75
|
+
export declare class WindowBindingConflictError extends Error {
|
|
76
|
+
readonly conflicts: CodexWindowBinding[];
|
|
77
|
+
constructor(message: string, conflicts: CodexWindowBinding[]);
|
|
78
|
+
}
|
|
79
|
+
export declare class CodexIdentityError extends Error {
|
|
80
|
+
readonly missingFields: string[];
|
|
81
|
+
constructor(message: string, missingFields: string[]);
|
|
82
|
+
}
|
|
83
|
+
export declare function resolveCodexSessionRole(role?: string): CodexSessionRole;
|
|
84
|
+
export declare function deriveCodexSessionIdentity(input?: CodexIdentityInput, context?: CodexIdentityContext): CodexSessionIdentity;
|
|
85
|
+
export declare function isBindingInWorktreeScope(caller: CodexSessionIdentity, binding: CodexWindowBinding): boolean;
|
|
86
|
+
export declare function canReadBinding(caller: CodexSessionIdentity, binding: CodexWindowBinding): boolean;
|
|
87
|
+
export declare function canMutateBinding(caller: CodexSessionIdentity, binding: CodexWindowBinding, options?: BindingMutationOptions): boolean;
|
|
88
|
+
export declare function assertBindingMutationAllowed(caller: CodexSessionIdentity, binding: CodexWindowBinding, options?: BindingMutationOptions): void;
|
|
89
|
+
export declare function normalizeProfileOwner(owner?: string): ProfileOwnershipDomain;
|
|
90
|
+
export declare function assertBindingProfileAllowed(identity: CodexSessionIdentity, binding: Pick<CodexWindowBinding, "profileId" | "profileOwner">): void;
|
|
91
|
+
export declare class CodexWindowBindingStore {
|
|
92
|
+
private readonly file;
|
|
93
|
+
private readonly dir;
|
|
94
|
+
private readonly lockDir;
|
|
95
|
+
constructor(storePath?: string);
|
|
96
|
+
get path(): string;
|
|
97
|
+
load(): Promise<WindowBindingSnapshot>;
|
|
98
|
+
list(): Promise<CodexWindowBinding[]>;
|
|
99
|
+
get(bindingId: string): Promise<CodexWindowBinding | null>;
|
|
100
|
+
findActiveByIdentity(identity: CodexSessionIdentity): Promise<CodexWindowBinding | null>;
|
|
101
|
+
findByRunId(runId: string): Promise<CodexWindowBinding | null>;
|
|
102
|
+
createOrReuse(input: CreateBindingInput): Promise<CreateOrReuseResult>;
|
|
103
|
+
addRunId(bindingId: string, runId: string): Promise<CodexWindowBinding>;
|
|
104
|
+
transition(bindingId: string, status: Exclude<CodexBindingStatus, "conflict">): Promise<CodexWindowBinding>;
|
|
105
|
+
transitionByRunId(runId: string, status: Exclude<CodexBindingStatus, "conflict">): Promise<CodexWindowBinding | null>;
|
|
106
|
+
classifyConflicts(): Promise<CodexWindowBinding[]>;
|
|
107
|
+
markStaleForMissingWindows(liveWindowIds: Iterable<number>): Promise<CodexWindowBinding[]>;
|
|
108
|
+
private assertNoActiveConflicts;
|
|
109
|
+
private findActiveConflicts;
|
|
110
|
+
}
|
|
111
|
+
export declare const windowBindingStore: CodexWindowBindingStore;
|
|
112
|
+
//# sourceMappingURL=window-bindings.d.ts.map
|