@awesomate/hosting-mcp 0.171.28 → 0.171.43

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awesomate/hosting-mcp",
3
- "version": "0.171.28",
3
+ "version": "0.171.43",
4
4
  "description": "Awesomate MCP server — lets Claude manage your Awesomate WordPress hosting, plan, limits, n8n automations, and build Node/static apps + databases",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -20,7 +20,7 @@
20
20
  "build": "esbuild src/index.ts --bundle --platform=node --target=node18 --format=esm --outfile=dist/index.js --banner:js='#!/usr/bin/env node\nimport { createRequire as __awmCreateRequire } from \"node:module\"; const require = __awmCreateRequire(import.meta.url);' --external:node:*",
21
21
  "build:chat": "esbuild src/chat.ts --bundle --platform=node --target=node20 --format=cjs --outfile=dist-chat/chat.cjs --external:node:*",
22
22
  "typecheck": "tsc --noEmit",
23
- "test": "npm run build && esbuild src/config.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/config.mjs --external:node:* && esbuild src/knowledge.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/knowledge.mjs --banner:js='import { createRequire as __awmCreateRequire } from \"node:module\"; const require = __awmCreateRequire(import.meta.url);' --external:node:* && esbuild src/skills.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/skills.mjs --external:node:* && esbuild src/features.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/features.mjs --external:node:* && esbuild src/scopes.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/scopes.mjs --external:node:* && esbuild src/http.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/http.mjs --banner:js='import { createRequire as __awmCreateRequire } from \"node:module\"; const require = __awmCreateRequire(import.meta.url);' --external:node:* && esbuild src/files.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/files.mjs --banner:js='import { createRequire as __awmCreateRequire } from \"node:module\"; const require = __awmCreateRequire(import.meta.url);' --external:node:* && esbuild src/scenes.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/scenes.mjs --banner:js='import { createRequire as __awmCreateRequire } from \"node:module\"; const require = __awmCreateRequire(import.meta.url);' --external:node:* && esbuild test/registrar.entry.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/registrar.mjs --banner:js='import { createRequire as __awmCreateRequire } from \"node:module\"; const require = __awmCreateRequire(import.meta.url);' --external:node:* && esbuild src/chat.ts --bundle --platform=node --target=node20 --format=esm --outfile=test/.build/chat.mjs --banner:js='import { createRequire as __awmCreateRequire } from \"node:module\"; const require = __awmCreateRequire(import.meta.url);' --external:node:* && esbuild ../server/src/lib/keys/chat-key-rules.ts --bundle --platform=node --target=node20 --format=esm --outfile=test/.build/chat-key-rules.mjs && node --test --test-timeout=60000 --test-force-exit test/*.test.mjs",
23
+ "test": "npm run build && esbuild src/config.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/config.mjs --external:node:* && esbuild src/knowledge.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/knowledge.mjs --banner:js='import { createRequire as __awmCreateRequire } from \"node:module\"; const require = __awmCreateRequire(import.meta.url);' --external:node:* && esbuild src/skills.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/skills.mjs --external:node:* && esbuild src/client.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/client.mjs --external:node:* && esbuild src/features.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/features.mjs --external:node:* && esbuild src/scopes.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/scopes.mjs --external:node:* && esbuild src/http.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/http.mjs --banner:js='import { createRequire as __awmCreateRequire } from \"node:module\"; const require = __awmCreateRequire(import.meta.url);' --external:node:* && esbuild src/files.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/files.mjs --banner:js='import { createRequire as __awmCreateRequire } from \"node:module\"; const require = __awmCreateRequire(import.meta.url);' --external:node:* && esbuild src/scenes.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/scenes.mjs --banner:js='import { createRequire as __awmCreateRequire } from \"node:module\"; const require = __awmCreateRequire(import.meta.url);' --external:node:* && esbuild test/registrar.entry.ts --bundle --platform=node --target=node18 --format=esm --outfile=test/.build/registrar.mjs --banner:js='import { createRequire as __awmCreateRequire } from \"node:module\"; const require = __awmCreateRequire(import.meta.url);' --external:node:* && esbuild src/chat.ts --bundle --platform=node --target=node20 --format=esm --outfile=test/.build/chat.mjs --banner:js='import { createRequire as __awmCreateRequire } from \"node:module\"; const require = __awmCreateRequire(import.meta.url);' --external:node:* && esbuild ../server/src/lib/keys/chat-key-rules.ts --bundle --platform=node --target=node20 --format=esm --outfile=test/.build/chat-key-rules.mjs && node --test --test-timeout=60000 --test-force-exit test/*.test.mjs",
24
24
  "prepublishOnly": "npm run typecheck && npm run test"
25
25
  },
