@shawnowen/comet-mcp 2.3.1 → 2.4.2

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.
Files changed (65) hide show
  1. package/README.md +97 -19
  2. package/dist/alert-dispatcher.d.ts +23 -0
  3. package/dist/alert-dispatcher.js +101 -0
  4. package/dist/binding-reaper.d.ts +46 -0
  5. package/dist/binding-reaper.js +73 -0
  6. package/dist/bound-session.d.ts +23 -0
  7. package/dist/bound-session.js +119 -0
  8. package/dist/bridge-config.d.ts +6 -0
  9. package/dist/bridge-config.js +78 -0
  10. package/dist/cdp-client.d.ts +40 -4
  11. package/dist/cdp-client.js +502 -155
  12. package/dist/comet-ai.d.ts +15 -0
  13. package/dist/comet-ai.js +114 -38
  14. package/dist/delegate-binding.d.ts +19 -0
  15. package/dist/delegate-binding.js +73 -0
  16. package/dist/http-server.js +2188 -47
  17. package/dist/index.js +3545 -788
  18. package/dist/observer.d.ts +47 -0
  19. package/dist/observer.js +516 -0
  20. package/dist/project-config.d.ts +46 -0
  21. package/dist/project-config.js +166 -0
  22. package/dist/session-registry.d.ts +57 -0
  23. package/dist/session-registry.js +500 -0
  24. package/dist/sidecar-artifacts.d.ts +49 -0
  25. package/dist/sidecar-artifacts.js +146 -0
  26. package/dist/snapshot-capture.d.ts +3 -0
  27. package/dist/snapshot-capture.js +91 -0
  28. package/dist/tab-group-archive.js +3 -1
  29. package/dist/tab-groups.d.ts +28 -1
  30. package/dist/tab-groups.js +205 -3
  31. package/dist/types.d.ts +237 -0
  32. package/dist/window-bindings.d.ts +160 -0
  33. package/dist/window-bindings.js +561 -0
  34. package/extension/background.js +1577 -300
  35. package/extension/icons/icon.svg +9 -0
  36. package/extension/icons/icon128.png +0 -0
  37. package/extension/icons/icon16.png +0 -0
  38. package/extension/icons/icon48.png +0 -0
  39. package/extension/manifest.json +34 -4
  40. package/extension/perplexity-capability-manifest.json +1181 -0
  41. package/extension/perplexity-capability-manifest.schema.json +142 -0
  42. package/extension/session-logic.js +3054 -0
  43. package/extension/session-manager.html +311 -0
  44. package/extension/sidepanel.css +5338 -528
  45. package/extension/sidepanel.html +282 -2
  46. package/extension/sidepanel.js +10604 -950
  47. package/extension/window-policy.js +162 -0
  48. package/package.json +10 -7
  49. package/vendor/lifecycle-mcp-adapter.mjs +103 -0
  50. package/vendor/lifecycle-metadata.mjs +252 -0
  51. package/vendor/readiness-report.mjs +742 -0
  52. package/dist/cdp-client.d.ts.map +0 -1
  53. package/dist/cdp-client.js.map +0 -1
  54. package/dist/comet-ai.d.ts.map +0 -1
  55. package/dist/comet-ai.js.map +0 -1
  56. package/dist/http-server.d.ts.map +0 -1
  57. package/dist/http-server.js.map +0 -1
  58. package/dist/index.d.ts.map +0 -1
  59. package/dist/index.js.map +0 -1
  60. package/dist/tab-group-archive.d.ts.map +0 -1
  61. package/dist/tab-group-archive.js.map +0 -1
  62. package/dist/tab-groups.d.ts.map +0 -1
  63. package/dist/tab-groups.js.map +0 -1
  64. package/dist/types.d.ts.map +0 -1
  65. package/dist/types.js.map +0 -1
