@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,166 @@
1
+ // Spec 087 / T040 / FR-006, FR-007, FR-008, FR-009
2
+ //
3
+ // Per-project configuration loader. Reads <project_root>/.comet/config.json
4
+ // when present, validates against a small schema, and re-reads on each access
5
+ // (mirrors bridge-config.ts pattern — no per-session caching of file contents).
6
+ //
7
+ // Discovery: walks upward from cwd to repo root or $HOME, looking for .comet/config.json.
8
+ // Caches only the discovered PATH for the session, not the file contents.
9
+ //
10
+ // All fields optional. Backwards-compatible: absent config = pre-Spec 087 behavior.
11
+ import { readFileSync, existsSync, statSync } from "fs";
12
+ import { homedir } from "os";
13
+ import { join, resolve, sep } from "path";
14
+ const VALID_PLAYBOOKS = new Set(["qbo", "mercury", "salt", "github", "google"]);
15
+ let discoveryCache = null;
16
+ /**
17
+ * Walk up from `cwd` to either a directory containing `.comet/config.json`,
18
+ * the user's $HOME (boundary), or filesystem root. Returns the absolute path
19
+ * to the config file, or null.
20
+ */
21
+ export function discoverProjectConfigPath(cwd = process.cwd()) {
22
+ // Cache discovery by cwd — file contents are NOT cached.
23
+ if (discoveryCache && discoveryCache.cwd === cwd) {
24
+ return discoveryCache.path;
25
+ }
26
+ const home = homedir();
27
+ let dir = resolve(cwd);
28
+ let result = null;
29
+ while (true) {
30
+ const candidate = join(dir, ".comet", "config.json");
31
+ if (existsSync(candidate)) {
32
+ try {
33
+ if (statSync(candidate).isFile()) {
34
+ result = candidate;
35
+ break;
36
+ }
37
+ }
38
+ catch {
39
+ // unreadable: keep walking
40
+ }
41
+ }
42
+ if (dir === home || dir === sep || dir === resolve(dir, ".."))
43
+ break;
44
+ dir = resolve(dir, "..");
45
+ }
46
+ discoveryCache = { cwd, path: result };
47
+ return result;
48
+ }
49
+ /** Clear the discovery cache. Test-only / on cwd change. */
50
+ export function clearProjectConfigCache() {
51
+ discoveryCache = null;
52
+ }
53
+ /**
54
+ * Validate a parsed config object. Returns the cleaned config + a list of
55
+ * warning strings for any keys that were ignored. Unknown keys are warned
56
+ * about but do not cause failure.
57
+ */
58
+ export function validateProjectConfig(raw) {
59
+ const warnings = [];
60
+ const config = {};
61
+ if (raw == null || typeof raw !== "object") {
62
+ warnings.push("project-config: root must be an object — falling back to defaults");
63
+ return { config, warnings };
64
+ }
65
+ const obj = raw;
66
+ const known = new Set([
67
+ "organization",
68
+ "default_profile",
69
+ "entity_skills",
70
+ "domain_playbooks",
71
+ "tab_group_prefix",
72
+ "google_drive_root",
73
+ "mcp_pin",
74
+ ]);
75
+ for (const key of Object.keys(obj)) {
76
+ if (!known.has(key)) {
77
+ warnings.push(`project-config: unknown key '${key}' ignored`);
78
+ }
79
+ }
80
+ if (typeof obj.organization === "string" && obj.organization.length <= 32) {
81
+ config.organization = obj.organization;
82
+ }
83
+ else if (obj.organization !== undefined) {
84
+ warnings.push("project-config: 'organization' must be a string ≤ 32 chars — ignored");
85
+ }
86
+ if (typeof obj.default_profile === "string" && /^[a-z0-9_-]{1,16}$/.test(obj.default_profile)) {
87
+ config.default_profile = obj.default_profile;
88
+ }
89
+ else if (obj.default_profile !== undefined) {
90
+ warnings.push("project-config: 'default_profile' must match /^[a-z0-9_-]{1,16}$/ — falling back to 'oe'");
91
+ }
92
+ if (Array.isArray(obj.entity_skills) && obj.entity_skills.every((x) => typeof x === "string")) {
93
+ config.entity_skills = obj.entity_skills;
94
+ }
95
+ else if (obj.entity_skills !== undefined) {
96
+ warnings.push("project-config: 'entity_skills' must be string[] — ignored");
97
+ }
98
+ if (Array.isArray(obj.domain_playbooks)) {
99
+ const valid = [];
100
+ for (const item of obj.domain_playbooks) {
101
+ if (typeof item === "string" && VALID_PLAYBOOKS.has(item)) {
102
+ valid.push(item);
103
+ }
104
+ else {
105
+ warnings.push(`project-config: unknown domain_playbook '${item}' ignored`);
106
+ }
107
+ }
108
+ if (valid.length > 0)
109
+ config.domain_playbooks = valid;
110
+ }
111
+ else if (obj.domain_playbooks !== undefined) {
112
+ warnings.push("project-config: 'domain_playbooks' must be string[] — ignored");
113
+ }
114
+ if (typeof obj.tab_group_prefix === "string" &&
115
+ obj.tab_group_prefix.length <= 16 &&
116
+ !/[,:]/.test(obj.tab_group_prefix)) {
117
+ config.tab_group_prefix = obj.tab_group_prefix;
118
+ }
119
+ else if (obj.tab_group_prefix !== undefined) {
120
+ warnings.push("project-config: 'tab_group_prefix' must be ≤ 16 chars with no comma or colon — ignored");
121
+ }
122
+ if (typeof obj.google_drive_root === "string" &&
123
+ (obj.google_drive_root.startsWith("drive://") ||
124
+ obj.google_drive_root.startsWith("https://drive.google.com/"))) {
125
+ config.google_drive_root = obj.google_drive_root;
126
+ }
127
+ else if (obj.google_drive_root !== undefined) {
128
+ warnings.push("project-config: 'google_drive_root' must start with drive:// or https://drive.google.com/ — ignored");
129
+ }
130
+ if (typeof obj.mcp_pin === "string" && /^\d+\.\d+\.\d+(-[A-Za-z0-9.-]+)?$/.test(obj.mcp_pin)) {
131
+ config.mcp_pin = obj.mcp_pin;
132
+ }
133
+ else if (obj.mcp_pin !== undefined) {
134
+ warnings.push("project-config: 'mcp_pin' must be a semver string — ignored");
135
+ }
136
+ return { config, warnings };
137
+ }
138
+ /**
139
+ * Read and validate the project config. Returns an empty config + warnings if
140
+ * the file is absent, unreadable, or invalid JSON. NEVER throws.
141
+ *
142
+ * Per Spec 087 U-1 / clarify.md C-1 (revised): re-reads on every call.
143
+ * Discovery (walking up from cwd) IS cached by cwd; file contents are NOT.
144
+ */
145
+ export function readProjectConfig(cwd = process.cwd()) {
146
+ const path = discoverProjectConfigPath(cwd);
147
+ if (!path) {
148
+ return { config: {}, path: null, warnings: [] };
149
+ }
150
+ let raw;
151
+ try {
152
+ raw = JSON.parse(readFileSync(path, "utf8"));
153
+ }
154
+ catch (err) {
155
+ return {
156
+ config: {},
157
+ path,
158
+ warnings: [
159
+ `project-config: failed to parse ${path} — ${err.message} — falling back to defaults`,
160
+ ],
161
+ };
162
+ }
163
+ const { config, warnings } = validateProjectConfig(raw);
164
+ return { config, path, warnings };
165
+ }
166
+ //# sourceMappingURL=project-config.js.map
@@ -0,0 +1,57 @@
1
+ import { CometCDPClient } from "./cdp-client.js";
2
+ import { CometAI } from "./comet-ai.js";
3
+ import type { AgentSession, ManifestEntry, TabGroupColor, ConsumerRole } from "./types.js";
4
+ export interface RegisterOptions {
5
+ agentId?: string;
6
+ taskThreadId?: string;
7
+ url?: string;
8
+ tabGroupColor?: TabGroupColor;
9
+ port?: number;
10
+ role?: ConsumerRole;
11
+ taskGoal?: string;
12
+ codexSessionId?: string;
13
+ projectThreadId?: string;
14
+ projectThreadFamily?: string;
15
+ worktreePath?: string;
16
+ repoSlug?: string;
17
+ branchName?: string;
18
+ codexSessionRole?: string;
19
+ codexSessionKey?: string;
20
+ strictCodexIdentity?: boolean;
21
+ profile?: string;
22
+ }
23
+ export declare function generateSessionName(taskGoal: string): string;
24
+ export interface ReleaseOptions {
25
+ closeTabs?: boolean;
26
+ updateGroupColor?: TabGroupColor;
27
+ taskStatus?: "success" | "failed" | "abandoned" | "in-progress";
28
+ }
29
+ export declare class SessionRegistry {
30
+ private sessions;
31
+ private currentSessionKey;
32
+ private tabGroupMutex;
33
+ register(options?: RegisterOptions): Promise<AgentSession & {
34
+ cdpClient: CometCDPClient;
35
+ cometAI: CometAI;
36
+ }>;
37
+ get(sessionKey: string): (AgentSession & {
38
+ cdpClient: CometCDPClient;
39
+ cometAI: CometAI;
40
+ }) | undefined;
41
+ getCurrent(): (AgentSession & {
42
+ cdpClient: CometCDPClient;
43
+ cometAI: CometAI;
44
+ }) | undefined;
45
+ updateSessionUrl(sessionKey: string, orchestratorUrl: string): void;
46
+ getManifestEntryByThread(taskThreadId: string): ManifestEntry | undefined;
47
+ release(sessionKey: string, options?: ReleaseOptions): Promise<void>;
48
+ reapOrphans(): Promise<number>;
49
+ ensureBrowserRunning(port?: number): Promise<string>;
50
+ private createTabGroup;
51
+ private getWindowIdForTarget;
52
+ private loadManifest;
53
+ private writeManifest;
54
+ private persistManifest;
55
+ }
56
+ export declare const sessionRegistry: SessionRegistry;
57
+ //# sourceMappingURL=session-registry.d.ts.map