26
26
  "dependencies": {
@@ -1,5 +1,30 @@
1
1
  {
2
2
  "versions": [
3
+ {"version": "0.171.43", "highlights": ["Setting up a business starts with its documents: the quickstart suggests \"Set up my business documents\", the business map skill starts a new business's 16 documents (research, then the open questions) before the map rounds, the Knowledge skill checks for the approved business documents' own copies in Knowledge (tagged business-doc) before ingesting the same facts, and the hosting skill reads the documents for a writing job with read 'context' and a purpose."]},
4
+ {"version": "0.171.42", "highlights": ["awesomate_files now only reads (status, usage, list, search, get_link, recent, trash, share_links) and awesomate_files_change makes every change (download to this computer, upload, save_url, save_link, mkdir, move, copy, make_public, make_private, delete, restore, empty_trash, extract, context_scan, share_link, stop_share_link). New: usage shows where the space goes and the largest files; status says when Files is nearly full or full; get_link opens the hub at the file's folder; a search date with no time is the business's own day; a download to a folder ending in / makes it; make_public says when it left a private folder empty; only the account owner can empty the Bin. On a Claude or ChatGPT connection Files can be read, and folders made, files moved, and copies saved from a web address or kept as links, inside Company files only; chat stops a share link but never makes one, and never makes a file public, deletes or replaces one. A connection made before this gets Files when it is made again."]},
5
+ {"version": "0.171.41", "highlights": ["On a Claude or ChatGPT connection where the account has it switched on, awesomate_ask_person asks a person for you: when you ask for something chat can't do (switching an automation on or off, taking an FAQ down, merging people and the like) it puts one card on that person's Tasks in the hub, linking the page where they do it. Nothing changes until they do. Needs Tasks; never on a read-only connection. Claude Code is unchanged."]},
6
+ {"version": "0.171.40", "highlights": ["On a Claude or ChatGPT connection where the account has it switched on, the chat server offers the hub's own agents: awesomate_agents (list, get, workflows, and try: the agent's draft answers one message from its Knowledge as it would a customer; no action runs and nothing is kept) and awesomate_agent_website. Changing an agent stays in Claude Code or the hub. Claude Code is unchanged."]},
7
+ {"version": "0.171.39", "highlights": ["awesomate_crm_contacts find {text} finds people by anything at once, each with why: their name, email or company, a phone number in any spelling (0400 123 123 finds +61400123123), a support ticket's reference or subject words, or a day a booking falls on. activity {id, types?, before?} lists everything with one person, newest first. Both need the person's timeline on the account. awesomate_support_desk list and read carry each ticket's contact_id and needs_person (the AI handed it to a person and nobody on the team has replied since)."]},
8
+ {"version": "0.171.38", "highlights": ["awesomate_get_context's features list includes first_week: whether the account was given the first week path at sign-up (Your business, Your website, Your enquiry agent, Your marketing helper, then Automations). The steps and which one is next show on the account's Home in the hub."]},
9
+ {"version": "0.171.37", "highlights": ["awesomate_files restore brings one thing back from the trash: to the folder it was deleted from, or to private/Restored when it was deleted outside the hub, under a new name when that one is taken. trash says where each would go back to. Putting something back into public/ needs your yes."]},
10
+ {"version": "0.171.36", "highlights": ["awesomate_files save_url copies a file at an https address into Files (up to 50 MB), so a picture or video on a link that expires (a Kie result) gets a lasting address of its own; save_link keeps a link that should stay external (a YouTube video, a Canva design) as a small .url file that lists, moves and searches like any file. Saving into public/ needs your yes, and a web page, an SVG or a script never goes there."]},
11
+ {"version": "0.171.35", "highlights": ["awesomate_files get_link gives a file's public address (when it is public), the Files page in the hub and the Scope and Path a Local Files node needs; list says for each folder and file whether your agents answer from it and at which level. awesomate_get_context lists Files among the features, and awesomate_get_limits shows Files space used and allowed."]},
12
+ {"version": "0.171.34", "highlights": ["awesomate_files can share one private file without making it public: share_link gives a link that works for 1 to 90 days (7 by default), share_links lists them with their downloads, and stop_share_link stops one at once. Moving the file out of Company files, making it public or deleting it stops its links, and Claude says so."]},
13
+ {
14
+ "version": "0.171.33",
15
+ "highlights": [
16
+ "awesomate_n8n_executions now says n8n keeps 14 days of runs (at most 10,000), so an empty page past the end means no more runs still kept. Claude also calls n8n's MCP switch Instance-level MCP, the name n8n uses."
17
+ ]
18
+ },
19
+ {
20
+ "version": "0.171.32",
21
+ "highlights": [
22
+ "awesomate_knowledge_agents_change: create {template: 'website-enquiry', name?} makes the account's website enquiry agent as a draft from its approved business documents (only where features.enquiry_agent is available); the answer lists what it answers from and links Your business, where the owner confirms what visitors may see and makes it live. awesomate_knowledge_agents list and get carry template, template_version and template_update_waiting on an agent made from a template"
23
+ ]
24
+ },
25
+ {"version": "0.171.31", "highlights": ["awesomate_business_map with what roles now lists each role with its id as well as its name, so Claude can use the ids when it changes a role instead of guessing"]},
26
+ {"version": "0.171.30", "highlights": ["Claude Code and OpenAI Codex both connect now: the connect step detects which one you are in, registers the Awesomate server in the right place (Codex: ~/.codex/config.toml, with a longer start-up allowance for the first download), puts the skills where that client reads them (Codex: ~/.agents/skills) and tells you to restart the right app. Updating skills refreshes both copies when both are installed"]},
27
+ {"version": "0.171.29", "highlights": ["awesomate_files can say what changed recently: action 'recent' lists files changed in the last days (by anyone, automations included) and who made each change through the hub, and 'search' takes modifiedAfter, modifiedBefore and sort:'newest' to find files by date"]},
3
28
  {"version": "0.171.28", "highlights": ["Behind the scenes: each request now tells the hub which Claude app and version sent it, and passes along a trace id when Claude Code sends one, so your account's history can later show what was done through Claude. Nothing changes in what you can ask for"]},
4
29
  {"version": "0.171.27", "highlights": ["New tools awesomate_help_centre and awesomate_help_centre_change: read and write your business's own help centre (topics, and articles as drafts), and publish, take down or archive an article, each only after you say yes. They need a key with help centre writing, which the account owner switches on for one computer in the hub (Claude Code, Get my code)"]},
5
30
  {
@@ -67,7 +67,15 @@ what is waiting in Tasks and carry on once they have accepted it.
67
67
  1. **Learn the business.** `awesomate_get_context` (check `features.business_map`
68
68
  is available), then `awesomate_business` for its details, then the map
69
69
  (`read` summary, `gaps`), and `awesomate_onebrain` `status` to see whether
70
- 1Brain is connected.
70
+ 1Brain is connected. Where the account has business documents
71
+ (`features.business_docs`) and you are on the owner's own key, also read `awesomate_business {read:'plan'}`: for a new
72
+ business, start them in the same session with the owner before the map rounds,
73
+ so the roles and path below are built on what they said. With the owner's yes,
74
+ `awesomate_business_decide {action:'research'}` reads their website, then ask
75
+ the questions from `awesomate_business {read:'questions'}` one at a time and
76
+ save their words with `awesomate_business_decide {action:'answer'}`
77
+ (awesomate-hosting, "Writing in the business's name" has the rules). On a team member's key
78
+ `plan` is refused: tell them the owner sets the documents up, and carry on.
71
79
  2. **Agree the customer's path and the roles with the owner** before building
72
80
  anything. The path is up to nine steps, each a phrase the owner would use
73
81
  (Find us, Ask, Get a price, Book, Pay, The job, Feedback, Review, Come back),
@@ -173,7 +181,7 @@ clears it.
173
181
 
174
182
  These are not configured by the `awesomate_knowledge_*` tools, which edit the
175
183
  Knowledge agent's instructions, scope and answers. A hub agent's actions and
176
- skills are drafted with `awesomate_agents` (read: `list`, `get`, `workflows`)
184
+ skills are drafted with `awesomate_agents` (read: `list`, `get`, `workflows`; `try` has the draft answer one message)
177
185
  and `awesomate_agents_change` (`add_action`, `update_action`, `remove_action`,
178
186
  `add_skill`, `update_skill`, `remove_skill`, `test_action`): every change lands
179
187
  in the draft, and going live is always the owner's click or yes in the hub.
@@ -106,7 +106,7 @@ connected on this machine, so the default profile was used. (A machine with one
106
106
  choose between, so its changes go through.) If you see that
107
107
  refusal, ASK the user which account the change is for, then help them pin it
108
108
  (`.awesomate.json` with `{"account": "<slug>"}` in the project folder, or
109
- `AWESOMATE_ACCOUNT=<slug>`) and restart Claude Code. Never pick an account
109
+ `AWESOMATE_ACCOUNT=<slug>`) and restart Claude Code (or Codex). Never pick an account
110
110
  yourself and never suggest setting the default profile to get past it. Even when
111
111
  pinned, say the account out loud before the first change of a session.
112
112
 
@@ -134,10 +134,19 @@ tell them where to save it (the response names the place), so the next chat
134
134
  starts with it.
135
135
 
136
136
  For anything longer than a line or two (a page, a blog post, an email series,
137
- an agent's instructions), also read the business's own documents:
138
- `awesomate_business {read:'documents'}` lists which exist, and
139
- `{read:'document', kind:'voice_guide'}` (or `brand_guide`, `business_summary`,
140
- `website_brand`) gives one in full. Write in the voice the voice guide sets.
137
+ an agent's instructions), also read the business's own documents for that job.
138
+ Where the account has business documents (`features.business_docs` in
139
+ `awesomate_get_context`), `awesomate_business {read:'context',
140
+ purpose:'website'}` (or `seo`, `blog`, `email`, `social`, `support`, `sales`,
141
+ `agent`) gives the approved documents the owner's usage map assigns to it, each
142
+ with its note on how to use it. It reads at Your team: for words that go on a
143
+ public page or to a customer, also pass `audience:'public'`. `{read:'library'}`
144
+ lists the approved documents you may read (`{read:'plan'}`, on the owner's own
145
+ key, says where all 16 are up to). Write in the voice the Brand voice and writing
146
+ style document sets. An account without business documents answers
147
+ feature_unavailable to those: read `{read:'documents'}` to list its long
148
+ documents and `{read:'document', kind:'voice_guide'}` (or `brand_guide`,
149
+ `business_summary`, `website_brand`) for one in full.
141
150
  `{read:'suggestions'}` lists details waiting for the owner's yes: never use one
142
151
  as confirmed; only the owner accepts or refuses it, under **Your business** in
143
152
  the hub. When a detail is wrong or missing (the user tells you, or you find it
@@ -306,7 +315,7 @@ MCP, so say that rather than stopping.
306
315
  | `awesomate_dns_check` | Live answer to "where does this domain actually point" — before and after any DNS change |
307
316
  | `awesomate_site_uptime` | 30-day availability, incidents, downtime per domain (cached, free) |
308
317
  | `awesomate_site_audit` | SEO + AEO build gates for one page, fetched as OAI-SearchBot (what ChatGPT search sees) — content present without JS, retrieval bots reachable, canonical, schema, structure, speed. Not plan-gated. Run it after any public-page change, and see the awesomate-seo skill for the fixes |
309
- | `awesomate_files` | Files on their automation account (public/, private/, temp/): put an image or download up and hand back its `public_url`, fetch what a workflow wrote, tidy a folder. Ask before make_public, a move into public/, or delete; `trash` shows what was deleted, and `empty_trash` erases it for good (show what goes, get a clear yes). `extract` unpacks a .zip beside itself; `context_scan` proposes business details from one file (saves nothing; the owner saves them in the hub, Files, Scan for business context; needs the owner's Learn Business Context from My Files switch). Support Plus+, owner's file-folders switch on (`status` says what's missing). Guide: https://hub.awesomate.ai/docs/mcp/guides/files/ |
318
+ | `awesomate_files` / `awesomate_files_change` | Files on their automation account (public/, private/, temp/): `awesomate_files` reads (status, usage, list, search, get_link, recent, trash, share_links); `awesomate_files_change` changes, and downloads to this computer. Put an image or download up and hand back its `public_url`, fetch what a workflow wrote, tidy a folder. Ask before make_public, a move into public/, or delete; `trash` shows what was deleted, `restore` brings one back (ask first when it goes back into public/), and `empty_trash` erases it for good (show what goes, get a clear yes; only the account owner can). To send someone a private file, `share_link` gives a link that runs out (7 days by default, up to 90) and leaves the file private: use it rather than make_public; `stop_share_link` ends one. `extract` unpacks a .zip beside itself; `context_scan` proposes business details from one file (saves nothing; the owner saves them in the hub, Files, Scan for business context; needs the owner's Learn Business Context from My Files switch). Support Plus+, owner's file-folders switch on (`status` says what's missing). Guide: https://hub.awesomate.ai/docs/mcp/guides/files/ |
310
319
  | `awesomate_snapshot_site` | Before ANY change to a live site — files + DB restore point |
311
320
  | `awesomate_list_snapshots` | What restore points a site has |
312
321
  | `awesomate_rollback_site` | Restore a snapshot after something went wrong (confirm first) |
@@ -0,0 +1,200 @@
1
+ /**
2
+ * Which coding agent runs the Awesomate connect, and where each one reads its
3
+ * MCP registration and skills. Node 18 built-ins only: this file is copied
4
+ * into the user's skills folder beside bootstrap.mjs.
5
+ *
6
+ * Facts (31 Oct 2026, OpenAI's Codex docs and openai/codex source):
7
+ * - Codex registers MCP servers in $CODEX_HOME/config.toml (default
8
+ * ~/.codex/config.toml) as [mcp_servers.<name>] with command/args/env;
9
+ * startup_timeout_sec defaults to 10 s, too short for a first npx download.
10
+ * - Codex reads skills from ~/.agents/skills ($CODEX_HOME/skills is the
11
+ * deprecated location) and picks up new skills without a restart; a
12
+ * config.toml change needs one.
13
+ * - Codex sets CODEX_THREAD_ID, CODEX_SESSION_ID and CODEX_VERSION for shell
14
+ * commands, but an MCP server gets only HOME, PATH, USER and a few more plus
15
+ * its entry's own env, so the entry carries AWESOMATE_CLIENT=codex.
16
+ */
17
+
18
+ import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
19
+ import { join, dirname } from 'node:path';
20
+
21
+ export const SERVER_NAME = 'awesomate-hosting';
22
+
23
+ export function clientLabel(client) {
24
+ return client === 'codex' ? 'Codex' : 'Claude Code';
25
+ }
26
+
27
+ /** --client codex|claude|both (or --client=codex) wins; then the agent's own env markers; else Claude Code, as before. */
28
+ export function detectClients(argv, env) {
29
+ let flag = null;
30
+ const i = argv.indexOf('--client');
31
+ if (i >= 0) flag = String(argv[i + 1] ?? '');
32
+ const eq = argv.find((a) => typeof a === 'string' && a.startsWith('--client='));
33
+ if (eq) flag = eq.slice('--client='.length);
34
+ if (flag !== null) {
35
+ flag = flag.toLowerCase();
36
+ if (flag === 'codex') return { clients: ['codex'], source: 'flag' };
37
+ if (flag === 'claude' || flag === 'claude-code') return { clients: ['claude'], source: 'flag' };
38
+ if (flag === 'both') return { clients: ['claude', 'codex'], source: 'flag' };
39
+ throw new Error(`--client must be codex, claude or both (got "${flag}")`);
40
+ }
41
+ const codex = Boolean(env.CODEX_THREAD_ID || env.CODEX_SESSION_ID || env.CODEX_VERSION);
42
+ const claude = Boolean(env.CLAUDECODE || env.CLAUDE_CODE_ENTRYPOINT);
43
+ if (codex && claude) return { clients: ['claude', 'codex'], source: 'env' };
44
+ if (codex) return { clients: ['codex'], source: 'env' };
45
+ return { clients: ['claude'], source: claude ? 'env' : 'default' };
46
+ }
47
+
48
+ export function codexHome(env, home) {
49
+ return env.CODEX_HOME || join(home, '.codex');
50
+ }
51
+
52
+ export function skillsDirFor(client, home) {
53
+ return client === 'codex' ? join(home, '.agents', 'skills') : join(home, '.claude', 'skills');
54
+ }
55
+
56
+ /** The one file a Codex copy must not rewrite: it holds the rewrite itself. */
57
+ export const NOT_REWRITTEN = 'agent-clients.mjs';
58
+
59
+ /** Skill text names ~/.claude/skills paths; a Codex copy names its own folder. */
60
+ export function rewriteForCodex(text) {
61
+ return text
62
+ .replaceAll('~/.claude/skills', '~/.agents/skills')
63
+ .replaceAll('$HOME/.claude/skills', '$HOME/.agents/skills')
64
+ .replaceAll("join(homedir(), '.claude', 'skills'", "join(homedir(), '.agents', 'skills'")
65
+ .replaceAll("join(HOME, '.claude', 'skills'", "join(HOME, '.agents', 'skills'");
66
+ }
67
+
68
+ const tomlString = (s) => JSON.stringify(String(s));
69
+
70
+ /**
71
+ * Our entry. keptMain: the owner's other keys on the entry (enabled,
72
+ * tool_timeout_sec, ...); keptEnv: their own env keys; keptTables: sub-tables
73
+ * such as [mcp_servers.awesomate-hosting.tools.x], all kept as written.
74
+ */
75
+ export function codexEntryToml(entry, { keptMain = [], keptEnv = [], keptTables = [] } = {}) {
76
+ const hasTimeout = keptMain.some((l) => /^\s*startup_timeout_sec\s*=/.test(l));
77
+ return [
78
+ `[mcp_servers.${SERVER_NAME}]`,
79
+ `command = ${tomlString(entry.command)}`,
80
+ `args = [${entry.args.map(tomlString).join(', ')}]`,
81
+ ...(hasTimeout ? [] : ['startup_timeout_sec = 60']),
82
+ ...keptMain,
83
+ '',
84
+ `[mcp_servers.${SERVER_NAME}.env]`,
85
+ 'AWESOMATE_CLIENT = "codex"',
86
+ ...keptEnv,
87
+ '',
88
+ ...(keptTables.length ? [...keptTables, ''] : []),
89
+ ].join('\n');
90
+ }
91
+
92
+ const NAME = `(?:"${SERVER_NAME}"|'${SERVER_NAME}'|${SERVER_NAME})`;
93
+ const OUR_HEADER = new RegExp(`^\\s*\\[\\s*mcp_servers\\s*\\.\\s*${NAME}\\s*(\\.[^\\]]*)?\\]\\s*(#.*)?$`);
94
+ const OUR_MAIN_HEADER = new RegExp(`^\\s*\\[\\s*mcp_servers\\s*\\.\\s*${NAME}\\s*\\]\\s*(#.*)?$`);
95
+ const OUR_ENV_HEADER = new RegExp(`^\\s*\\[\\s*mcp_servers\\s*\\.\\s*${NAME}\\s*\\.\\s*env\\s*\\]\\s*(#.*)?$`);
96
+ const ANY_HEADER = /^\s*\[/;
97
+ const KEY = /^\s*(["']?)([A-Za-z0-9_-]+)\1\s*=/;
98
+ // Keys this script owns on the entry; the owner's own value for any other key stays.
99
+ const OURS_IN_MAIN = new Set(['command', 'args']);
100
+
101
+ /**
102
+ * Put exactly one Awesomate entry (no token in it) into config.toml text.
103
+ * command and args become ours; AWESOMATE_PAT is dropped; everything else the
104
+ * owner set on the entry, and everything else in the file, is kept. A form this
105
+ * cannot edit safely (an inline table, dotted keys, an inline env) is refused
106
+ * rather than duplicated.
107
+ */
108
+ export function upsertCodexEntry(text, entry) {
109
+ const lines = text.split(/\r?\n/);
110
+ const kept = [];
111
+ const keptMain = [];
112
+ const keptEnv = [];
113
+ const keptTables = [];
114
+ let section = 'root'; // root | mcp_servers | main | env | sub | other
115
+ let found = false;
116
+ let hadToken = false;
117
+ let skippingArray = false;
118
+ const refuse = () => {
119
+ throw new Error(`config.toml defines ${SERVER_NAME} in a form this script will not rewrite`);
120
+ };
121
+ for (const line of lines) {
122
+ if (skippingArray) {
123
+ if (line.includes(']')) skippingArray = false;
124
+ continue;
125
+ }
126
+ if (ANY_HEADER.test(line)) {
127
+ if (OUR_MAIN_HEADER.test(line)) { section = 'main'; found = true; continue; }
128
+ if (OUR_ENV_HEADER.test(line)) { section = 'env'; found = true; continue; }
129
+ if (OUR_HEADER.test(line)) { section = 'sub'; found = true; keptTables.push(line); continue; }
130
+ section = /^\s*\[\s*mcp_servers\s*\]/.test(line) ? 'mcp_servers' : 'other';
131
+ kept.push(line);
132
+ continue;
133
+ }
134
+ // Dotted or inline forms of our entry, only where they would define it.
135
+ if (
136
+ (section === 'root' && new RegExp(`^\\s*mcp_servers\\s*(\\.\\s*${NAME}\\s*[.=]|=.*${SERVER_NAME})`).test(line)) ||
137
+ (section === 'mcp_servers' && new RegExp(`^\\s*${NAME}\\s*[.=]`).test(line))
138
+ ) {
139
+ refuse();
140
+ }
141
+ if (section === 'main') {
142
+ const key = KEY.exec(line)?.[2];
143
+ if (key === 'env') {
144
+ if (/AWESOMATE_PAT/.test(line)) { hadToken = true; continue; }
145
+ refuse();
146
+ }
147
+ if (key && OURS_IN_MAIN.has(key)) {
148
+ // A multi-line array: skip its continuation lines too.
149
+ const value = line.slice(line.indexOf('=') + 1);
150
+ if (value.includes('[') && !value.includes(']')) skippingArray = true;
151
+ continue;
152
+ }
153
+ if (line.trim()) keptMain.push(line.trim());
154
+ continue;
155
+ }
156
+ if (section === 'env') {
157
+ if (/AWESOMATE_PAT/.test(line)) { hadToken = true; continue; }
158
+ const key = KEY.exec(line)?.[2];
159
+ if (key && key !== 'AWESOMATE_CLIENT') keptEnv.push(line.trim());
160
+ continue;
161
+ }
162
+ if (section === 'sub') {
163
+ if (line.trim()) keptTables.push(line);
164
+ continue;
165
+ }
166
+ kept.push(line);
167
+ }
168
+ while (kept.length && kept[kept.length - 1].trim() === '') kept.pop();
169
+ const body = kept.length ? `${kept.join('\n')}\n\n` : '';
170
+ return { text: `${body}${codexEntryToml(entry, { keptMain, keptEnv, keptTables })}`, found, hadToken };
171
+ }
172
+
173
+ /** Write the Codex registration, read it back, and say what happened. */
174
+ export function ensureCodexRegistration({ env, home, entry, log = console.log }) {
175
+ const path = join(codexHome(env, home), 'config.toml');
176
+ const exists = existsSync(path);
177
+ const before = exists ? readFileSync(path, 'utf8') : '';
178
+ const { text, found, hadToken } = upsertCodexEntry(before, entry);
179
+ if (text === before) {
180
+ log(`✓ MCP server already registered for Codex in ${path}.`);
181
+ return { path, changed: false };
182
+ }
183
+ mkdirSync(dirname(path), { recursive: true });
184
+ // Keep the file's own mode: config.toml can hold other servers' keys.
185
+ const mode = exists ? statSync(path).mode & 0o777 : 0o600;
186
+ const tmp = `${path}.tmp-${process.pid}`;
187
+ writeFileSync(tmp, text, { mode });
188
+ chmodSync(tmp, mode);
189
+ renameSync(tmp, path);
190
+ const verify = readFileSync(path, 'utf8');
191
+ if (!verify.includes(`[mcp_servers.${SERVER_NAME}]`) || !verify.includes('awesomate-hosting-mcp')) {
192
+ throw new Error(`wrote ${path} but the ${SERVER_NAME} entry did not verify on read-back`);
193
+ }
194
+ log(
195
+ hadToken
196
+ ? `✓ Replaced the Codex registration in ${path} (it had a token in its env) with one that has none.`
197
+ : `✓ ${found ? 'Updated' : 'Registered'} the Awesomate MCP server for Codex in ${path} (no token in it: the folder pin picks the account).`,
198
+ );
199
+ return { path, changed: true };
200
+ }
@@ -11,7 +11,7 @@
11
11
  * access token itself is never printed.
12
12
  *
13
13
  * Usage (Claude runs this — the user doesn't touch a terminal):
14
- * node bootstrap.mjs --code amt_bs_XXXX [--account <slug>] [--pin-dir <dir>] [--replace]
14
+ * node bootstrap.mjs --code amt_bs_XXXX [--account <slug>] [--pin-dir <dir>] [--replace] [--client codex|claude|both]
15
15
  * node bootstrap.mjs --pat <token> [--account <slug>] # resume: skip redeem
16
16
  *
17
17
  * --account asserts WHICH account this connect is for — mismatch aborts before
@@ -34,6 +34,9 @@ import { existsSync, mkdirSync, writeFileSync, chmodSync, readFileSync, cpSync,
34
34
  import { homedir, hostname } from 'node:os';
35
35
  import { join, dirname, resolve, basename } from 'node:path';
36
36
  import { fileURLToPath } from 'node:url';
37
+ import {
38
+ NOT_REWRITTEN, clientLabel, codexEntryToml, codexHome, detectClients, ensureCodexRegistration, rewriteForCodex, skillsDirFor,
39
+ } from './agent-clients.mjs';
37
40
 
38
41
  function arg(name, fallback) {
39
42
  const i = process.argv.indexOf(`--${name}`);
@@ -46,29 +49,24 @@ const expectedAccount = arg('account', null);
46
49
  const pinDirArg = arg('pin-dir', null);
47
50
  const apiBase = (arg('api', 'https://hub.awesomate.ai')).replace(/\/$/, '');
48
51
 
49
- // --update: refresh the installed skills from this package and exit — no
50
- // setup code, no registration, no token. The no-MCP fallback for the
51
- // awesomate_skill_update tool.
52
- if (process.argv.includes('--update')) {
53
- try {
54
- installSkill();
55
- // Also converge the MCP registration: --update is the no-token repair
56
- // path, and a broken registration (e.g. bare-npx on Windows) is exactly
57
- // what people run it to fix.
58
- try {
59
- ensureMcpRegistration();
60
- } catch (regErr) {
61
- console.error('Skill files refreshed, but the MCP registration could not be updated:', regErr?.message ?? regErr);
62
- }
63
- console.log('Skills refreshed. New content applies in your next Claude Code session.');
64
- process.exit(0);
65
- } catch (err) {
66
- console.error('Skill refresh failed:', err?.message ?? err);
67
- process.exit(1);
68
- }
52
+ // Which coding agent this connect is for: Codex and Claude Code read their MCP
53
+ // registration and skills from different places. --client codex|claude|both
54
+ // overrides what the environment says.
55
+ let CLIENTS;
56
+ try {
57
+ CLIENTS = detectClients(process.argv, process.env).clients;
58
+ } catch (err) {
59
+ console.error(err.message);
60
+ console.error('AWESOMATE CONNECT: FAILED reason=bad-client');
61
+ process.exit(1);
69
62
  }
63
+ const CLIENT_NAMES = CLIENTS.map(clientLabel).join(' and ');
64
+ // Written as text, not joined: the hints print the same ~/ path on every platform.
65
+ const FIRST_SKILLS_DIR = CLIENTS[0] === 'codex' ? '~/.agents/skills' : '~/.claude/skills';
66
+
67
+ const UPDATE_ONLY = process.argv.includes('--update');
70
68
 
71
- if (!resumePat && (!code || !code.startsWith('amt_bs_'))) {
69
+ if (!UPDATE_ONLY && !resumePat && (!code || !code.startsWith('amt_bs_'))) {
72
70
  console.error('Missing/invalid --code. Copy a fresh Connect command from hub.awesomate.ai/claude and run it again.');
73
71
  console.error('AWESOMATE CONNECT: FAILED reason=bad-code');
74
72
  process.exit(1);
@@ -109,12 +107,13 @@ process.on('exit', (code) => {
109
107
  try {
110
108
  CONNECT_LOG.push(`exit: ${code}`);
111
109
  mkdirSync(dir, { recursive: true, mode: 0o700 });
112
- writeFileSync(join(dir, 'last-connect.log'), `${CONNECT_LOG.join('\n')}\n`, { mode: 0o600 });
110
+ // --update keeps its own log, so it never replaces a failed connect's.
111
+ writeFileSync(join(dir, UPDATE_ONLY ? 'last-update.log' : 'last-connect.log'), `${CONNECT_LOG.join('\n')}\n`, { mode: 0o600 });
113
112
  } catch { /* logging must never block exit */ }
114
113
  });
115
114
 
116
115
  const SUPPORT_HINT =
117
- 'Stuck? Generate a support report: node ~/.claude/skills/awesomate-hosting/scripts/support-report.mjs --note "<what happened>" (add --submit to send it to Awesomate and get a reference ID).';
116
+ `Stuck? Generate a support report: node ${FIRST_SKILLS_DIR}/awesomate-hosting/scripts/support-report.mjs --note "<what happened>" (add --submit to send it to Awesomate and get a reference ID).`;
118
117
 
119
118
  // ---------------------------------------------------------------------------
120
119
  // Proxy-aware fetch. Node's built-in fetch does NOT honor HTTP(S)_PROXY —
@@ -313,8 +312,9 @@ function installSkill() {
313
312
  // dest — so an "update" from here silently refreshed nothing while
314
313
  // reporting success. Say so honestly and point at the two real paths.
315
314
  console.log('• This is the installed copy of the skill — it cannot refresh the bundle from here.');
316
- console.log(' Update instead with the awesomate_skill_update tool in Claude Code, or re-run the');
317
- console.log(' full bootstrap: npx -y --package=@awesomate/hosting-mcp awesomate-hosting-bootstrap --update');
315
+ console.log(` Update instead with the awesomate_skill_update tool in ${CLIENT_NAMES}, or re-run the`);
316
+ const clientFlag = CLIENTS.length > 1 ? ' --client both' : CLIENTS[0] === 'codex' ? ' --client codex' : '';
317
+ console.log(` full bootstrap: npx -y --package=@awesomate/hosting-mcp awesomate-hosting-bootstrap --update${clientFlag}`);
318
318
  return false;
319
319
  }
320
320
  const bundled = readdirSync(skillRoot);
@@ -328,13 +328,15 @@ function installSkill() {
328
328
  } catch { /* non-fatal — marker just won't be written */ }
329
329
  }
330
330
  let installed = 0;
331
- for (const name of bundled) {
331
+ for (const client of CLIENTS) for (const name of bundled) {
332
332
  const src = join(skillRoot, name);
333
333
  if (!existsSync(join(src, 'SKILL.md'))) continue;
334
- const dest = join(homedir(), '.claude', 'skills', name);
334
+ const dest = join(skillsDirFor(client, homedir()), name);
335
335
  if (src === dest) { installed += 1; continue; } // already running from the installed copy
336
336
  mkdirSync(dirname(dest), { recursive: true });
337
337
  cpSync(src, dest, { recursive: true, force: true });
338
+ // Skill text names ~/.claude/skills paths; a Codex copy names its own folder.
339
+ if (client === 'codex') rewriteTree(dest);
338
340
  // Make the shell/mjs helpers executable (npm can publish them non-+x).
339
341
  const scriptsDir = join(dest, 'scripts');
340
342
  if (existsSync(scriptsDir)) {
@@ -355,6 +357,19 @@ function installSkill() {
355
357
  return true;
356
358
  }
357
359
 
360
+ function rewriteTree(dir) {
361
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
362
+ const path = join(dir, entry.name);
363
+ if (entry.isDirectory()) { rewriteTree(path); continue; }
364
+ if (!/\.(md|mjs|js|sh)$/.test(entry.name) || entry.name === NOT_REWRITTEN) continue;
365
+ try {
366
+ const text = readFileSync(path, 'utf8');
367
+ const next = rewriteForCodex(text);
368
+ if (next !== text) writeFileSync(path, next);
369
+ } catch { /* a file we cannot rewrite keeps the Claude Code path */ }
370
+ }
371
+ }
372
+
358
373
  // --package= (with the =) instead of -p: the claude CLI pre-scans the FULL
359
374
  // argv for its own global -p/--print flag — even after the `--` separator —
360
375
  // so any `claude mcp add … -- npx -y -p pkg bin` flips it into print mode and
@@ -375,6 +390,7 @@ const CLEAN_ENTRY = process.platform === 'win32'
375
390
  args: ['-y', '--package=@awesomate/hosting-mcp', 'awesomate-hosting-mcp'],
376
391
  };
377
392
  const MANUAL_ADD_JSON = JSON.stringify({ mcpServers: { 'awesomate-hosting': CLEAN_ENTRY } }, null, 2);
393
+ const MANUAL_ADD_TOML = `In ${join(codexHome(process.env, homedir()), 'config.toml')}:\n${codexEntryToml(CLEAN_ENTRY)}`;
378
394
 
379
395
  /**
380
396
  * Converge on exactly one env-free, user-scope MCP registration by editing the
@@ -388,7 +404,32 @@ const MANUAL_ADD_JSON = JSON.stringify({ mcpServers: { 'awesomate-hosting': CLEA
388
404
  * env var (user scope, this project's local scope + .mcp.json); entries in
389
405
  * OTHER projects are reported for manual cleanup, not touched.
390
406
  */
407
+ /**
408
+ * Each client is registered where IT reads: a Claude Code registration is
409
+ * never reported as a Codex one, or the other way round. Each is tried on its
410
+ * own, so one failing never leaves the other unregistered; the failures come
411
+ * back with the manual form for that client.
412
+ */
391
413
  function ensureMcpRegistration() {
414
+ const failures = [];
415
+ if (CLIENTS.includes('codex')) {
416
+ try {
417
+ ensureCodexRegistration({ env: process.env, home: homedir(), entry: CLEAN_ENTRY });
418
+ } catch (err) {
419
+ failures.push({ client: 'codex', message: err?.message ?? String(err), manual: MANUAL_ADD_TOML });
420
+ }
421
+ }
422
+ if (CLIENTS.includes('claude')) {
423
+ try {
424
+ ensureClaudeRegistration();
425
+ } catch (err) {
426
+ failures.push({ client: 'claude', message: err?.message ?? String(err), manual: MANUAL_ADD_JSON });
427
+ }
428
+ }
429
+ return failures;
430
+ }
431
+
432
+ function ensureClaudeRegistration() {
392
433
  const cwd = resolve(process.cwd());
393
434
  const claudeJsonPath = join(homedir(), '.claude.json');
394
435
 
@@ -415,10 +456,10 @@ function ensureMcpRegistration() {
415
456
  console.log(
416
457
  entry?.env?.AWESOMATE_PAT
417
458
  ? '✓ Replaced the legacy user-scope registration (had a token baked into its env) with an env-free one.'
418
- : '✓ Registered the Awesomate Hosting MCP server (user scope, env-free — the folder pin picks the account).',
459
+ : '✓ Registered the Awesomate Hosting MCP server for Claude Code (user scope, env-free: the folder pin picks the account).',
419
460
  );
420
461
  } else {
421
- console.log('✓ MCP server already registered (user scope, env-free) — account selection comes from the folder pin.');
462
+ console.log('✓ MCP server already registered for Claude Code (user scope, env-free): account selection comes from the folder pin.');
422
463
  }
423
464
 
424
465
  // This project's local-scope entry (lives under projects[cwd] in ~/.claude.json).
@@ -479,7 +520,7 @@ async function main() {
479
520
  } else {
480
521
  console.log(`Redeeming setup code against ${apiBase} …`);
481
522
  redeemed = await post('/api/hosting-access/redeem', {
482
- body: { code, machineLabel: `Claude Code on ${hostname()}` },
523
+ body: { code, machineLabel: `${CLIENT_NAMES} on ${hostname()}` },
483
524
  });
484
525
  }
485
526
 
@@ -556,12 +597,11 @@ async function main() {
556
597
  console.log(`• Could not auto-install the skill (${err.message}) — continuing; you can copy skill/ manually.`);
557
598
  }
558
599
 
559
- try {
560
- ensureMcpRegistration();
561
- } catch (err) {
562
- issues.push('mcp-registration');
563
- console.error(`• MCP registration failed: ${err.message}`);
564
- console.error(` Add it manually (no token goes in the config — the folder pin picks the account):\n${MANUAL_ADD_JSON}`);
600
+ const failures = ensureMcpRegistration();
601
+ if (failures.length) issues.push('mcp-registration');
602
+ for (const f of failures) {
603
+ console.error(`• ${clientLabel(f.client)} MCP registration failed: ${f.message}`);
604
+ console.error(` Add it manually (no token goes in the config: the folder pin picks the account):\n${f.manual}`);
565
605
  }
566
606
 
567
607
  // SSH key (Support Plus+): best-effort. If it fails (e.g. hosting not fully
@@ -578,7 +618,7 @@ async function main() {
578
618
  const publicKey = readFileSync(`${keyPath}.pub`, 'utf8').trim();
579
619
  const reg = await post('/api/hosting-access/ssh-keys', {
580
620
  token: redeemed.pat,
581
- body: { publicKey, label: `Claude Code on ${hostname()}` },
621
+ body: { publicKey, label: `${CLIENT_NAMES} on ${hostname()}` },
582
622
  });
583
623
  profile.ssh = { host: reg.sshHost, user: reg.sshUser, port: reg.sshPort ?? 22, keyPath, fingerprint: reg.fingerprint };
584
624
  mergeProfile(profile);
@@ -602,12 +642,15 @@ async function main() {
602
642
  console.log(`\n✓ Connected: ${who}${pinPath ? ` — pinned ${dirname(pinPath)}` : ''}`);
603
643
  console.log('Setup complete.');
604
644
  console.log('');
605
- console.log('IMPORTANT — restart Claude Code now: the MCP tools and skills load only at startup.');
606
- console.log('Until the restart, builds still work — the assistant should follow');
607
- console.log('~/.claude/skills/awesomate-n8n/references/rest-fallback.md (n8n) or');
608
- console.log('~/.claude/skills/awesomate-hosting/references/rest-fallback.md (hosting).');
645
+ console.log(`IMPORTANT: restart ${CLIENT_NAMES} now: the MCP tools load only at startup.`);
646
+ if (CLIENTS.includes('codex')) {
647
+ console.log('In Codex: type /quit, then run codex again in this folder (in the Codex app or IDE extension, start a new chat after reloading).');
648
+ }
649
+ console.log('Until the restart, builds still work: the assistant should follow');
650
+ console.log(`${FIRST_SKILLS_DIR}/awesomate-n8n/references/rest-fallback.md (n8n) or`);
651
+ console.log(`${FIRST_SKILLS_DIR}/awesomate-hosting/references/rest-fallback.md (hosting).`);
609
652
  console.log('After restarting: run awesomate_whoami to confirm the account, then ask for your first build.');
610
- console.log('(The skill works in your current Claude session right away via its REST fallback — restart Claude Code when convenient to load the MCP tools.)');
653
+ console.log(`(The skills work in your current session right away via their REST fallback; restart ${CLIENT_NAMES} when convenient to load the MCP tools.)`);
611
654
  if (issues.length) {
612
655
  console.log(SUPPORT_HINT);
613
656
  console.log(`AWESOMATE CONNECT: PARTIAL account=${slug} pin=${pinPath ?? 'none'} issues=${issues.join(',')}`);
@@ -616,7 +659,29 @@ async function main() {
616
659
  console.log(`AWESOMATE CONNECT: SUCCESS account=${slug} pin=${pinPath ?? 'none'}`);
617
660
  }
618
661
 
619
- main().catch((err) => {
662
+ // --update: refresh the installed skills from this package and exit, no
663
+ // setup code, no registration, no token. The no-MCP fallback for the
664
+ // awesomate_skill_update tool.
665
+ function runUpdate() {
666
+ try {
667
+ installSkill();
668
+ // Also converge the MCP registration: --update is the no-token repair
669
+ // path, and a broken registration (e.g. bare-npx on Windows) is exactly
670
+ // what people run it to fix.
671
+ for (const f of ensureMcpRegistration()) {
672
+ console.error(`Skill files refreshed, but the ${clientLabel(f.client)} MCP registration could not be updated: ${f.message}`);
673
+ console.error(`Add it by hand:\n${f.manual}`);
674
+ }
675
+ console.log(`Skills refreshed. New content applies in your next ${CLIENT_NAMES} session.`);
676
+ process.exit(0);
677
+ } catch (err) {
678
+ console.error('Skill refresh failed:', err?.message ?? err);
679
+ process.exit(1);
680
+ }
681
+ }
682
+
683
+ if (UPDATE_ONLY) runUpdate();
684
+ else main().catch((err) => {
620
685
  console.error('Bootstrap failed:', err.message);
621
686
  if (err.isApiError && err.status === 401) {
622
687
  console.error('Grab a fresh code from hub.awesomate.ai/claude — codes last 10 minutes (and stay re-runnable within that window).');
@@ -158,6 +158,19 @@ async function main() {
158
158
  const e = project?.mcpServers?.['awesomate-hosting'];
159
159
  if (e) push(`- local scope (${projectDir}): envKeys=${JSON.stringify(Object.keys(e.env ?? {}))}${e.env?.AWESOMATE_PAT ? ' ⚠ LEGACY env token' : ''}`);
160
160
  }
161
+ // Codex: $CODEX_HOME/config.toml. Key names only, never values.
162
+ const codexToml = join(process.env.CODEX_HOME || join(HOME, '.codex'), 'config.toml');
163
+ try {
164
+ const lines = readFileSync(codexToml, 'utf8').split(/\r?\n/);
165
+ const keys = []; let inOurs = false;
166
+ for (const l of lines) {
167
+ if (/^\s*\[/.test(l)) { inOurs = /^\s*\[\s*mcp_servers\s*\.\s*["']?awesomate-hosting["']?\s*(\.|\])/.test(l); if (inOurs) keys.push(l.trim()); continue; }
168
+ const k = inOurs && /^\s*["']?([A-Za-z0-9_-]+)["']?\s*=/.exec(l)?.[1];
169
+ if (k) keys.push(k);
170
+ }
171
+ push(`- Codex (${codexToml}): ${keys.length ? keys.join(' ') : 'no awesomate-hosting entry'}`);
172
+ if (keys.includes('AWESOMATE_PAT')) push(' ⚠ LEGACY: token in the Codex entry. Re-run Connect with --client codex to fix.');
173
+ } catch { push(`- Codex (${codexToml}): not found`); }
161
174
  const mcpJson = readJson(join(process.cwd(), '.mcp.json'));
162
175
  const projEntry = mcpJson?.mcpServers?.['awesomate-hosting'];
163
176
  if (projEntry) push(`- project scope (cwd/.mcp.json): envKeys=${JSON.stringify(Object.keys(projEntry.env ?? {}))}${projEntry.env?.AWESOMATE_PAT ? ' ⚠ LEGACY env token' : ''}`);