@@ -0,0 +1,160 @@
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
+ * ISO 8601 timestamp first recorded when a reap cycle found this binding's
46
+ * window absent from the live CDP set. Cleared when the window reappears.
47
+ * Drives the TTL grace period in {@link CodexWindowBindingStore.reapExpiredBindings}.
48
+ * Optional/absent on pre-existing records (backward-compatible).
49
+ */
50
+ missingSince?: string;
51
+ }
52
+ export interface RunBindingIndexEntry {
53
+ runId: string;
54
+ bindingId: string;
55
+ updatedAt: string;
56
+ }
57
+ export interface WindowBindingSnapshot {
58
+ version: 1;
59
+ bindings: Record<string, CodexWindowBinding>;
60
+ runBindingIndex: Record<string, RunBindingIndexEntry>;
61
+ updatedAt: string;
62
+ }
63
+ export interface CreateBindingInput extends CodexSessionIdentity {
64
+ windowId: number;
65
+ tabGroupId?: number | null;
66
+ targetId?: string | null;
67
+ profileId?: string;
68
+ profileAlias?: string | null;
69
+ profileOwner?: ProfileOwnershipDomain;
70
+ runIds?: string[];
71
+ sidecarContextKey?: string;
72
+ }
73
+ export interface CreateOrReuseResult {
74
+ binding: CodexWindowBinding;
75
+ action: "created" | "reused" | "repaired";
76
+ }
77
+ export interface BindingMutationOptions {
78
+ targetBindingId?: string;
79
+ reason?: string;
80
+ audit?: boolean;
81
+ }
82
+ /** Options for {@link CodexWindowBindingStore.reapExpiredBindings}. */
83
+ export interface ReapOptions {
84
+ /** Distinct windowIds currently live in the browser (CDP). */
85
+ liveWindowIds: Iterable<number>;
86
+ /** Grace period in ms a binding may stay missing before it is reaped. */
87
+ ttlMs: number;
88
+ /** Injectable clock (ms epoch). Defaults to Date.now(). */
89
+ now?: number;
90
+ /**
91
+ * Archive callback invoked BEFORE a binding is deleted (e.g. recovery
92
+ * snapshot + ORPHAN_REAPED alert). If it throws, the binding is NOT deleted
93
+ * that cycle (fail-safe).
94
+ */
95
+ archive?: (binding: CodexWindowBinding) => Promise<void>;
96
+ /**
97
+ * Predicate for profile-owned bindings the auto-reaper must skip.
98
+ * Default: profileOwner is set and not "agent".
99
+ */
100
+ isProfileOwned?: (binding: CodexWindowBinding) => boolean;
101
+ }
102
+ /** Per-cycle counts returned by {@link CodexWindowBindingStore.reapExpiredBindings}. */
103
+ export interface ReapCycleResult {
104
+ evaluated: number;
105
+ newlyMissing: number;
106
+ retainedLive: number;
107
+ reaped: number;
108
+ skippedOwned: number;
109
+ reapedBindingIds: string[];
110
+ }
111
+ export declare class WindowBindingConflictError extends Error {
112
+ readonly conflicts: CodexWindowBinding[];
113
+ constructor(message: string, conflicts: CodexWindowBinding[]);
114
+ }
115
+ export declare class CodexIdentityError extends Error {
116
+ readonly missingFields: string[];
117
+ constructor(message: string, missingFields: string[]);
118
+ }
119
+ export declare function resolveCodexSessionRole(role?: string): CodexSessionRole;
120
+ export declare function deriveCodexSessionIdentity(input?: CodexIdentityInput, context?: CodexIdentityContext): CodexSessionIdentity;
121
+ export declare function isBindingInWorktreeScope(caller: CodexSessionIdentity, binding: CodexWindowBinding): boolean;
122
+ export declare function canReadBinding(caller: CodexSessionIdentity, binding: CodexWindowBinding): boolean;
123
+ export declare function canMutateBinding(caller: CodexSessionIdentity, binding: CodexWindowBinding, options?: BindingMutationOptions): boolean;
124
+ export declare function assertBindingMutationAllowed(caller: CodexSessionIdentity, binding: CodexWindowBinding, options?: BindingMutationOptions): void;
125
+ export declare function normalizeProfileOwner(owner?: string): ProfileOwnershipDomain;
126
+ export declare function assertBindingProfileAllowed(identity: CodexSessionIdentity, binding: Pick<CodexWindowBinding, "profileId" | "profileOwner">): void;
127
+ export declare class CodexWindowBindingStore {
128
+ private readonly file;
129
+ private readonly dir;
130
+ private readonly lockDir;
131
+ constructor(storePath?: string);
132
+ get path(): string;
133
+ load(): Promise<WindowBindingSnapshot>;
134
+ list(): Promise<CodexWindowBinding[]>;
135
+ get(bindingId: string): Promise<CodexWindowBinding | null>;
136
+ findActiveByIdentity(identity: CodexSessionIdentity): Promise<CodexWindowBinding | null>;
137
+ findByRunId(runId: string): Promise<CodexWindowBinding | null>;
138
+ createOrReuse(input: CreateBindingInput): Promise<CreateOrReuseResult>;
139
+ addRunId(bindingId: string, runId: string): Promise<CodexWindowBinding>;
140
+ transition(bindingId: string, status: Exclude<CodexBindingStatus, "conflict">): Promise<CodexWindowBinding>;
141
+ transitionByRunId(runId: string, status: Exclude<CodexBindingStatus, "conflict">): Promise<CodexWindowBinding | null>;
142
+ classifyConflicts(): Promise<CodexWindowBinding[]>;
143
+ markStaleForMissingWindows(liveWindowIds: Iterable<number>): Promise<CodexWindowBinding[]>;
144
+ /**
145
+ * Reconcile every binding against the live window set and reap (delete) those
146
+ * whose window has been missing for at least {@link ReapOptions.ttlMs}.
147
+ *
148
+ * - Window live → clear `missingSince`, reactivate if the reaper marked it stale, retain.
149
+ * - Window missing, no `missingSince` → record `missingSince=now`, mark stale, retain (grace starts).
150
+ * - Window missing ≥ TTL, profile-owned → skip.
151
+ * - Window missing ≥ TTL, not owned → `archive()` then delete.
152
+ *
153
+ * Atomic + file-locked + idempotent. A no-op when nothing needs changing.
154
+ */
155
+ reapExpiredBindings(opts: ReapOptions): Promise<ReapCycleResult>;
156
+ private assertNoActiveConflicts;
157
+ private findActiveConflicts;
158
+ }
159
+ export declare const windowBindingStore: CodexWindowBindingStore;
160
+ //# sourceMappingURL=window-bindings.d.ts.map