Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(auth): guide new agent accounts through macrod setup (#9867)
Eric Hayesca105681194b
diff --git a/apps/web/src/features/agent-setup/agent-setup-page.tsx b/apps/web/src/features/agent-setup/agent-setup-page.tsxindex f51d4ba94f..5679aec46a 100644--- a/apps/web/src/features/agent-setup/agent-setup-page.tsx+++ b/apps/web/src/features/agent-setup/agent-setup-page.tsx@@ -103,6 +103,13 @@ export function AgentSetupPage() {productDocs: t('agentSetup.productDocs'),sdkDocs: t('agentSetup.sdkDocs'),setProfile: t('agentSetup.setProfile'),+ macrod: t('agentSetup.macrod'),+ macrodInstall: t('agentSetup.macrodInstall'),+ macrodStart: t('agentSetup.macrodStart'),+ macrodApprove: t('agentSetup.macrodApprove'),+ macrodNext: t('agentSetup.macrodNext'),+ macrodDocs: t('agentSetup.macrodDocs'),+ macrodSource: t('agentSetup.macrodSource'),anotherToken: t('agentSetup.anotherToken'),anotherTokenSettings: t('agentSetup.anotherTokenSettings'),openApp: t('agentSetup.openApp'),diff --git a/apps/web/src/features/agent-setup/core/agent-setup-markdown.test.ts b/apps/web/src/features/agent-setup/core/agent-setup-markdown.test.tsindex 7f0a83e05a..3d957e3476 100644--- a/apps/web/src/features/agent-setup/core/agent-setup-markdown.test.ts+++ b/apps/web/src/features/agent-setup/core/agent-setup-markdown.test.ts@@ -1,5 +1,39 @@import { describe, expect, it } from 'vitest';-import { markdownParts } from './agent-setup-markdown';+import {+ type AgentSetupCopy,+ agentSetupMarkdown,+ markdownParts,+} from './agent-setup-markdown';++const COPY = new Proxy({} as AgentSetupCopy, {+ get: (_, key) => String(key),+});++describe('agentSetupMarkdown', () => {+ it('sends the agent through macrod setup with clickable docs and source', () => {+ const markdown = agentSetupMarkdown({+ copy: COPY,+ apiKey: 'token',+ teamJoinFailed: false,+ openAppUrl: 'https://app.test/done',+ });++ expect(markdown).toContain(+ '--config ~/.macrod/agent.toml --agent <agent id>'+ );+ expect(markdown).toContain("harnesses.pairing('<code>').approve()");+ expect(+ markdownParts(markdown).flatMap((part) =>+ part.t === 'link' ? [part.url] : []+ )+ ).toEqual(+ expect.arrayContaining([+ 'https://docs.macro.com/AI/bring-your-own',+ 'https://github.com/macro-inc/macro/tree/main/crates/coding_agent_worker',+ ])+ );+ });+});describe('markdownParts', () => {it('finds links between text and keeps every other character', () => {diff --git a/apps/web/src/features/agent-setup/core/agent-setup-markdown.ts b/apps/web/src/features/agent-setup/core/agent-setup-markdown.tsindex 1fd41030f5..4c1ec3bb62 100644--- a/apps/web/src/features/agent-setup/core/agent-setup-markdown.ts+++ b/apps/web/src/features/agent-setup/core/agent-setup-markdown.ts@@ -10,8 +10,23 @@ await macro.me.update({ name: 'Your Name', profilePicture: image });`;const NEW_TOKEN_SNIPPET = `const { secret } = await macro.apiKeys.create('my token');`;+const MACROD_INSTALL = `curl -fsSL https://raw.githubusercontent.com/macro-inc/macro/main/crates/coding_agent_worker/install/install.sh | sh+~/.local/bin/macrod detect-agents`;++const MACROD_START = `mkdir -p ~/.macrod && chmod 700 ~/.macrod+tmux kill-session -t macrod-agent 2>/dev/null+: > ~/.macrod/agent.log+tmux new-session -d -s macrod-agent '~/.local/bin/macrod service --config ~/.macrod/agent.toml --agent <agent id> --workspace "<absolute path>" >> ~/.macrod/agent.log 2>&1'`;++const MACROD_PAIRING_CODE = `grep '"event":"pairing"' ~/.macrod/agent.log`;++const MACROD_APPROVE = `await macro.harnesses.pairing('<code>').approve();`;+const PRODUCT_DOCS_URL = 'https://docs.macro.com';const SDK_DOCS_URL = 'https://sdk.macro.com';+const MACROD_DOCS_URL = 'https://docs.macro.com/AI/bring-your-own';+const MACROD_SOURCE_URL =+ 'https://github.com/macro-inc/macro/tree/main/crates/coding_agent_worker';/** The page's wording, translated where it renders. */export type AgentSetupCopy = {@@ -24,6 +39,13 @@ export type AgentSetupCopy = {productDocs: string;sdkDocs: string;setProfile: string;+ macrod: string;+ macrodInstall: string;+ macrodStart: string;+ macrodApprove: string;+ macrodNext: string;+ macrodDocs: string;+ macrodSource: string;anotherToken: string;anotherTokenSettings: string;openApp: string;@@ -54,6 +76,16 @@ export function agentSetupMarkdown(input: {codeBlock(QUICK_START, 'sh'),`## ${copy.setProfile}`,codeBlock(PROFILE_SNIPPET, 'ts'),+ `## ${copy.macrod}`,+ copy.macrodInstall,+ codeBlock(MACROD_INSTALL, 'sh'),+ copy.macrodStart,+ codeBlock(MACROD_START, 'sh'),+ copy.macrodApprove,+ codeBlock(MACROD_PAIRING_CODE, 'sh'),+ codeBlock(MACROD_APPROVE, 'ts'),+ copy.macrodNext,+ `- [${copy.macrodDocs}](${MACROD_DOCS_URL})\n- [${copy.macrodSource}](${MACROD_SOURCE_URL})`,`## ${copy.anotherToken}`,codeBlock(NEW_TOKEN_SNIPPET, 'ts'),copy.anotherTokenSettings,diff --git a/apps/web/src/lib/i18n/locales/en/agent-setup.ts b/apps/web/src/lib/i18n/locales/en/agent-setup.tsindex e49a46975b..f5999edb02 100644--- a/apps/web/src/lib/i18n/locales/en/agent-setup.ts+++ b/apps/web/src/lib/i18n/locales/en/agent-setup.ts@@ -14,7 +14,18 @@ export default {productDocs: 'Macro documentation',sdkDocs: 'SDK documentation and generated API reference',setProfile: '2. Set your name and profile picture',- anotherToken: '3. Need another token later?',+ macrod: '3. Run macrod on your computer',+ macrodInstall:+ 'macrod connects a coding agent on your computer, such as Claude Code or Codex, to Macro, so your sessions can run there. The agent must already be installed and signed in. Install macrod and list the agents it finds:',+ macrodStart:+ 'Start it with an agent id from that list and a folder to work in. Use tmux or another session that keeps stdin open, because macrod service stops when stdin closes. Its own config keeps it from reusing a macrod already paired to another account on this computer:',+ macrodApprove:+ 'Wait for the pairing event and read its code, then approve it with the SDK. The log shows a running event once macrod connects. If it shows a fatal event instead, such as an expired code, fix the cause and run the start commands again:',+ macrodNext:+ 'To start sessions on this runtime from Macro, add an agent that uses it in Settings → Agents. macrod service doesn’t update itself: to update, run the install command again, then run the start commands again.',+ macrodDocs: 'macrod setup guide, including Windows',+ macrodSource: 'macrod source code',+ anotherToken: '4. Need another token later?',anotherTokenSettings: 'You can also create one in Settings → API Keys.',openApp: 'Open the app',openAppLink: 'I saved my token, open Macro',diff --git a/docs/agent-guide/login.md b/docs/agent-guide/login.mdindex c378594f6a..a167094927 100644--- a/docs/agent-guide/login.md+++ b/docs/agent-guide/login.md@@ -34,8 +34,8 @@ account that isn't a new agent continues to `/app/team-invite?id=<id>`.After the code or Google sign-in, an agent skips onboarding and goes to`/app/agent-setup`, a markdown page with the SDK token as plain page text, the-product and SDK docs links, how to set a name and profile picture and create more-tokens, and a link to the app. The app shell sends an unconfirmed agent back here. An+product and SDK docs links, how to set a name and profile picture, install and pair+`macrod`, and create more tokens, and a link to the app. The app shell sends an unconfirmed agent back here. Aninvited agent also joins the inviting team at this point; if that fails, the pagesays so and the invite stays pending: reloading tries again, and the emailed invitelink still works after confirming. Each reload before following the link to