UNPKG

@essentialai/cogent-bridge

Version:

Cogent Bridge — cross-agent comms for Claude Code, OpenAI Codex and Slack. Codex users: install with `curl -fsSL https://cogent.tools/install.sh | sh`, then start with `cogent-codex` for real-time peer wake.

39 lines • 3.75 kB
/** * MCP server instructions (COG-81) — the only Cogent text a cold agent is guaranteed to see * before it has loaded a single tool schema or skill. * * Constraints, each one measured (docs/reference/mcp-spec.md): * - ASCII only, and UNDER 4096 characters: Claude Code cuts the text there. * - Scoped to "when the user asks": the text reaches EVERY session of every installed user, so * an unconditional "to get online, do X" would make unrelated sessions read .env and register. * * scripts/first-run-test.mjs reads this text back from the built bridge's `initialize` result. */ /** * Lists the Cogent KEY NAMES in a project .env, with line numbers — never a value (`-o` prints * only the matched part, and the match ends at the `=`). The prefix is loose on purpose: a key * with a misspelled prefix is still found, and the agent reports it by key name. * The register skills carry this exact command; src/tools/register-skill-first-run.test.ts * holds the copies together and runs it on fixtures. */ export const ENV_KEY_NAMES_COMMAND = "grep -noE '^#COGENT[A-Za-z0-9_ -]*|^(CHANNEL|COG[A-Z]*NT)_(CHANNEL_)?(NAME|PASSWORD|ORG_ID|PEER_NAME|PEER_LABEL)=' .env"; export const SERVER_INSTRUCTIONS = [ "Cogent connects this agent to a shared channel with other agents and with people in Slack. Follow the steps below only when the user asks you to register, join or get online on Cogent; never read .env or register unprompted.", "To get online:", "1. cogent_join_session { channel, secret, orgId? }. channel is the channel NAME (3-32 characters: lowercase letters, digits, hyphens), never a UUID. If you were given an Org_ID (Team channel) pass it as orgId on every call and never retry without it.", "2. Only if step 1 answers CHANNEL_NOT_FOUND: cogent_create_session { label, secret, orgId? } with the SAME name, password and Org_ID. It creates the channel and joins you. Never change the name. Do not repeat step 1 first: five failed joins lock the name for 15 minutes.", "3. cogent_register_peer { peerId, sessionId, cwd, label }. peerId is the peer name you were given. sessionId is this agent session's own resumable id, not the channel id. Do not call this first.", "Values come from the user's message, else from the project .env: the keys ending in CHANNEL_NAME, CHANNEL_PASSWORD, ORG_ID, PEER_NAME and PEER_LABEL. To find them, list the key NAMES only:", ENV_KEY_NAMES_COMMAND, "Then pass the values straight into the tool call. Do not print them and do not write a script that prints them. A key with a misspelled prefix is still used: report its KEY NAME. If the channel name or peer name is missing, or appears more than once, ask. Never invent either.", "Errors:", "- CHANNEL_NOT_FOUND: do step 2 once. Exception: if you were given an Org_ID and left it out, do step 1 again WITH orgId and create nothing.", "- 'already in use' from create: the channel exists. Do step 1 again with the same name.", "- Invalid credentials or Invalid session secret (HTTP 401): the password or Org_ID is wrong. Stop and ask.", "- RATE_LIMITED or HTTP 429: wait the seconds it states, then repeat the same call once. Change nothing.", "- JOIN_NOT_CONFIRMED: step 1 or 2 has not succeeded in this session. Do it, then register.", "- PEER_NOT_YOURS: your own earlier session holds the name. Retry the SAME peerId when the error says. Never rename.", "- Anything else: report it and stop.", "Never print the channel password or the Org_ID. When online, report the peer name, the channel name, whether you created or joined it, and the Slack command from the tool result with its placeholders left as they are.", ].join("\n"); //# sourceMappingURL=instructions.js.map