@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.
28 lines • 1.42 kB
JavaScript
import { isValidSessionLabel } from "@essentialai/cogent";
import { BridgeError, BridgeErrorCode } from "../errors.js";
/**
* Text shared by cogent_join_session and cogent_create_session (COG-81).
*/
/**
* A channel name the relay would reject, refused BEFORE any network call: the relay answers a
* multi-line schema dump that names no next action, and on the Team relay every failed attempt
* counts toward the name's lockout. Never lowercased silently — the agent must know the name it
* ends up on.
*/
export function invalidChannelName(name) {
if (isValidSessionLabel(name))
return null;
return new BridgeError(BridgeErrorCode.INVALID_INPUT, `Channel names are 3-32 characters: lowercase letters, digits and hyphens. '${name}' is not valid`, "If it differs only by capital letters, retry with it in lowercase; otherwise ask the user.");
}
/**
* The Slack command that maps this channel, for the agent to pass on to the user. Only the
* non-secret part is filled in: the password and the Org_ID stay placeholders, so a tool result
* (which an agent's reply may quote into a channel) never carries either.
* Team maps by channel NAME + Org_ID; the free adapter maps by session id.
*/
export function slackMapCommand(o) {
return o.team
? `/cogent map ${o.label} <password> <org-id>`
: `/cogent map ${o.sessionId} <password>`;
}
//# sourceMappingURL=channel-text.js.map