@agent-deck/shared 2.5.1 → 2.5.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.
@@ -0,0 +1,167 @@
1
+ /** Shared recovery sentence for Cursor MCP diagnostics and docs (NOT-50, pure-MCP form NOT-567). */
2
+ export declare const CURSOR_MCP_RECOVERY_HINT = "If Agent Deck tools are missing in Cursor, run `agent-deck setup --client cursor`, approve the project agent-deck server, run `agent-deck use <deck>` in the folder, then reload MCP.";
3
+ export type McpClient = 'cursor' | 'claude' | 'claude-desktop' | 'muse' | 'codex';
4
+ export type SetupScope = 'global' | 'project';
5
+ /** Muse user settings require this exact schema version (NOT-387). */
6
+ export declare const MUSE_SCHEMA_VERSION = 1;
7
+ export interface McpEndpoint {
8
+ host: string;
9
+ mcpPort: number;
10
+ }
11
+ export declare function buildMcpUrl({ host, mcpPort }: McpEndpoint): string;
12
+ /** Muse honors XDG_CONFIG_HOME for its user settings; otherwise ~/.config. */
13
+ export declare function resolveMuseGlobalConfigDir(home?: string): string;
14
+ export declare function resolveConfigPath(client: McpClient, scope: SetupScope, cwd?: string): string;
15
+ /** Pure-HTTP Codex entry: URL plus the workspace header only (NOT-563). */
16
+ export type CodexAgentDeckEntry = {
17
+ url: string;
18
+ http_headers: Record<string, string>;
19
+ };
20
+ /**
21
+ * Pure-HTTP entry for a Codex project config (`<folder>/.codex/config.toml`).
22
+ * The daemon resolves the deck from `.agent-deck/use.json` — no deck id here.
23
+ */
24
+ export declare function buildCodexAgentDeckEntry(endpoint: McpEndpoint, options: {
25
+ workspaceRoot: string;
26
+ }): CodexAgentDeckEntry;
27
+ /**
28
+ * Global headerless HTTP fallback entry (NOT-565, design §4): folders with
29
+ * no assignment connect everywhere over pure MCP and land in the existing
30
+ * unassigned (explain-only) session. No headers, no executable lookup.
31
+ * Per-folder entries written by `agent-deck use` use the same server name,
32
+ * so they shadow this fallback where an assignment exists.
33
+ */
34
+ export declare function buildGlobalFallbackHttpEntry(endpoint: McpEndpoint): Record<string, unknown>;
35
+ /**
36
+ * MCP client entry for the agent-deck server. Codex, Claude, Cursor, and
37
+ * Muse connect over pure HTTP (NOT-563/565/567/570/571): the workspace
38
+ * header names the folder and the daemon resolves the deck from
39
+ * `.agent-deck/use.json` — no deck id in tracked config, no executable
40
+ * lookup.
41
+ *
42
+ * A `workspaceRoot` selects the per-folder HTTP form; without one the
43
+ * client gets the global headerless HTTP fallback (NOT-565/567/570).
44
+ * Claude Desktop still uses the trusted local launcher, which reads the
45
+ * folder assignment at runtime. The retired Muse launcher shape (NOT-387:
46
+ * command/args/env only, no type or workspace pin) is never built —
47
+ * legacy entries are detected with {@link isLegacyMuseLaunchEntry} and
48
+ * converted by the upgrade path (NOT-572).
49
+ */
50
+ export declare function buildAgentDeckEntry(client: McpClient, endpoint: McpEndpoint, options?: {
51
+ workspaceRoot?: string;
52
+ }): Record<string, unknown>;
53
+ /**
54
+ * Pure-MCP HTTP entry (NOT-567): a `url` with no `command` — the
55
+ * per-folder entry carrying the workspace header, or the headerless
56
+ * global fallback. No executable lookup on the connection path.
57
+ */
58
+ export declare function isHttpAgentDeckEntry(entry: unknown): boolean;
59
+ /**
60
+ * Raw `x-agent-deck-workspace` header value from a pure-MCP HTTP entry
61
+ * (NOT-567). Returned as-is: Cursor sends header values literally, so a
62
+ * value carrying `${...}` interpolation is for the caller to flag, never
63
+ * to resolve.
64
+ */
65
+ export declare function readHttpWorkspaceHeader(entry: unknown): string | undefined;
66
+ /**
67
+ * Pre-1.7 Cursor/HTTP entries used bare `url` with no deck-assignment
68
+ * launcher. Same url-without-command shape as {@link isHttpAgentDeckEntry};
69
+ * kept under this name for the Claude legacy paths.
70
+ */
71
+ export declare function isLegacyBareHttpAgentDeckEntry(entry: unknown): boolean;
72
+ export declare function isMcpLaunchEntry(entry: unknown): boolean;
73
+ /**
74
+ * True when a JSON `agent-deck` entry is a legacy Claude Code launcher
75
+ * entry (NOT-566): an `agent-deck mcp-launch` entry carrying
76
+ * `type: 'stdio'` or an `AGENT_DECK_WORKSPACE` env pin. Every launcher
77
+ * entry `use`/`setup --client claude` ever wrote carries at least one of
78
+ * those markers — project entries carry both, global entries the type.
79
+ *
80
+ * Muse-shaped launcher entries carry the same command/args but never
81
+ * `type` or the workspace pin, so they never match here; they match
82
+ * {@link isLegacyMuseLaunchEntry} instead, and the upgrade rewrite
83
+ * handles each marker with its own conversion (NOT-572).
84
+ */
85
+ export declare function isLegacyClaudeLaunchEntry(entry: unknown): boolean;
86
+ /**
87
+ * True when a JSON `agent-deck` entry is a legacy Muse launcher entry
88
+ * (NOT-387 shape, retired NOT-572): an `agent-deck mcp-launch` entry
89
+ * with neither Claude marker — no `type: 'stdio'`, no
90
+ * `AGENT_DECK_WORKSPACE` env pin. Every launcher entry older
91
+ * `use --client muse` and `setup --client muse --scope project` wrote
92
+ * has exactly this shape (command/args/env only). Nothing builds it;
93
+ * the upgrade path converts it to the HTTP shape (or removes it when
94
+ * the folder has no assignment), and setup/use only detect it for
95
+ * legacy warnings.
96
+ */
97
+ export declare function isLegacyMuseLaunchEntry(entry: unknown): boolean;
98
+ export declare function readJsonFile(filePath: string): Record<string, unknown>;
99
+ /**
100
+ * Merge into Muse global settings: sets schema_version when absent, rejects
101
+ * an incompatible existing schema version with an actionable error (caller
102
+ * must leave the file untouched), and preserves every unrelated root key
103
+ * and MCP server. Project .mcp.json uses the plain merge — it has no
104
+ * schema_version and is shared with Claude Code.
105
+ */
106
+ export declare function mergeMuseServerConfig(existing: Record<string, unknown>, entry: Record<string, unknown>, configPath: string): Record<string, unknown>;
107
+ export declare function mergeMcpServerConfig(existing: Record<string, unknown>, entry: Record<string, unknown>): Record<string, unknown>;
108
+ export declare function writeJsonFile(filePath: string, data: Record<string, unknown>): void;
109
+ export declare function readTextFile(filePath: string): string;
110
+ export declare function writeTextFile(filePath: string, text: string): void;
111
+ export declare function escapeTomlBasicString(value: string): string;
112
+ /**
113
+ * Canonical `[mcp_servers.agent-deck]` TOML block (NOT-563). No trailing
114
+ * newline — the merge helper owns file framing.
115
+ */
116
+ export declare function formatCodexMcpSection(entry: CodexAgentDeckEntry): string;
117
+ /**
118
+ * Canonical headerless `[mcp_servers.agent-deck]` TOML block: the global
119
+ * unassigned-folder fallback (NOT-565, design §4). Same-name per-folder
120
+ * entries written by `agent-deck use` shadow it. No trailing newline —
121
+ * the merge helper owns file framing.
122
+ */
123
+ export declare function formatCodexGlobalFallbackSection(endpoint: McpEndpoint): string;
124
+ /**
125
+ * True when Codex TOML defines any `agent-deck` server entry (NOT-574):
126
+ * a managed `[mcp_servers.agent-deck]` section (or sub-table) in any
127
+ * transport, or a dotted/inline `agent-deck` key under a bare
128
+ * `[mcp_servers]` section. Other servers never match; a merely prefixed
129
+ * sibling such as `[mcp_servers.agent-deck-env]` never matches.
130
+ */
131
+ export declare function codexTomlHasAgentDeckEntry(existingText: string): boolean;
132
+ /**
133
+ * True when Codex TOML defines the `agent-deck` server through the legacy
134
+ * stdio launcher (NOT-566): a managed `[mcp_servers.agent-deck]` section
135
+ * (or sub-table) whose body mentions `mcp-launch`, or a dotted/inline
136
+ * `agent-deck` key under a bare `[mcp_servers]` section mentioning it.
137
+ * Pure-HTTP sections, custom entries, and other servers never match —
138
+ * only what the legacy-upgrade rewrite owns.
139
+ */
140
+ export declare function codexTomlHasLauncherEntry(existingText: string): boolean;
141
+ /**
142
+ * Merge our managed section into existing Codex TOML, preserving every
143
+ * unrelated byte. Stale agent-deck content in any form is removed first:
144
+ * the parent section, every `[mcp_servers.agent-deck.<sub>]` sub-table
145
+ * wherever it sits, and dotted/inline `agent-deck` keys under a bare
146
+ * `[mcp_servers]` section (multi-line inline tables included). The first
147
+ * managed section is replaced in place with its header normalized to the
148
+ * bare form; otherwise the section is appended after a blank separator.
149
+ * Idempotent: merging twice yields byte-identical text. The result ends
150
+ * with exactly one newline when the section is the last content.
151
+ */
152
+ export declare function mergeCodexTomlConfig(existingText: string, section: string): string;
153
+ /**
154
+ * NOT-597: shared per-folder writer used by `agent-deck use` and by the
155
+ * daemon's human-approved assignment path. Writes only inside
156
+ * `workspaceRoot` (project scope): JSON entries via
157
+ * `mergeMcpServerConfig`, Codex TOML via `mergeCodexTomlConfig`.
158
+ * Callers pass the explicit client list; `use` maps its `--client` flag,
159
+ * the daemon passes cursor+claude+codex so later sessions start assigned
160
+ * regardless of host. Never touches the global headerless fallback —
161
+ * that is `setup`'s job.
162
+ */
163
+ export declare function writePerFolderMcpEntries(workspaceRoot: string, endpoint: McpEndpoint, clients: McpClient[]): Array<{
164
+ client: McpClient;
165
+ path: string;
166
+ }>;
167
+ //# sourceMappingURL=mcp-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-config.d.ts","sourceRoot":"","sources":["../../src/utils/mcp-config.ts"],"names":[],"mappings":"AAYA,oGAAoG;AACpG,eAAO,MAAM,wBAAwB,0LACoJ,CAAC;AAE1L,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,gBAAgB,GAAG,MAAM,GAAG,OAAO,CAAC;AAClF,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE9C,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,WAAW,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,WAAW,GAAG,MAAM,CAElE;AAED,8EAA8E;AAC9E,wBAAgB,0BAA0B,CAAC,IAAI,GAAE,MAAqB,GAAG,MAAM,CAG9E;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,UAAU,EACjB,GAAG,GAAE,MAAsB,GAC1B,MAAM,CAgCR;AAED,2EAA2E;AAC3E,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CA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