@remixhq/mcp 0.1.13 → 0.1.15
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/dist/cli.js +133 -24
- package/dist/cli.js.map +1 -1
- package/dist/index.js +127 -23
- package/dist/index.js.map +1 -1
- package/dist/server.js +127 -23
- package/dist/server.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/domain/apiClient.ts","../src/bootstrap/auth.ts","../src/server.ts","../src/observability/logger.ts","../src/policy/policy.ts","../src/errors/normalizeError.ts","../src/errors/errorCodes.ts","../src/bootstrap/context.ts","../src/tools/collab/register.ts","../src/contracts/collab.ts","../src/contracts/common.ts","../src/domain/coreAdapter.ts","../src/domain/shared.ts","../src/domain/collabAdminAdapter.ts","../src/tools/identity/register.ts","../src/contracts/identity.ts","../src/domain/directoryAdapter.ts","../src/tools/memory/register.ts","../src/contracts/memory.ts","../src/domain/memoryAdapter.ts","../src/tools/ops/register.ts","../src/contracts/ops.ts","../src/domain/opsAdapter.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport { drainPendingFinalizeQueue } from \"@remixhq/core/collab\";\n\nimport { createCollabApiClient } from \"./domain/apiClient.js\";\nimport { startStdioServer } from \"./server.js\";\n\nconst require = createRequire(import.meta.url);\nconst { version } = require(\"../package.json\") as { version: string };\n\nasync function main(): Promise<void> {\n if (process.argv.includes(\"--drain-finalize-queue\")) {\n const api = await createCollabApiClient();\n await drainPendingFinalizeQueue({ api });\n return;\n }\n await startStdioServer({ version });\n}\n\nmain().catch((error) => {\n const message = error instanceof Error ? error.message : String(error);\n process.stderr.write(`${message}\\n`);\n process.exitCode = 1;\n});\n","import { createApiClient as createCoreApiClient, resolveConfig, type ApiClient } from \"@remixhq/core\";\nimport type { CollabApiClient } from \"@remixhq/core/collab\";\n\nimport { createRemixTokenProvider } from \"../bootstrap/auth.js\";\n\nexport async function createCollabApiClient(): Promise<CollabApiClient> {\n const config = await resolveConfig();\n const tokenProvider = await createRemixTokenProvider(config);\n const api = createCoreApiClient(config, {\n tokenProvider,\n });\n return api as unknown as CollabApiClient;\n}\n\nexport async function createApiClient(): Promise<ApiClient> {\n const config = await resolveConfig();\n const tokenProvider = await createRemixTokenProvider(config);\n return createCoreApiClient(config, {\n tokenProvider,\n });\n}\n","import { createLocalSessionStore, createStoredSessionTokenProvider, createSupabaseAuthHelpers, resolveConfig, type CoreConfig } from \"@remixhq/core\";\nimport type { TokenProvider } from \"@remixhq/core/auth\";\n\nexport async function createRemixTokenProvider(config?: CoreConfig): Promise<TokenProvider> {\n const resolvedConfig = config ?? (await resolveConfig());\n const sessionStore = createLocalSessionStore();\n return createStoredSessionTokenProvider({\n config: resolvedConfig,\n sessionStore,\n refreshStoredSession: async ({ config: refreshConfig, session }) => {\n const supabase = createSupabaseAuthHelpers(refreshConfig);\n return supabase.refreshWithStoredSession({ session });\n },\n });\n}\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\n\nimport { createServerContext } from \"./bootstrap/context.js\";\nimport { registerCollabTools } from \"./tools/collab/register.js\";\nimport { registerIdentityTools } from \"./tools/identity/register.js\";\nimport { registerMemoryTools } from \"./tools/memory/register.js\";\nimport { registerOpsTools } from \"./tools/ops/register.js\";\n\nexport function createRemixMcpServer(params: { version: string }) {\n const context = createServerContext({ version: params.version });\n const server = new McpServer({\n name: context.serverName,\n version: context.version,\n });\n\n registerIdentityTools(server, context);\n registerCollabTools(server, context);\n registerOpsTools(server, context);\n registerMemoryTools(server, context);\n\n return { server, context };\n}\n\nexport async function startStdioServer(params: { version: string }): Promise<void> {\n const { server } = createRemixMcpServer(params);\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n","export type LogLevel = \"info\" | \"error\";\n\nexport type LogEvent = {\n level: LogLevel;\n message: string;\n tool?: string;\n requestId?: string | null;\n durationMs?: number;\n result?: \"success\" | \"error\";\n errorCode?: string | null;\n repoRoot?: string | null;\n appId?: string | null;\n mrId?: string | null;\n truncated?: boolean;\n};\n\nexport type Logger = {\n log(event: LogEvent): void;\n};\n\nexport function createLogger(): Logger {\n return {\n log(event) {\n const payload = {\n timestamp: new Date().toISOString(),\n ...event,\n };\n const line = JSON.stringify(payload);\n if (event.level === \"error\") {\n process.stderr.write(`${line}\\n`);\n return;\n }\n process.stderr.write(`${line}\\n`);\n },\n };\n}\n","import path from \"node:path\";\n\nimport { createPolicyError } from \"../errors/normalizeError.js\";\n\nexport type ToolAccess = \"read\" | \"remote_write\" | \"local_write\";\n\nexport type Policy = {\n allowLocalWrite: boolean;\n allowRemoteWrite: boolean;\n allowedRepoRoots: string[] | null;\n maxDiffBytes: number;\n maxDiffOutputChars: number;\n};\n\nfunction parseBooleanEnv(name: string, fallback: boolean): boolean {\n const raw = process.env[name];\n if (!raw) return fallback;\n const normalized = raw.trim().toLowerCase();\n return normalized === \"1\" || normalized === \"true\" || normalized === \"yes\" || normalized === \"on\";\n}\n\nfunction parsePositiveIntEnv(name: string, fallback: number): number {\n const raw = process.env[name];\n if (!raw) return fallback;\n const parsed = Number.parseInt(raw, 10);\n return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;\n}\n\nfunction parseAllowedRoots(raw: string | undefined): string[] | null {\n if (!raw) return null;\n const roots = raw\n .split(path.delimiter)\n .map((entry) => entry.trim())\n .filter(Boolean)\n .map((entry) => path.resolve(entry));\n return roots.length > 0 ? roots : null;\n}\n\nfunction isWithinRoot(root: string, candidate: string): boolean {\n const relative = path.relative(root, candidate);\n return relative === \"\" || (!relative.startsWith(\"..\") && !path.isAbsolute(relative));\n}\n\nexport function loadPolicy(): Policy {\n return {\n allowLocalWrite: parseBooleanEnv(\"COMERGE_MCP_ALLOW_LOCAL_WRITE\", true),\n allowRemoteWrite: parseBooleanEnv(\"COMERGE_MCP_ALLOW_REMOTE_WRITE\", true),\n allowedRepoRoots: parseAllowedRoots(process.env.COMERGE_MCP_ALLOWED_REPO_ROOTS),\n maxDiffBytes: parsePositiveIntEnv(\"COMERGE_MCP_MAX_DIFF_BYTES\", 1024 * 1024),\n maxDiffOutputChars: parsePositiveIntEnv(\"COMERGE_MCP_MAX_DIFF_OUTPUT_CHARS\", 20_000),\n };\n}\n\nexport function resolvePolicyCwd(policy: Policy, cwd: string | undefined): string {\n const resolved = path.resolve(cwd?.trim() || process.cwd());\n if (!policy.allowedRepoRoots) return resolved;\n if (policy.allowedRepoRoots.some((root) => isWithinRoot(root, resolved))) return resolved;\n throw createPolicyError(\"Requested working directory is outside the allowed repository roots.\", resolved);\n}\n\nexport function assertToolAccess(policy: Policy, access: ToolAccess): void {\n if (access === \"read\") return;\n if (access === \"remote_write\" && !policy.allowRemoteWrite) {\n throw createPolicyError(\"Remote-mutating Remix tools are disabled by policy.\");\n }\n if (access === \"local_write\" && !policy.allowLocalWrite) {\n throw createPolicyError(\"Local-mutating Remix tools are disabled by policy.\");\n }\n}\n\nexport function assertConfirm(confirm: boolean | undefined, operation: string): void {\n if (confirm) return;\n throw createPolicyError(`${operation} requires explicit confirmation.`, \"Pass confirm=true to run this tool.\");\n}\n\nexport function assertDiffWithinLimit(policy: Policy, diff: string): void {\n const sizeBytes = Buffer.byteLength(diff, \"utf8\");\n if (sizeBytes <= policy.maxDiffBytes) return;\n throw createPolicyError(\n \"Diff exceeds the configured maximum size for Remix MCP.\",\n `Configured limit=${policy.maxDiffBytes} bytes actual=${sizeBytes} bytes.`,\n );\n}\n\nexport function truncateText(policy: Policy, value: string): { value: string; truncated: boolean; originalChars: number } {\n const originalChars = value.length;\n if (originalChars <= policy.maxDiffOutputChars) {\n return { value, truncated: false, originalChars };\n }\n return {\n value: `${value.slice(0, policy.maxDiffOutputChars)}\\n\\n[truncated ${originalChars - policy.maxDiffOutputChars} chars]`,\n truncated: true,\n originalChars,\n };\n}\n","import { ZodError } from \"zod\";\n\nimport { ERROR_CODES, type ErrorCategory, type ErrorCode, type NormalizedToolError, RemixMcpError } from \"./errorCodes.js\";\n\ntype ErrorLike = {\n code?: unknown;\n message?: unknown;\n hint?: unknown;\n exitCode?: unknown;\n};\n\nfunction toStringOrNull(value: unknown): string | null {\n if (typeof value !== \"string\") return null;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : null;\n}\n\nfunction parseJsonObject(value: string | null): Record<string, unknown> | null {\n if (!value) return null;\n try {\n const parsed = JSON.parse(value);\n return parsed && typeof parsed === \"object\" ? (parsed as Record<string, unknown>) : null;\n } catch {\n return null;\n }\n}\n\nfunction makeNormalized(params: {\n code: ErrorCode;\n message: string;\n hint?: string | null;\n retryable?: boolean;\n category: ErrorCategory;\n}): NormalizedToolError {\n return {\n code: params.code,\n message: params.message,\n hint: params.hint ?? null,\n retryable: params.retryable ?? false,\n category: params.category,\n };\n}\n\nfunction normalizeByMessage(err: ErrorLike): NormalizedToolError {\n const code = toStringOrNull(err.code);\n const message = toStringOrNull(err.message) ?? \"Unexpected error.\";\n const hint = toStringOrNull(err.hint);\n const hintBody = parseJsonObject(hint);\n const statusCode =\n typeof hintBody?.statusCode === \"number\"\n ? hintBody.statusCode\n : typeof hintBody?.statusCode === \"string\"\n ? Number(hintBody.statusCode)\n : null;\n\n if (code === ERROR_CODES.REPO_LOCK_HELD) {\n return makeNormalized({\n code: ERROR_CODES.REPO_LOCK_HELD,\n message,\n hint,\n retryable: true,\n category: \"local_state\",\n });\n }\n\n if (code === ERROR_CODES.REPO_LOCK_TIMEOUT) {\n return makeNormalized({\n code: ERROR_CODES.REPO_LOCK_TIMEOUT,\n message,\n hint,\n retryable: true,\n category: \"local_state\",\n });\n }\n\n if (code === ERROR_CODES.REPO_STATE_CHANGED_DURING_OPERATION) {\n return makeNormalized({\n code: ERROR_CODES.REPO_STATE_CHANGED_DURING_OPERATION,\n message,\n hint,\n retryable: true,\n category: \"local_state\",\n });\n }\n\n if (code === ERROR_CODES.REPO_LOCK_STALE_RECOVERED) {\n return makeNormalized({\n code: ERROR_CODES.REPO_LOCK_STALE_RECOVERED,\n message,\n hint,\n retryable: true,\n category: \"local_state\",\n });\n }\n\n if (message === \"Not signed in.\") {\n return makeNormalized({\n code: ERROR_CODES.AUTH_REQUIRED,\n message,\n hint,\n category: \"auth\",\n });\n }\n\n if (message === \"Not inside a git repository.\") {\n return makeNormalized({\n code: ERROR_CODES.NOT_GIT_REPO,\n message,\n hint,\n category: \"local_state\",\n });\n }\n\n if (message === \"Repository is not bound to Remix.\") {\n return makeNormalized({\n code: ERROR_CODES.NOT_BOUND,\n message,\n hint,\n category: \"local_state\",\n });\n }\n\n if (message.includes(\"Working tree must be clean\")) {\n return makeNormalized({\n code: ERROR_CODES.DIRTY_WORKTREE,\n message,\n hint,\n category: \"local_state\",\n });\n }\n\n if (message.includes(\"requires a checked out local branch\") || message.includes(\"detached HEAD\")) {\n return makeNormalized({\n code: ERROR_CODES.DETACHED_HEAD,\n message,\n hint,\n category: \"local_state\",\n });\n }\n\n if (code === ERROR_CODES.PREFERRED_BRANCH_MISMATCH || message.includes(\"preferred branch\") || message.includes(\"bound branch\")) {\n return makeNormalized({\n code: ERROR_CODES.PREFERRED_BRANCH_MISMATCH,\n message,\n hint,\n category: \"local_state\",\n });\n }\n\n if (message.includes(\"Multiple canonical Remix families\") || message.includes(\"family selection is ambiguous\")) {\n return makeNormalized({\n code: ERROR_CODES.FAMILY_SELECTION_AMBIGUOUS,\n message,\n hint,\n category: \"local_state\",\n });\n }\n\n if (message.includes(\"Failed to resolve local HEAD\")) {\n return makeNormalized({\n code: ERROR_CODES.MISSING_HEAD,\n message,\n hint,\n category: \"local_state\",\n });\n }\n\n if (message.includes(\"metadata conflicts with the bound Remix app\") || message.includes(\"manual intervention\")) {\n return makeNormalized({\n code: ERROR_CODES.METADATA_CONFLICT,\n message,\n hint,\n category: \"remote_state\",\n });\n }\n\n if (statusCode === 403) {\n return makeNormalized({\n code: ERROR_CODES.ACCESS_DENIED,\n message,\n hint,\n category: \"remote_state\",\n });\n }\n\n if (statusCode === 404) {\n return makeNormalized({\n code: ERROR_CODES.RESOURCE_NOT_FOUND,\n message,\n hint,\n category: \"remote_state\",\n });\n }\n\n if (message.includes(\"Timed out\") || message.includes(\"failed\") || message.includes(\"error state\")) {\n return makeNormalized({\n code: ERROR_CODES.REMOTE_ERROR,\n message,\n hint,\n retryable: true,\n category: \"remote_state\",\n });\n }\n\n return makeNormalized({\n code: ERROR_CODES.INTERNAL_ERROR,\n message,\n hint,\n retryable: true,\n category: \"internal\",\n });\n}\n\nexport function createPolicyError(message: string, hint?: string | null): RemixMcpError {\n return new RemixMcpError(\n makeNormalized({\n code: ERROR_CODES.DESTRUCTIVE_OPERATION_BLOCKED,\n message,\n hint,\n category: \"policy\",\n }),\n );\n}\n\nexport function createAuthRequiredError(hint?: string | null): RemixMcpError {\n return new RemixMcpError(\n makeNormalized({\n code: ERROR_CODES.AUTH_REQUIRED,\n message: \"COMERGE_ACCESS_TOKEN is required.\",\n hint: hint ?? \"Set COMERGE_ACCESS_TOKEN before using Remix MCP tools that call the backend.\",\n category: \"auth\",\n }),\n );\n}\n\nexport function normalizeToolError(error: unknown): NormalizedToolError {\n if (error instanceof RemixMcpError) {\n return error.normalized;\n }\n\n if (error instanceof ZodError) {\n return makeNormalized({\n code: ERROR_CODES.INVALID_INPUT,\n message: \"Tool arguments failed validation.\",\n hint: error.issues.map((issue) => `${issue.path.join(\".\") || \"input\"}: ${issue.message}`).join(\"; \"),\n category: \"validation\",\n });\n }\n\n if (error && typeof error === \"object\") {\n return normalizeByMessage(error as ErrorLike);\n }\n\n return makeNormalized({\n code: ERROR_CODES.INTERNAL_ERROR,\n message: typeof error === \"string\" && error.trim() ? error.trim() : \"Unexpected error.\",\n hint: null,\n retryable: true,\n category: \"internal\",\n });\n}\n","export const ERROR_CODES = {\n AUTH_REQUIRED: \"AUTH_REQUIRED\",\n INVALID_INPUT: \"INVALID_INPUT\",\n NOT_GIT_REPO: \"NOT_GIT_REPO\",\n NOT_BOUND: \"NOT_BOUND\",\n DIRTY_WORKTREE: \"DIRTY_WORKTREE\",\n DETACHED_HEAD: \"DETACHED_HEAD\",\n PREFERRED_BRANCH_MISMATCH: \"PREFERRED_BRANCH_MISMATCH\",\n FAMILY_SELECTION_AMBIGUOUS: \"FAMILY_SELECTION_AMBIGUOUS\",\n MISSING_HEAD: \"MISSING_HEAD\",\n REPO_LOCK_HELD: \"REPO_LOCK_HELD\",\n REPO_LOCK_TIMEOUT: \"REPO_LOCK_TIMEOUT\",\n REPO_LOCK_STALE_RECOVERED: \"REPO_LOCK_STALE_RECOVERED\",\n REPO_STATE_CHANGED_DURING_OPERATION: \"REPO_STATE_CHANGED_DURING_OPERATION\",\n REMOTE_ERROR: \"REMOTE_ERROR\",\n METADATA_CONFLICT: \"METADATA_CONFLICT\",\n DESTRUCTIVE_OPERATION_BLOCKED: \"DESTRUCTIVE_OPERATION_BLOCKED\",\n CONFIG_INVALID: \"CONFIG_INVALID\",\n ACCESS_DENIED: \"ACCESS_DENIED\",\n RESOURCE_NOT_FOUND: \"RESOURCE_NOT_FOUND\",\n INTERNAL_ERROR: \"INTERNAL_ERROR\",\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n\nexport type ErrorCategory = \"auth\" | \"validation\" | \"local_state\" | \"remote_state\" | \"policy\" | \"config\" | \"internal\";\n\nexport type NormalizedToolError = {\n code: ErrorCode;\n message: string;\n hint: string | null;\n retryable: boolean;\n category: ErrorCategory;\n};\n\nexport class RemixMcpError extends Error {\n public readonly normalized: NormalizedToolError;\n\n constructor(normalized: NormalizedToolError) {\n super(normalized.message);\n this.name = \"RemixMcpError\";\n this.normalized = normalized;\n }\n}\n","import type { CollabApiClient } from \"@remixhq/core/collab\";\n\nimport { createCollabApiClient } from \"../domain/apiClient.js\";\nimport { createLogger, type Logger } from \"../observability/logger.js\";\nimport { loadPolicy, type Policy } from \"../policy/policy.js\";\n\nexport type ServerContext = {\n serverName: string;\n version: string;\n policy: Policy;\n logger: Logger;\n getCollabApiClient(): Promise<CollabApiClient>;\n agentMetadata: {\n type: string;\n name?: string;\n version?: string;\n provider?: string;\n };\n};\n\nexport function createServerContext(params: { version: string }): ServerContext {\n return {\n serverName: \"remix-mcp\",\n version: params.version,\n policy: loadPolicy(),\n logger: createLogger(),\n getCollabApiClient: () => createCollabApiClient(),\n agentMetadata: {\n type: process.env.COMERGE_AGENT_TYPE?.trim() || \"agent\",\n name: process.env.COMERGE_AGENT_NAME?.trim() || \"remix-mcp\",\n version: process.env.COMERGE_AGENT_VERSION?.trim() || params.version,\n provider: process.env.COMERGE_AGENT_PROVIDER?.trim() || \"remix\",\n },\n };\n}\n","import { z } from \"zod\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { ToolAnnotations } from \"@modelcontextprotocol/sdk/types.js\";\n\nimport type { ServerContext } from \"../../bootstrap/context.js\";\nimport {\n drainFinalizeQueueInputSchema,\n drainFinalizeQueueSuccessSchema,\n finalizeTurnInputSchema,\n finalizeTurnSuccessSchema,\n accessDebugInputSchema,\n accessDebugSuccessSchema,\n acceptInvitationInputSchema,\n acceptInvitationSuccessSchema,\n approveInputSchema,\n approveSuccessSchema,\n appMergeRequestsInputSchema,\n checkoutInputSchema,\n checkoutSuccessSchema,\n initInputSchema,\n initSuccessSchema,\n listMembersInputSchema,\n listMembersSuccessSchema,\n inviteInputSchema,\n inviteSuccessSchema,\n reAnchorInputSchema,\n reAnchorSuccessSchema,\n listInputSchema,\n listInvitesInputSchema,\n listInvitesSuccessSchema,\n listSuccessSchema,\n mergeRequestQueueSuccessSchema,\n myMergeRequestsInputSchema,\n previewInputSchema,\n reconcileSuccessSchema,\n rejectInputSchema,\n rejectSuccessSchema,\n resendInviteInputSchema,\n resendInviteSuccessSchema,\n remixInputSchema,\n revokeInviteInputSchema,\n revokeInviteSuccessSchema,\n updateMemberRoleInputSchema,\n updateMemberRoleSuccessSchema,\n reviewQueueInputSchema,\n remixSuccessSchema,\n requestMergeInputSchema,\n requestMergeSuccessSchema,\n statusInputSchema,\n statusSuccessSchema,\n syncSuccessSchema,\n syncUpstreamSuccessSchema,\n viewMergeRequestInputSchema,\n viewMergeRequestSuccessSchema,\n applyInputSchema,\n} from \"../../contracts/collab.js\";\nimport { makeErrorResult, makeErrorSchema, makeSuccessResult, type ErrorEnvelope, type SuccessEnvelope, SCHEMA_VERSION } from \"../../contracts/common.js\";\nimport type { NormalizedToolError } from \"../../errors/errorCodes.js\";\nimport { normalizeToolError } from \"../../errors/normalizeError.js\";\nimport {\n drainFinalizeQueue,\n finalizeCollabTurn,\n approveMergeRequest,\n checkoutCollab,\n getStatus,\n initCollab,\n reAnchor,\n inviteCollaborator,\n listMembers,\n listAppMergeRequests,\n listApps,\n myMergeRequests,\n reconcile,\n rejectMergeRequest,\n remixCollab,\n reviewQueue,\n requestMerge,\n syncCollab,\n syncUpstream,\n updateMemberRole,\n viewMergeRequest,\n} from \"../../domain/coreAdapter.js\";\nimport {\n accessDebug as accessDebugRead,\n acceptInvitation as acceptInvitationByToken,\n listInvites as listScopeInvites,\n resendInvite as resendScopedInvite,\n revokeInvite as revokeScopedInvite,\n} from \"../../domain/collabAdminAdapter.js\";\nimport { assertConfirm, assertToolAccess, resolvePolicyCwd, type ToolAccess } from \"../../policy/policy.js\";\n\ntype ToolExecutionResult<T> = {\n data: T;\n warnings?: string[];\n risks?: string[];\n recommendedNextActions?: string[];\n logContext?: {\n repoRoot?: string | null;\n appId?: string | null;\n mrId?: string | null;\n };\n};\n\nfunction getAnnotations(access: ToolAccess, options?: { idempotent?: boolean }): ToolAnnotations {\n if (access === \"read\") {\n return {\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n };\n }\n return {\n readOnlyHint: false,\n destructiveHint: access === \"local_write\",\n idempotentHint: options?.idempotent ?? false,\n openWorldHint: false,\n };\n}\n\nfunction buildSuccessEnvelope<T>(tool: string, requestId: string | undefined, result: ToolExecutionResult<T>): SuccessEnvelope<T> {\n return {\n schemaVersion: SCHEMA_VERSION,\n ok: true,\n tool,\n requestId: requestId ?? null,\n data: result.data,\n warnings: result.warnings ?? [],\n risks: result.risks ?? [],\n recommendedNextActions: result.recommendedNextActions ?? [],\n };\n}\n\nfunction deriveErrorRisks(tool: string, normalized: NormalizedToolError): string[] {\n if (normalized.code === \"DESTRUCTIVE_OPERATION_BLOCKED\") {\n return [\"A policy guard blocked a potentially destructive or state-mutating operation.\"];\n }\n if (normalized.code === \"REPO_LOCK_TIMEOUT\") {\n return [\"Another Remix mutation was already in progress for this repository, so the local mutation did not run.\"];\n }\n if (normalized.code === \"REPO_STATE_CHANGED_DURING_OPERATION\") {\n return [\"The repository changed during the operation, so Remix aborted before applying a destructive local mutation.\"];\n }\n return [];\n}\n\nfunction buildErrorEnvelope(tool: string, requestId: string | undefined, error: unknown): ErrorEnvelope {\n const normalized = normalizeToolError(error);\n const recommendedNextActions =\n normalized.code === \"AUTH_REQUIRED\"\n ? [\"Set COMERGE_ACCESS_TOKEN, then retry the tool call.\"]\n : normalized.code === \"REPO_LOCK_TIMEOUT\"\n ? [\"Wait for the active Remix mutation to finish, then retry the tool call.\"]\n : normalized.code === \"REPO_STATE_CHANGED_DURING_OPERATION\"\n ? [\"Review local repository changes, then rerun the tool once the worktree is stable.\"]\n : normalized.code === \"PREFERRED_BRANCH_MISMATCH\"\n ? [\"Switch to the repository's preferred Remix branch, or rerun with allowBranchMismatch=true if intentional.\"]\n : [];\n return {\n schemaVersion: SCHEMA_VERSION,\n ok: false,\n tool,\n requestId: requestId ?? null,\n error: normalized,\n warnings: [],\n risks: deriveErrorRisks(tool, normalized),\n recommendedNextActions,\n };\n}\n\nfunction registerTool<T>(\n server: McpServer,\n context: ServerContext,\n params: {\n name: string;\n description: string;\n access: ToolAccess;\n annotations?: ToolAnnotations;\n inputSchema: Record<string, z.ZodTypeAny>;\n outputSchema: z.ZodTypeAny;\n run: (args: Record<string, unknown>) => Promise<ToolExecutionResult<T>>;\n },\n) {\n const errorSchema = makeErrorSchema();\n server.registerTool(\n params.name,\n {\n title: params.name,\n description: params.description,\n inputSchema: params.inputSchema,\n outputSchema: params.outputSchema,\n annotations: params.annotations ?? getAnnotations(params.access),\n },\n async (rawArgs: Record<string, unknown>) => {\n const requestId = typeof rawArgs.requestId === \"string\" ? rawArgs.requestId : undefined;\n const startedAt = Date.now();\n try {\n assertToolAccess(context.policy, params.access);\n const result = await params.run(rawArgs);\n const envelope = buildSuccessEnvelope(params.name, requestId, result);\n params.outputSchema.parse(envelope);\n context.logger.log({\n level: \"info\",\n message: \"tool_completed\",\n tool: params.name,\n requestId: envelope.requestId,\n durationMs: Date.now() - startedAt,\n result: \"success\",\n repoRoot: result.logContext?.repoRoot ?? null,\n appId: result.logContext?.appId ?? null,\n mrId: result.logContext?.mrId ?? null,\n truncated: result.warnings?.some((warning) => warning.toLowerCase().includes(\"truncated\")) ?? false,\n });\n return makeSuccessResult(envelope);\n } catch (error) {\n const envelope = buildErrorEnvelope(params.name, requestId, error);\n errorSchema.parse(envelope);\n context.logger.log({\n level: \"error\",\n message: \"tool_failed\",\n tool: params.name,\n requestId: envelope.requestId,\n durationMs: Date.now() - startedAt,\n result: \"error\",\n errorCode: envelope.error.code,\n });\n return makeErrorResult(envelope);\n }\n },\n );\n}\n\nexport function registerCollabTools(server: McpServer, context: ServerContext): void {\n registerTool(server, context, {\n name: \"remix_collab_status\",\n description: \"Required first read for a bound repository: summarize binding, worktree state, merge request counts, and sync or reconcile readiness before Remix mutations.\",\n access: \"read\",\n inputSchema: statusInputSchema,\n outputSchema: statusSuccessSchema,\n run: async (args) => {\n const input = z.object(statusInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return getStatus({\n cwd,\n includeRemote: input.includeRemote ?? true,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_init\",\n description: \"Import the current repository into Remix and write the local binding file.\",\n access: \"remote_write\",\n inputSchema: initInputSchema,\n outputSchema: initSuccessSchema,\n run: async (args) => {\n const input = z.object(initInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return initCollab({\n cwd,\n appName: input.appName,\n forceNew: input.forceNew,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_list\",\n description:\n \"List Remix apps visible to the current authenticated user. Defaults to membership-oriented discovery; pass accessScope=all_readable explicitly for broader readable discovery.\",\n access: \"read\",\n inputSchema: listInputSchema,\n outputSchema: listSuccessSchema,\n run: async (args) => {\n const input = z.object(listInputSchema).parse(args);\n return listApps({\n ownership: input.ownership,\n accessScope: input.accessScope,\n createdBy: input.createdBy,\n forked: input.forked,\n limit: input.limit,\n offset: input.offset,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_remix\",\n description: \"Fork a Remix app and materialize a new local checkout bound to the remix. Prefer `outputDir` for an exact destination outside any existing git repo; `cwd` is only the parent-directory fallback.\",\n access: \"remote_write\",\n inputSchema: remixInputSchema,\n outputSchema: remixSuccessSchema,\n run: async (args) => {\n const input = z.object(remixInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return remixCollab({\n cwd,\n appId: input.appId,\n name: input.name,\n outputDir: input.outputDir,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_checkout\",\n description: \"Materialize an existing Remix app as-is into a new local checkout without creating a new fork. Works for original apps and fork apps; the resulting binding preserves that lineage.\",\n access: \"remote_write\",\n inputSchema: checkoutInputSchema,\n outputSchema: checkoutSuccessSchema,\n run: async (args) => {\n const input = z.object(checkoutInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return checkoutCollab({\n cwd,\n appId: input.appId,\n outputDir: input.outputDir,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_finalize_turn\",\n description:\n \"Primary turn recorder for the current bound repository. Call this exactly once before the final response; it captures the current boundary locally and queues remote processing. Queued only: no remote change step exists yet until the finalize queue is drained.\",\n access: \"local_write\",\n inputSchema: finalizeTurnInputSchema,\n outputSchema: finalizeTurnSuccessSchema,\n annotations: getAnnotations(\"local_write\", { idempotent: true }),\n run: async (args) => {\n const input = z.object(finalizeTurnInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return finalizeCollabTurn({\n cwd,\n prompt: input.prompt,\n assistantResponse: input.assistantResponse,\n sync: input.sync,\n allowBranchMismatch: input.allowBranchMismatch ?? false,\n idempotencyKey: input.idempotencyKey,\n agent: context.agentMetadata,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_drain_finalize_queue\",\n description:\n \"Drain the local finalize queue and record queued finalize_turn jobs immediately. Use this before request-merge, reconcile, or other flows that require the remote change step to exist already.\",\n access: \"local_write\",\n inputSchema: drainFinalizeQueueInputSchema,\n outputSchema: drainFinalizeQueueSuccessSchema,\n annotations: getAnnotations(\"local_write\", { idempotent: true }),\n run: async (args) => {\n const input = z.object(drainFinalizeQueueInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return drainFinalizeQueue({ cwd });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_sync_preview\",\n description: \"Preview whether the current bound repository can pull the server delta into the working tree. Use this instead of raw git pull or rebase for bound-repo alignment.\",\n access: \"read\",\n inputSchema: previewInputSchema,\n outputSchema: syncSuccessSchema,\n run: async (args) => {\n const input = z.object(previewInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return syncCollab({ cwd, dryRun: true });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_sync_apply\",\n description: \"Pull the server delta into the local working tree without moving local git history. This is the Remix-native replacement for raw git pull or rebase in a bound repo.\",\n access: \"local_write\",\n inputSchema: applyInputSchema,\n outputSchema: syncSuccessSchema,\n run: async (args) => {\n const input = z.object(applyInputSchema).parse(args);\n assertConfirm(input.confirm, \"remix_collab_sync_apply\");\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return syncCollab({ cwd, dryRun: false, allowBranchMismatch: input.allowBranchMismatch ?? false });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_re_anchor_preview\",\n description: \"Preview whether the current checkout needs an explicit re-anchor to adopt or recover external Git/GitHub history.\",\n access: \"read\",\n inputSchema: previewInputSchema,\n outputSchema: reAnchorSuccessSchema,\n run: async (args) => {\n const input = z.object(previewInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return reAnchor({ cwd, dryRun: true });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_re_anchor_apply\",\n description: \"Explicitly re-anchor the current lane to adopted or recovered external Git/GitHub history, without rewriting the local checkout afterward.\",\n access: \"local_write\",\n inputSchema: reAnchorInputSchema,\n outputSchema: reAnchorSuccessSchema,\n run: async (args) => {\n const input = z.object(reAnchorInputSchema).parse(args);\n assertConfirm(input.confirm, \"remix_collab_re_anchor_apply\");\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return reAnchor({ cwd, dryRun: false, allowBranchMismatch: input.allowBranchMismatch ?? false });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_request_merge\",\n description: \"Open a prompt-backed Remix merge request from the current bound repository to its upstream app instead of merging locally with raw git.\",\n access: \"remote_write\",\n inputSchema: requestMergeInputSchema,\n outputSchema: requestMergeSuccessSchema,\n run: async (args) => {\n const input = z.object(requestMergeInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return requestMerge({ cwd });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_review_queue\",\n description: \"List reviewable merge requests: open requests the current user can actively approve or reject on target apps they administer or maintain. Optional `status` filters the results; optional `kind` defaults to `merge`.\",\n access: \"read\",\n inputSchema: reviewQueueInputSchema,\n outputSchema: mergeRequestQueueSuccessSchema,\n run: async (args) => {\n const input = z.object(reviewQueueInputSchema).parse(args);\n return reviewQueue({\n status: input.status,\n kind: input.kind,\n limit: input.limit,\n offset: input.offset,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_my_merge_requests\",\n description: \"List merge requests created by the current user across all apps visible to that user, not just the current bound checkout. This still works even when the user is not a reviewer on the target app. Optional `status` filters the results; optional `kind` defaults to `merge`.\",\n access: \"read\",\n inputSchema: myMergeRequestsInputSchema,\n outputSchema: mergeRequestQueueSuccessSchema,\n run: async (args) => {\n const input = z.object(myMergeRequestsInputSchema).parse(args);\n return myMergeRequests({\n status: input.status,\n kind: input.kind,\n limit: input.limit,\n offset: input.offset,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_list_app_merge_requests\",\n description: \"List app-scoped merge requests for the current bound checkout or an explicit `appId`. Required `queue` must be one of: `app_reviewable` (incoming requests this app can review), `app_outgoing` (requests created from this app), or `app_related_visible` (all open visible requests where this app is either source or target). Optional `status` filters the results; optional `kind` defaults to `merge`.\",\n access: \"read\",\n inputSchema: appMergeRequestsInputSchema,\n outputSchema: mergeRequestQueueSuccessSchema,\n run: async (args) => {\n const input = z.object(appMergeRequestsInputSchema).parse(args);\n const cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n return listAppMergeRequests({\n cwd,\n appId: input.appId,\n queue: input.queue,\n status: input.status,\n kind: input.kind,\n limit: input.limit,\n offset: input.offset,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_view_merge_request\",\n description: \"View Remix merge request metadata, review groups, change steps, and optionally a bounded unified diff before approval or rejection.\",\n access: \"read\",\n inputSchema: viewMergeRequestInputSchema,\n outputSchema: viewMergeRequestSuccessSchema,\n run: async (args) => {\n const input = z.object(viewMergeRequestInputSchema).parse(args);\n return viewMergeRequest({\n mrId: input.mrId,\n includeUnifiedDiff: input.includeUnifiedDiff ?? false,\n diffMaxChars: input.diffMaxChars ?? context.policy.maxDiffOutputChars,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_approve_remote\",\n description: \"Approve a merge request or upstream sync remotely and wait for terminal completion without mutating the local repository, preserving Remix as the merge authority.\",\n access: \"remote_write\",\n inputSchema: approveInputSchema,\n outputSchema: approveSuccessSchema,\n run: async (args) => {\n const input = z.object(approveInputSchema).parse(args);\n assertConfirm(input.confirm, \"remix_collab_approve_remote\");\n return approveMergeRequest({\n mrId: input.mrId,\n mode: \"remote-only\",\n allowBranchMismatch: input.allowBranchMismatch ?? false,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_approve_and_sync_target\",\n description: \"Approve a merge request, wait for completion, and sync the target repository locally through Remix rather than a local git merge flow.\",\n access: \"local_write\",\n inputSchema: approveInputSchema,\n outputSchema: approveSuccessSchema,\n run: async (args) => {\n const input = z.object(approveInputSchema).parse(args);\n assertConfirm(input.confirm, \"remix_collab_approve_and_sync_target\");\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return approveMergeRequest({\n mrId: input.mrId,\n cwd,\n mode: \"sync-target-repo\",\n allowBranchMismatch: input.allowBranchMismatch ?? false,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_reject\",\n description: \"Reject a merge request.\",\n access: \"remote_write\",\n inputSchema: rejectInputSchema,\n outputSchema: rejectSuccessSchema,\n run: async (args) => {\n const input = z.object(rejectInputSchema).parse(args);\n assertConfirm(input.confirm, \"remix_collab_reject\");\n return rejectMergeRequest({ mrId: input.mrId });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_sync_upstream\",\n description: \"Sync upstream changes into the current remix and update the local checkout through Remix-native lineage management rather than raw git pull or merge.\",\n access: \"local_write\",\n inputSchema: applyInputSchema,\n outputSchema: syncUpstreamSuccessSchema,\n run: async (args) => {\n const input = z.object(applyInputSchema).parse(args);\n assertConfirm(input.confirm, \"remix_collab_sync_upstream\");\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return syncUpstream({ cwd });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_reconcile_preview\",\n description: \"Preview the explicit Remix recovery flow when local and server state diverged beyond a simple pull.\",\n access: \"read\",\n inputSchema: previewInputSchema,\n outputSchema: reconcileSuccessSchema,\n run: async (args) => {\n const input = z.object(previewInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return reconcile({ cwd, dryRun: true });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_reconcile_apply\",\n description: \"Run the explicit Remix recovery flow for diverged local/server state.\",\n access: \"local_write\",\n inputSchema: applyInputSchema,\n outputSchema: reconcileSuccessSchema,\n run: async (args) => {\n const input = z.object(applyInputSchema).parse(args);\n assertConfirm(input.confirm, \"remix_collab_reconcile_apply\");\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return reconcile({ cwd, dryRun: false, allowBranchMismatch: input.allowBranchMismatch ?? false });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_invite\",\n description: \"Invite a collaborator to an organization, project, or app, using the current repository binding unless targetId is provided.\",\n access: \"remote_write\",\n inputSchema: inviteInputSchema,\n outputSchema: inviteSuccessSchema,\n run: async (args) => {\n const input = z.object(inviteInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return inviteCollaborator({\n cwd,\n email: input.email,\n role: input.role,\n scope: input.scope,\n targetId: input.targetId,\n ttlDays: input.ttlDays,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_list_members\",\n description: \"List organization, project, or app members, using the current repository binding unless targetId is provided.\",\n access: \"read\",\n inputSchema: listMembersInputSchema,\n outputSchema: listMembersSuccessSchema,\n run: async (args) => {\n const input = z.object(listMembersInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return listMembers({\n cwd,\n scope: input.scope,\n targetId: input.targetId,\n limit: input.limit,\n offset: input.offset,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_list_invites\",\n description: \"List invitations for an organization, project, or app, using the current repository binding unless targetId is provided.\",\n access: \"read\",\n inputSchema: listInvitesInputSchema,\n outputSchema: listInvitesSuccessSchema,\n run: async (args) => {\n const input = z.object(listInvitesInputSchema).parse(args);\n const cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n return listScopeInvites({\n cwd,\n scope: input.scope ?? \"project\",\n targetId: input.targetId,\n limit: input.limit,\n offset: input.offset,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_resend_invite\",\n description: \"Resend an existing invitation for an organization, project, or app, using the current repository binding unless targetId is provided.\",\n access: \"remote_write\",\n inputSchema: resendInviteInputSchema,\n outputSchema: resendInviteSuccessSchema,\n run: async (args) => {\n const input = z.object(resendInviteInputSchema).parse(args);\n const cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n return resendScopedInvite({\n cwd,\n scope: input.scope ?? \"project\",\n targetId: input.targetId,\n inviteId: input.inviteId,\n ttlDays: input.ttlDays,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_revoke_invite\",\n description: \"Revoke an existing invitation for an organization, project, or app, using the current repository binding unless targetId is provided.\",\n access: \"remote_write\",\n inputSchema: revokeInviteInputSchema,\n outputSchema: revokeInviteSuccessSchema,\n run: async (args) => {\n const input = z.object(revokeInviteInputSchema).parse(args);\n assertConfirm(input.confirm, \"remix_collab_revoke_invite\");\n const cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n return revokeScopedInvite({\n cwd,\n scope: input.scope ?? \"project\",\n targetId: input.targetId,\n inviteId: input.inviteId,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_accept_invitation\",\n description: \"Accept an invitation token for the currently authenticated Remix user.\",\n access: \"remote_write\",\n inputSchema: acceptInvitationInputSchema,\n outputSchema: acceptInvitationSuccessSchema,\n annotations: getAnnotations(\"remote_write\", { idempotent: true }),\n run: async (args) => {\n const input = z.object(acceptInvitationInputSchema).parse(args);\n return acceptInvitationByToken({\n token: input.token,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_access_debug\",\n description: \"Explain why the current user does or does not have access to an organization, project, or app by composing binding, membership, invite, and scope context.\",\n access: \"read\",\n inputSchema: accessDebugInputSchema,\n outputSchema: accessDebugSuccessSchema,\n run: async (args) => {\n const input = z.object(accessDebugInputSchema).parse(args);\n const cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n return accessDebugRead({\n cwd,\n scope: input.scope ?? \"project\",\n targetId: input.targetId,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_update_member_role\",\n description: \"Update an organization, project, or app member role, using the current repository binding unless targetId is provided.\",\n access: \"remote_write\",\n inputSchema: updateMemberRoleInputSchema,\n outputSchema: updateMemberRoleSuccessSchema,\n run: async (args) => {\n const input = z.object(updateMemberRoleInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return updateMemberRole({\n cwd,\n scope: input.scope,\n targetId: input.targetId,\n userId: input.userId,\n role: input.role,\n });\n },\n });\n}\n","import { z } from \"zod\";\n\nimport { commonRequestFieldsSchema, makeSuccessSchema } from \"./common.js\";\n\nconst genericRecordSchema = z.record(z.string(), z.unknown());\nconst genericArraySchema = z.array(genericRecordSchema);\nconst paginationSchema = z.object({\n limit: z.number().int().positive(),\n offset: z.number().int().nonnegative(),\n hasMore: z.boolean(),\n});\nconst mergeRequestQueueSchema = z.enum([\n \"reviewable\",\n \"created_by_me\",\n \"app_reviewable\",\n \"app_outgoing\",\n \"app_related_visible\",\n]);\nconst appScopedMergeRequestQueueSchema = z.enum([\"app_reviewable\", \"app_outgoing\", \"app_related_visible\"]);\nconst memberScopeSchema = z.enum([\"organization\", \"project\", \"app\"]);\n\nexport const statusInputSchema = {\n ...commonRequestFieldsSchema,\n includeRemote: z.boolean().optional(),\n};\n\nexport const initInputSchema = {\n ...commonRequestFieldsSchema,\n appName: z.string().trim().min(1).optional(),\n forceNew: z.boolean().optional(),\n};\n\nexport const listInputSchema = {\n requestId: z.string().trim().min(1).optional(),\n outputMode: z.enum([\"summary\", \"full\"]).optional(),\n ownership: z.enum([\"mine\", \"shared\", \"all\"]).optional(),\n accessScope: z.enum([\"all_readable\", \"explicit_member\"]).optional(),\n createdBy: z.string().trim().min(1).optional(),\n forked: z.enum([\"only\", \"exclude\", \"all\"]).optional(),\n limit: z.number().int().positive().max(50).optional(),\n offset: z.number().int().nonnegative().optional(),\n};\n\nexport const remixInputSchema = {\n ...commonRequestFieldsSchema,\n appId: z.string().trim().min(1),\n name: z.string().trim().min(1).optional(),\n outputDir: z.string().trim().min(1).optional(),\n};\n\nexport const checkoutInputSchema = {\n ...commonRequestFieldsSchema,\n appId: z.string().trim().min(1),\n outputDir: z.string().trim().min(1).optional(),\n};\n\nexport const addInputSchema = {\n ...commonRequestFieldsSchema,\n prompt: z.string().trim().min(1),\n assistantResponse: z.string().trim().min(1).optional(),\n diffSource: z.enum([\"worktree\", \"external\"]).optional(),\n externalDiff: z.string().optional(),\n allowBranchMismatch: z.boolean().optional(),\n idempotencyKey: z.string().trim().min(1).optional(),\n};\n\nexport const recordTurnInputSchema = {\n ...commonRequestFieldsSchema,\n prompt: z.string().trim().min(1),\n assistantResponse: z.string().trim().min(1),\n allowBranchMismatch: z.boolean().optional(),\n idempotencyKey: z.string().trim().min(1).optional(),\n};\n\nexport const finalizeTurnInputSchema = {\n ...commonRequestFieldsSchema,\n prompt: z.string().trim().min(1),\n assistantResponse: z.string().trim().min(1),\n sync: z.boolean().optional(),\n allowBranchMismatch: z.boolean().optional(),\n idempotencyKey: z.string().trim().min(1).optional(),\n};\n\nexport const previewInputSchema = {\n ...commonRequestFieldsSchema,\n};\n\nexport const drainFinalizeQueueInputSchema = {\n ...commonRequestFieldsSchema,\n};\n\nexport const applyInputSchema = {\n ...commonRequestFieldsSchema,\n confirm: z.boolean(),\n allowBranchMismatch: z.boolean().optional(),\n};\n\nexport const reAnchorInputSchema = {\n ...applyInputSchema,\n};\n\nexport const requestMergeInputSchema = {\n ...commonRequestFieldsSchema,\n};\n\nexport const reviewQueueInputSchema = {\n requestId: z.string().trim().min(1).optional(),\n outputMode: z.enum([\"summary\", \"full\"]).optional(),\n status: z.string().trim().min(1).optional(),\n kind: z.enum([\"merge\", \"sync\", \"all\"]).optional(),\n limit: z.number().int().positive().max(50).optional(),\n offset: z.number().int().nonnegative().optional(),\n};\n\nexport const myMergeRequestsInputSchema = {\n requestId: z.string().trim().min(1).optional(),\n outputMode: z.enum([\"summary\", \"full\"]).optional(),\n status: z.string().trim().min(1).optional(),\n kind: z.enum([\"merge\", \"sync\", \"all\"]).optional(),\n limit: z.number().int().positive().max(50).optional(),\n offset: z.number().int().nonnegative().optional(),\n};\n\nexport const appMergeRequestsInputSchema = {\n ...commonRequestFieldsSchema,\n queue: appScopedMergeRequestQueueSchema,\n appId: z.string().trim().min(1).optional(),\n status: z.string().trim().min(1).optional(),\n kind: z.enum([\"merge\", \"sync\", \"all\"]).optional(),\n limit: z.number().int().positive().max(50).optional(),\n offset: z.number().int().nonnegative().optional(),\n};\n\nexport const viewMergeRequestInputSchema = {\n requestId: z.string().trim().min(1).optional(),\n outputMode: z.enum([\"summary\", \"full\"]).optional(),\n mrId: z.string().trim().min(1),\n includeUnifiedDiff: z.boolean().optional(),\n diffMaxChars: z.number().int().positive().max(200_000).optional(),\n};\n\nexport const approveInputSchema = {\n ...commonRequestFieldsSchema,\n mrId: z.string().trim().min(1),\n confirm: z.boolean(),\n allowBranchMismatch: z.boolean().optional(),\n};\n\nexport const rejectInputSchema = {\n requestId: z.string().trim().min(1).optional(),\n mrId: z.string().trim().min(1),\n confirm: z.boolean(),\n};\n\nexport const inviteInputSchema = {\n ...commonRequestFieldsSchema,\n email: z.string().email(),\n scope: z.enum([\"organization\", \"project\", \"app\"]).optional(),\n targetId: z.string().trim().min(1).optional(),\n role: z.string().trim().min(1).optional(),\n ttlDays: z.number().int().positive().max(30).optional(),\n};\n\nexport const listMembersInputSchema = {\n ...commonRequestFieldsSchema,\n scope: memberScopeSchema,\n targetId: z.string().trim().min(1).optional(),\n limit: z.number().int().positive().max(50).optional(),\n offset: z.number().int().nonnegative().optional(),\n};\n\nexport const listInvitesInputSchema = {\n ...commonRequestFieldsSchema,\n scope: memberScopeSchema.optional(),\n targetId: z.string().trim().min(1).optional(),\n limit: z.number().int().positive().max(50).optional(),\n offset: z.number().int().nonnegative().optional(),\n};\n\nexport const resendInviteInputSchema = {\n ...commonRequestFieldsSchema,\n scope: memberScopeSchema.optional(),\n targetId: z.string().trim().min(1).optional(),\n inviteId: z.string().trim().min(1),\n ttlDays: z.number().int().positive().max(30).optional(),\n};\n\nexport const revokeInviteInputSchema = {\n ...commonRequestFieldsSchema,\n scope: memberScopeSchema.optional(),\n targetId: z.string().trim().min(1).optional(),\n inviteId: z.string().trim().min(1),\n confirm: z.boolean(),\n};\n\nexport const acceptInvitationInputSchema = {\n requestId: z.string().trim().min(1).optional(),\n token: z.string().trim().min(20),\n};\n\nexport const accessDebugInputSchema = {\n ...commonRequestFieldsSchema,\n scope: memberScopeSchema.optional(),\n targetId: z.string().trim().min(1).optional(),\n};\n\nexport const updateMemberRoleInputSchema = {\n ...commonRequestFieldsSchema,\n scope: memberScopeSchema,\n targetId: z.string().trim().min(1).optional(),\n userId: z.string().trim().min(1),\n role: z.string().trim().min(1),\n};\n\nexport const statusDataSchema = z.object({\n status: genericRecordSchema,\n riskLevel: z.enum([\"low\", \"medium\", \"high\"]),\n});\n\nexport const initDataSchema = z.object({\n reused: z.boolean(),\n projectId: z.string(),\n appId: z.string(),\n dashboardUrl: z.string().url(),\n upstreamAppId: z.string(),\n bindingPath: z.string(),\n repoRoot: z.string(),\n bindingMode: z.enum([\"legacy\", \"lane\", \"explicit_root\"]).optional(),\n createdCanonicalFamily: z.boolean().optional(),\n baselineStatus: z.enum([\"seeded\", \"existing\", \"requires_re_anchor\", \"requires_sync\"]).optional(),\n});\n\nexport const listDataSchema = z.object({\n apps: genericArraySchema,\n pagination: paginationSchema,\n});\n\nexport const remixDataSchema = z.object({\n appId: z.string(),\n dashboardUrl: z.string().url(),\n projectId: z.string(),\n upstreamAppId: z.string(),\n bindingPath: z.string(),\n repoRoot: z.string(),\n});\n\nexport const checkoutDataSchema = z.object({\n appId: z.string(),\n dashboardUrl: z.string().url(),\n projectId: z.string(),\n upstreamAppId: z.string(),\n bindingPath: z.string(),\n repoRoot: z.string(),\n});\n\nexport const addDataSchema = z.object({\n changeStep: genericRecordSchema,\n});\nexport const recordTurnDataSchema = genericRecordSchema;\nexport const finalizeTurnDataSchema = z.object({\n mode: z.enum([\"changed_turn\", \"no_diff_turn\"]),\n idempotencyKey: z.string().min(1),\n queued: z.boolean(),\n jobId: z.string().nullable(),\n repoState: z.string().nullable(),\n changeStep: genericRecordSchema.nullable(),\n collabTurn: genericRecordSchema.nullable(),\n autoSync: genericRecordSchema.nullable(),\n warnings: z.array(z.string()),\n});\nexport const drainFinalizeQueueDataSchema = z.object({\n processed: z.number().int().nonnegative(),\n results: z.array(genericRecordSchema),\n});\n\nexport const syncDataSchema = genericRecordSchema;\nexport const reAnchorDataSchema = genericRecordSchema;\nexport const requestMergeDataSchema = genericRecordSchema;\nexport const mergeRequestQueueDataSchema = z.object({\n queue: mergeRequestQueueSchema,\n appId: z.string().nullable(),\n mergeRequests: z.array(genericRecordSchema),\n pagination: paginationSchema,\n});\nexport const viewMergeRequestDataSchema = genericRecordSchema;\nexport const approveDataSchema = genericRecordSchema;\nexport const rejectDataSchema = genericRecordSchema;\nexport const syncUpstreamDataSchema = genericRecordSchema;\nexport const reconcileDataSchema = genericRecordSchema;\nexport const inviteDataSchema = genericRecordSchema;\nexport const memberRecordSchema = genericRecordSchema;\nexport const listMembersDataSchema = z.object({\n scopeType: memberScopeSchema,\n targetId: z.string(),\n members: z.array(memberRecordSchema),\n pagination: paginationSchema,\n});\nexport const listInvitesDataSchema = z.object({\n scopeType: memberScopeSchema,\n targetId: z.string(),\n invites: z.array(genericRecordSchema),\n pagination: paginationSchema,\n});\nexport const resendInviteDataSchema = genericRecordSchema;\nexport const revokeInviteDataSchema = z.object({\n scopeType: memberScopeSchema,\n targetId: z.string(),\n inviteId: z.string(),\n revoked: z.boolean(),\n});\nexport const acceptInvitationDataSchema = genericRecordSchema;\nexport const accessDebugDataSchema = z.object({\n viewer: genericRecordSchema,\n scope: z.object({\n scopeType: memberScopeSchema,\n targetId: z.string(),\n }),\n entities: z.object({\n organization: genericRecordSchema.nullable(),\n project: genericRecordSchema.nullable(),\n app: genericRecordSchema.nullable(),\n }),\n binding: z.object({\n repoRoot: z.string().nullable(),\n binding: genericRecordSchema.nullable(),\n }),\n access: z.object({\n appContext: genericRecordSchema.nullable(),\n viewerMember: genericRecordSchema.nullable(),\n viewerProjectMember: genericRecordSchema.nullable(),\n inviteForViewerEmail: genericRecordSchema.nullable(),\n effectiveAppAccess: genericRecordSchema.nullable(),\n }),\n members: z.array(genericRecordSchema),\n membersPageInfo: paginationSchema,\n invites: z.array(genericRecordSchema),\n invitesPageInfo: paginationSchema,\n});\nexport const updateMemberRoleDataSchema = z.object({\n scopeType: memberScopeSchema,\n targetId: z.string(),\n member: memberRecordSchema,\n});\n\nexport const statusSuccessSchema = makeSuccessSchema(statusDataSchema);\nexport const initSuccessSchema = makeSuccessSchema(initDataSchema);\nexport const listSuccessSchema = makeSuccessSchema(listDataSchema);\nexport const remixSuccessSchema = makeSuccessSchema(remixDataSchema);\nexport const checkoutSuccessSchema = makeSuccessSchema(checkoutDataSchema);\nexport const addSuccessSchema = makeSuccessSchema(addDataSchema);\nexport const recordTurnSuccessSchema = makeSuccessSchema(recordTurnDataSchema);\nexport const finalizeTurnSuccessSchema = makeSuccessSchema(finalizeTurnDataSchema);\nexport const drainFinalizeQueueSuccessSchema = makeSuccessSchema(drainFinalizeQueueDataSchema);\nexport const syncSuccessSchema = makeSuccessSchema(syncDataSchema);\nexport const reAnchorSuccessSchema = makeSuccessSchema(reAnchorDataSchema);\nexport const requestMergeSuccessSchema = makeSuccessSchema(requestMergeDataSchema);\nexport const mergeRequestQueueSuccessSchema = makeSuccessSchema(mergeRequestQueueDataSchema);\nexport const viewMergeRequestSuccessSchema = makeSuccessSchema(viewMergeRequestDataSchema);\nexport const approveSuccessSchema = makeSuccessSchema(approveDataSchema);\nexport const rejectSuccessSchema = makeSuccessSchema(rejectDataSchema);\nexport const syncUpstreamSuccessSchema = makeSuccessSchema(syncUpstreamDataSchema);\nexport const reconcileSuccessSchema = makeSuccessSchema(reconcileDataSchema);\nexport const inviteSuccessSchema = makeSuccessSchema(inviteDataSchema);\nexport const listMembersSuccessSchema = makeSuccessSchema(listMembersDataSchema);\nexport const listInvitesSuccessSchema = makeSuccessSchema(listInvitesDataSchema);\nexport const resendInviteSuccessSchema = makeSuccessSchema(resendInviteDataSchema);\nexport const revokeInviteSuccessSchema = makeSuccessSchema(revokeInviteDataSchema);\nexport const acceptInvitationSuccessSchema = makeSuccessSchema(acceptInvitationDataSchema);\nexport const accessDebugSuccessSchema = makeSuccessSchema(accessDebugDataSchema);\nexport const updateMemberRoleSuccessSchema = makeSuccessSchema(updateMemberRoleDataSchema);\n","import type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { z } from \"zod\";\n\nimport type { ErrorCategory, ErrorCode, NormalizedToolError } from \"../errors/errorCodes.js\";\n\nexport const SCHEMA_VERSION = 1 as const;\n\nexport const commonRequestFieldsSchema = {\n cwd: z.string().trim().min(1).optional(),\n requestId: z.string().trim().min(1).optional(),\n outputMode: z.enum([\"summary\", \"full\"]).optional(),\n};\n\nexport const errorEnvelopeSchema = z.object({\n code: z.custom<ErrorCode>(),\n message: z.string().min(1),\n hint: z.string().nullable(),\n retryable: z.boolean(),\n category: z.custom<ErrorCategory>(),\n});\n\nexport function makeSuccessSchema(dataSchema: z.ZodTypeAny) {\n return z.object({\n schemaVersion: z.literal(SCHEMA_VERSION),\n ok: z.literal(true),\n tool: z.string().min(1),\n requestId: z.string().nullable(),\n data: dataSchema,\n warnings: z.array(z.string()),\n risks: z.array(z.string()),\n recommendedNextActions: z.array(z.string()),\n });\n}\n\nexport function makeErrorSchema() {\n return z.object({\n schemaVersion: z.literal(SCHEMA_VERSION),\n ok: z.literal(false),\n tool: z.string().min(1),\n requestId: z.string().nullable(),\n error: errorEnvelopeSchema,\n warnings: z.array(z.string()),\n risks: z.array(z.string()),\n recommendedNextActions: z.array(z.string()),\n });\n}\n\nexport type SuccessEnvelope<T> = {\n schemaVersion: typeof SCHEMA_VERSION;\n ok: true;\n tool: string;\n requestId: string | null;\n data: T;\n warnings: string[];\n risks: string[];\n recommendedNextActions: string[];\n};\n\nexport type ErrorEnvelope = {\n schemaVersion: typeof SCHEMA_VERSION;\n ok: false;\n tool: string;\n requestId: string | null;\n error: NormalizedToolError;\n warnings: string[];\n risks: string[];\n recommendedNextActions: string[];\n};\n\nfunction toJsonText(value: unknown): string {\n return JSON.stringify(value, null, 2);\n}\n\nexport function makeSuccessResult<T>(envelope: SuccessEnvelope<T>): CallToolResult {\n return {\n content: [{ type: \"text\", text: toJsonText(envelope) }],\n structuredContent: envelope,\n };\n}\n\nexport function makeErrorResult(envelope: ErrorEnvelope): CallToolResult {\n return {\n content: [{ type: \"text\", text: toJsonText(envelope) }],\n structuredContent: envelope,\n isError: true,\n };\n}\n","import { spawn } from \"node:child_process\";\n\nimport {\n collabList as coreCollabList,\n collabListMembers as coreCollabListMembers,\n collabUpdateMemberRole as coreCollabUpdateMemberRole,\n drainPendingFinalizeQueue as coreDrainPendingFinalizeQueue,\n collabFinalizeTurn as coreCollabFinalizeTurn,\n collabApprove as coreCollabApprove,\n collabCheckout as coreCollabCheckout,\n collabListMergeRequests as coreCollabListMergeRequests,\n collabInit as coreCollabInit,\n collabReAnchor as coreCollabReAnchor,\n collabInvite as coreCollabInvite,\n collabReconcile as coreCollabReconcile,\n collabReject as coreCollabReject,\n collabRemix as coreCollabRemix,\n collabRequestMerge as coreCollabRequestMerge,\n collabStatus as coreCollabStatus,\n collabSync as coreCollabSync,\n collabSyncUpstream as coreCollabSyncUpstream,\n collabView as coreCollabView,\n type CollabStatus,\n type InvitationScopeType,\n type MergeRequestQueue,\n} from \"@remixhq/core/collab\";\nimport { findGitRoot } from \"@remixhq/core/repo\";\n\nimport { createCollabApiClient } from \"./apiClient.js\";\n\nfunction getRiskLevel(status: CollabStatus): \"low\" | \"medium\" | \"high\" {\n if (status.recommendedAction === \"reconcile\") return \"high\";\n if (status.recommendedAction === \"choose_family\" || status.recommendedAction === \"await_finalize\") return \"medium\";\n if (status.recommendedAction === \"pull\" || status.recommendedAction === \"re_anchor\" || status.remote.incomingOpenMergeRequestCount) {\n return \"medium\";\n }\n if (status.repo.branchMismatch || !status.repo.isGitRepo || !status.binding.isBound || !status.repo.worktree.isClean) return \"medium\";\n return \"low\";\n}\n\nfunction getRecommendedNextActions(status: CollabStatus): string[] {\n if (status.repo.branchMismatch) {\n return [\n `Switch to the bound branch (${status.binding.branchName ?? \"configured in the binding\"}) before using Remix mutation tools, or rerun with allowBranchMismatch=true if this deviation is intentional.`,\n ];\n }\n switch (status.recommendedAction) {\n case \"init\":\n return [\"Run remix_collab_init to bind the repository to Remix before using any Remix collaboration mutation flow.\"];\n case \"pull\":\n return [\"Run remix_collab_sync_preview, then remix_collab_sync_apply if the preview is acceptable. This pulls the server delta into the local working tree without rewriting local git history.\"];\n case \"re_anchor\":\n return [\"Run remix_collab_re_anchor_preview, then remix_collab_re_anchor_apply to re-anchor the lane after manual Git/GitHub history movement.\"];\n case \"reconcile\":\n return [\"Run remix_collab_reconcile_preview before attempting remix_collab_reconcile_apply. Reconcile now routes through the explicit Remix recovery/re-anchor flow for diverged state.\"];\n case \"await_finalize\":\n return [\n \"Run remix_collab_drain_finalize_queue before merge-related or recovery flows. finalize_turn is queued only until the local finalize queue is drained.\",\n ];\n case \"review_queue\":\n return [\"Run remix_collab_review_queue to inspect reviewable merge requests instead of using local git merge flows.\"];\n case \"choose_family\":\n return [\n \"This checkout is ambiguous across multiple canonical Remix families. Continue from a checkout already bound to the intended family, or run remix_collab_init with forceNew=true to create and bind a new canonical family.\",\n ];\n default:\n return [];\n }\n}\n\nfunction collectWarnings(value: unknown): string[] {\n if (!value || !Array.isArray(value)) return [];\n return value.filter((entry): entry is string => typeof entry === \"string\" && entry.trim().length > 0);\n}\n\nfunction collectResultWarnings<T extends { warnings?: unknown }>(value: T): string[] {\n return collectWarnings(value.warnings);\n}\n\nfunction truncateText(value: string, maxChars: number): { text: string; truncated: boolean; originalChars: number } {\n if (value.length <= maxChars) {\n return {\n text: value,\n truncated: false,\n originalChars: value.length,\n };\n }\n return {\n text: `${value.slice(0, maxChars)}\\n\\n[truncated ${value.length - maxChars} chars]`,\n truncated: true,\n originalChars: value.length,\n };\n}\n\nfunction spawnFinalizeQueueDrainer(): boolean {\n const entrypoint = process.argv[1];\n if (!entrypoint) return false;\n const child = spawn(process.execPath, [...process.execArgv, entrypoint, \"--drain-finalize-queue\"], {\n detached: true,\n stdio: \"ignore\",\n env: process.env,\n });\n child.unref();\n return true;\n}\n\nexport async function getStatus(params: { cwd: string; includeRemote: boolean }) {\n const api = params.includeRemote ? await createCollabApiClient() : null;\n const status = await coreCollabStatus({\n api,\n cwd: params.cwd,\n });\n return {\n data: {\n status,\n riskLevel: getRiskLevel(status),\n },\n warnings: status.warnings,\n recommendedNextActions: getRecommendedNextActions(status),\n logContext: {\n repoRoot: status.repo.repoRoot,\n appId: status.binding.currentAppId,\n },\n };\n}\n\nexport async function initCollab(params: { cwd: string; appName?: string; forceNew?: boolean }) {\n const api = await createCollabApiClient();\n const result = await coreCollabInit({\n api,\n cwd: params.cwd,\n appName: params.appName ?? null,\n forceNew: params.forceNew ?? false,\n });\n return {\n data: result,\n warnings: collectResultWarnings(result as { warnings?: unknown }),\n recommendedNextActions:\n result.baselineStatus === \"requires_re_anchor\"\n ? [\n \"Run remix_collab_re_anchor_preview, then remix_collab_re_anchor_apply to anchor this checkout before recording turns.\",\n ]\n : result.baselineStatus === \"requires_sync\"\n ? [\n \"Run remix_collab_sync_preview, then remix_collab_sync_apply to pull the server delta and create the first local baseline for this checkout.\",\n ]\n : [\"Run remix_collab_status to inspect sync, reconcile, and merge-request readiness before mutating bound-repo state.\"],\n logContext: {\n repoRoot: result.repoRoot,\n appId: result.appId,\n },\n };\n}\n\nexport async function listApps(params: {\n ownership?: \"mine\" | \"shared\" | \"all\";\n accessScope?: \"all_readable\" | \"explicit_member\";\n createdBy?: \"me\" | string;\n forked?: \"only\" | \"exclude\" | \"all\";\n limit?: number;\n offset?: number;\n}) {\n const api = await createCollabApiClient();\n const result = await coreCollabList({\n api,\n ownership: params.ownership,\n accessScope: params.accessScope,\n createdBy: params.createdBy,\n forked: params.forked,\n limit: params.limit,\n offset: params.offset,\n });\n return {\n data: result,\n warnings: [],\n recommendedNextActions:\n result.pagination.hasMore ? [`Pass offset=${result.pagination.offset + result.pagination.limit} to load the next page.`] : [],\n logContext: {},\n };\n}\n\nexport async function remixCollab(params: { cwd: string; appId: string; name?: string; outputDir?: string }) {\n const api = await createCollabApiClient();\n const result = await coreCollabRemix({\n api,\n cwd: params.cwd,\n appId: params.appId,\n name: params.name ?? null,\n outputDir: params.outputDir ?? null,\n });\n return {\n data: result,\n warnings: collectResultWarnings(result as { warnings?: unknown }),\n recommendedNextActions: [\"Run remix_collab_status inside the remix checkout before using Remix mutation tools there.\"],\n logContext: {\n repoRoot: result.repoRoot,\n appId: result.appId,\n },\n };\n}\n\nexport async function checkoutCollab(params: { cwd: string; appId: string; outputDir?: string }) {\n const api = await createCollabApiClient();\n const result = await coreCollabCheckout({\n api,\n cwd: params.cwd,\n appId: params.appId,\n outputDir: params.outputDir ?? null,\n });\n return {\n data: result,\n warnings: collectResultWarnings(result as { warnings?: unknown }),\n recommendedNextActions: [\"Run remix_collab_status inside the checked out repository before using Remix mutation tools there.\"],\n logContext: {\n repoRoot: result.repoRoot,\n appId: result.appId,\n },\n };\n}\n\nexport async function finalizeCollabTurn(params: {\n cwd: string;\n prompt: string;\n assistantResponse: string;\n sync?: boolean;\n allowBranchMismatch?: boolean;\n idempotencyKey?: string;\n agent: { type: string; name?: string; version?: string; provider?: string };\n}) {\n const api = await createCollabApiClient();\n const repoRoot = await findGitRoot(params.cwd);\n const result = await coreCollabFinalizeTurn({\n api,\n cwd: params.cwd,\n prompt: params.prompt,\n assistantResponse: params.assistantResponse,\n sync: params.sync,\n allowBranchMismatch: params.allowBranchMismatch ?? false,\n idempotencyKey: params.idempotencyKey ?? null,\n actor: params.agent,\n });\n if (result.queued) {\n if (!spawnFinalizeQueueDrainer()) {\n await coreDrainPendingFinalizeQueue({ api });\n }\n }\n return {\n data: result,\n warnings: result.warnings,\n recommendedNextActions: result.queued\n ? [\"Run remix_collab_drain_finalize_queue before merge-related flows if you need this queued turn recorded immediately.\"]\n : [],\n logContext: {\n repoRoot,\n appId: result.changeStep?.appId ?? result.collabTurn?.appId ?? null,\n },\n };\n}\n\nexport async function drainFinalizeQueue(params: { cwd: string }) {\n const api = await createCollabApiClient();\n const repoRoot = await findGitRoot(params.cwd);\n const results = await coreDrainPendingFinalizeQueue({ api });\n const warnings = results.flatMap((result) => collectResultWarnings(result as { warnings?: unknown }));\n return {\n data: {\n processed: results.length,\n results,\n },\n warnings,\n recommendedNextActions: [],\n logContext: {\n repoRoot,\n appId: null,\n },\n };\n}\n\nexport async function syncCollab(params: { cwd: string; dryRun: boolean; allowBranchMismatch?: boolean }) {\n const api = await createCollabApiClient();\n const result = await coreCollabSync({\n api,\n cwd: params.cwd,\n dryRun: params.dryRun,\n allowBranchMismatch: params.allowBranchMismatch ?? false,\n });\n return {\n data: result,\n warnings: collectResultWarnings(result as { warnings?: unknown }),\n recommendedNextActions: params.dryRun\n ? result.status === \"delta_ready\"\n ? [\"Run remix_collab_sync_apply with confirm=true to apply this server delta into the local working tree.\"]\n : result.status === \"base_unknown\"\n ? [\n \"Direct pull is unavailable because Remix cannot diff from the last acknowledged server head.\",\n \"Run remix_collab_reconcile_preview next to inspect recovery options before applying any recovery flow.\",\n ]\n : []\n : [],\n logContext: {\n repoRoot: result.repoRoot,\n },\n };\n}\n\nexport async function reAnchor(params: { cwd: string; dryRun: boolean; allowBranchMismatch?: boolean }) {\n const api = await createCollabApiClient();\n const result = await coreCollabReAnchor({\n api,\n cwd: params.cwd,\n dryRun: params.dryRun,\n allowBranchMismatch: params.allowBranchMismatch ?? false,\n });\n return {\n data: result,\n warnings: collectWarnings((result as { warnings?: unknown }).warnings),\n recommendedNextActions: params.dryRun\n ? [\"Run remix_collab_re_anchor_apply with confirm=true to re-anchor this lane after manual Git/GitHub history movement.\"]\n : [],\n logContext: {\n repoRoot: result.repoRoot,\n appId: result.currentAppId,\n },\n };\n}\n\nexport async function requestMerge(params: { cwd: string }) {\n const api = await createCollabApiClient();\n const result = await coreCollabRequestMerge({\n api,\n cwd: params.cwd,\n });\n return {\n data: result,\n warnings: [],\n recommendedNextActions: result.id\n ? [`Run remix_collab_view_merge_request with mrId=${String(result.id)} to inspect the request before deciding whether to approve or reject it.`]\n : [],\n logContext: {\n mrId: typeof result.id === \"string\" ? result.id : null,\n },\n };\n}\n\nexport async function reviewQueue(params: { status?: string; kind?: string; limit?: number; offset?: number }) {\n const api = await createCollabApiClient();\n const result = await coreCollabListMergeRequests({\n api,\n queue: \"reviewable\",\n status: params.status ?? \"open\",\n kind: params.kind ?? \"merge\",\n limit: params.limit,\n offset: params.offset,\n });\n return {\n data: {\n queue: result.queue,\n appId: result.appId,\n mergeRequests: result.mergeRequests,\n pagination: result.pagination,\n },\n warnings: [],\n recommendedNextActions:\n result.pagination.hasMore ? [`Pass offset=${result.pagination.offset + result.pagination.limit} to load the next page.`] : [],\n logContext: {},\n };\n}\n\nexport async function myMergeRequests(params: { status?: string; kind?: string; limit?: number; offset?: number }) {\n const api = await createCollabApiClient();\n const result = await coreCollabListMergeRequests({\n api,\n queue: \"created_by_me\",\n status: params.status ?? \"open\",\n kind: params.kind ?? \"merge\",\n limit: params.limit,\n offset: params.offset,\n });\n return {\n data: {\n queue: result.queue,\n appId: result.appId,\n mergeRequests: result.mergeRequests,\n pagination: result.pagination,\n },\n warnings: [],\n recommendedNextActions:\n result.pagination.hasMore ? [`Pass offset=${result.pagination.offset + result.pagination.limit} to load the next page.`] : [],\n logContext: {},\n };\n}\n\nexport async function listAppMergeRequests(params: {\n cwd?: string;\n appId?: string;\n queue: Extract<MergeRequestQueue, \"app_reviewable\" | \"app_outgoing\" | \"app_related_visible\">;\n status?: string;\n kind?: string;\n limit?: number;\n offset?: number;\n}) {\n const api = await createCollabApiClient();\n const result = await coreCollabListMergeRequests({\n api,\n cwd: params.cwd,\n appId: params.appId,\n queue: params.queue,\n status: params.status ?? \"open\",\n kind: params.kind ?? \"merge\",\n limit: params.limit,\n offset: params.offset,\n });\n return {\n data: {\n queue: result.queue,\n appId: result.appId,\n mergeRequests: result.mergeRequests,\n pagination: result.pagination,\n },\n warnings: [],\n recommendedNextActions:\n result.pagination.hasMore ? [`Pass offset=${result.pagination.offset + result.pagination.limit} to load the next page.`] : [],\n logContext: {\n appId: result.appId,\n },\n };\n}\n\nexport async function viewMergeRequest(params: { mrId: string; includeUnifiedDiff: boolean; diffMaxChars: number }) {\n const api = await createCollabApiClient();\n const review = await coreCollabView({\n api,\n mrId: params.mrId,\n });\n const truncatedDiff = params.includeUnifiedDiff ? truncateText(review.unifiedDiff, params.diffMaxChars) : null;\n return {\n data: {\n mergeRequest: review.mergeRequest,\n prompts: review.prompts,\n changeSteps: review.changeSteps,\n stats: review.stats,\n unifiedDiff: truncatedDiff?.text ?? null,\n diffTruncated: truncatedDiff?.truncated ?? false,\n originalUnifiedDiffChars: truncatedDiff?.originalChars ?? review.unifiedDiff.length,\n },\n warnings: truncatedDiff?.truncated ? [\"Unified diff output was truncated to respect the configured output limit.\"] : [],\n recommendedNextActions: [],\n logContext: {\n mrId: params.mrId,\n appId: review.mergeRequest.targetAppId,\n },\n };\n}\n\nexport async function approveMergeRequest(params: {\n mrId: string;\n cwd?: string;\n mode: \"remote-only\" | \"sync-target-repo\";\n allowBranchMismatch?: boolean;\n}) {\n const api = await createCollabApiClient();\n const result = await coreCollabApprove({\n api,\n mrId: params.mrId,\n cwd: params.cwd,\n mode: params.mode,\n allowBranchMismatch: params.allowBranchMismatch ?? false,\n });\n return {\n data: result,\n warnings: collectResultWarnings(result as { warnings?: unknown }),\n recommendedNextActions: [],\n logContext: {\n repoRoot: result.repoRoot ?? null,\n appId: result.targetAppId,\n mrId: result.mergeRequestId,\n },\n };\n}\n\nexport async function rejectMergeRequest(params: { mrId: string }) {\n const api = await createCollabApiClient();\n const result = await coreCollabReject({\n api,\n mrId: params.mrId,\n });\n return {\n data: result,\n warnings: [],\n recommendedNextActions: [],\n logContext: {\n mrId: params.mrId,\n },\n };\n}\n\nexport async function syncUpstream(params: { cwd: string }) {\n const api = await createCollabApiClient();\n const result = await coreCollabSyncUpstream({\n api,\n cwd: params.cwd,\n });\n return {\n data: result,\n warnings: collectResultWarnings(result as { warnings?: unknown }),\n recommendedNextActions: [],\n logContext: {\n repoRoot: result.repoRoot,\n appId: result.appId,\n mrId: \"mergeRequestId\" in result ? result.mergeRequestId ?? null : null,\n },\n };\n}\n\nexport async function reconcile(params: { cwd: string; dryRun: boolean; allowBranchMismatch?: boolean }) {\n const api = await createCollabApiClient();\n const result = await coreCollabReconcile({\n api,\n cwd: params.cwd,\n dryRun: params.dryRun,\n allowBranchMismatch: params.allowBranchMismatch ?? false,\n });\n return {\n data: result,\n warnings: collectWarnings((result as { warnings?: unknown }).warnings),\n recommendedNextActions: params.dryRun\n ? [\"Run remix_collab_reconcile_apply with confirm=true only if the preview is acceptable. This is the explicit Remix recovery flow for diverged state.\"]\n : [],\n risks: params.dryRun ? [\"Reconcile may upload local history to re-anchor the server lane before future recording continues.\"] : [],\n logContext: {\n repoRoot: (result as { repoRoot?: string | null }).repoRoot ?? null,\n },\n };\n}\n\nexport async function inviteCollaborator(params: {\n cwd: string;\n email: string;\n role?: string;\n scope?: InvitationScopeType;\n targetId?: string;\n ttlDays?: number;\n}) {\n const api = await createCollabApiClient();\n const result = await coreCollabInvite({\n api,\n cwd: params.cwd,\n email: params.email,\n role: params.role ?? null,\n scope: params.scope ?? \"project\",\n targetId: params.targetId ?? null,\n ttlDays: params.ttlDays,\n });\n return {\n data: result,\n warnings: [],\n recommendedNextActions: [],\n logContext: {},\n };\n}\n\nexport async function listMembers(params: {\n cwd: string;\n scope: InvitationScopeType;\n targetId?: string;\n limit?: number;\n offset?: number;\n}) {\n const api = await createCollabApiClient();\n const result = await coreCollabListMembers({\n api,\n cwd: params.cwd,\n scope: params.scope,\n targetId: params.targetId ?? null,\n limit: params.limit,\n offset: params.offset,\n });\n return {\n data: result,\n warnings: [],\n recommendedNextActions:\n result.pagination.hasMore ? [`Pass offset=${result.pagination.offset + result.pagination.limit} to load the next page.`] : [],\n logContext: {},\n };\n}\n\nexport async function updateMemberRole(params: {\n cwd: string;\n scope: InvitationScopeType;\n targetId?: string;\n userId: string;\n role: string;\n}) {\n const api = await createCollabApiClient();\n const result = await coreCollabUpdateMemberRole({\n api,\n cwd: params.cwd,\n scope: params.scope,\n targetId: params.targetId ?? null,\n userId: params.userId,\n role: params.role,\n });\n return {\n data: result,\n warnings: [],\n recommendedNextActions: [],\n logContext: {},\n };\n}\n","import { readCollabBinding, type CollabBinding } from \"@remixhq/core/binding\";\nimport { findGitRoot } from \"@remixhq/core/repo\";\nimport { ERROR_CODES, RemixMcpError } from \"../errors/errorCodes.js\";\n\nexport type ToolResult<T> = {\n\tdata: T;\n\twarnings?: string[];\n\trecommendedNextActions?: string[];\n\trisks?: string[];\n\tlogContext?: {\n\t\trepoRoot?: string | null;\n\t\tappId?: string | null;\n\t\tmrId?: string | null;\n\t};\n};\n\nexport type BindingContext = {\n\trepoRoot: string | null;\n\tbinding: CollabBinding | null;\n};\n\nexport function unwrapResponseObject<T>(resp: any, label: string): T {\n\tconst obj = resp?.responseObject;\n\tif (obj === undefined || obj === null) {\n\t\tthrow new Error(typeof resp?.message === \"string\" && resp.message.trim() ? resp.message : `Missing ${label} response`);\n\t}\n\treturn obj as T;\n}\n\nexport async function maybeFindGitRoot(cwd: string): Promise<string | null> {\n\ttry {\n\t\treturn await findGitRoot(cwd);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport async function loadBindingContext(cwd?: string): Promise<BindingContext> {\n\tif (!cwd) return { repoRoot: null, binding: null };\n\tconst repoRoot = await maybeFindGitRoot(cwd);\n\tif (!repoRoot) return { repoRoot: null, binding: null };\n\tconst binding = await readCollabBinding(repoRoot);\n\treturn {\n\t\trepoRoot,\n\t\tbinding,\n\t};\n}\n\nexport function makeNotBoundError(message = \"Repository is not bound to Remix.\", hint?: string): Error & { hint?: string } {\n\tconst error = new Error(message) as Error & { hint?: string };\n\terror.hint = hint ?? \"Run `remix_collab_init` in this repository, or pass the explicit id for a direct read.\";\n\treturn error;\n}\n\nfunction parseJsonObject(value: string | null): Record<string, unknown> | null {\n\tif (!value) return null;\n\ttry {\n\t\tconst parsed = JSON.parse(value);\n\t\treturn parsed && typeof parsed === \"object\" ? (parsed as Record<string, unknown>) : null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport function getBackendStatusCode(error: unknown): number | null {\n\tif (!error || typeof error !== \"object\") return null;\n\tconst hint =\n\t\t\"hint\" in error && typeof (error as { hint?: unknown }).hint === \"string\" ? ((error as { hint: string }).hint as string) : null;\n\tconst body = parseJsonObject(hint);\n\tif (typeof body?.statusCode === \"number\") return body.statusCode;\n\tif (typeof body?.statusCode === \"string\") {\n\t\tconst parsed = Number(body.statusCode);\n\t\treturn Number.isFinite(parsed) ? parsed : null;\n\t}\n\treturn null;\n}\n\nexport function isBackendForbidden(error: unknown): boolean {\n\treturn getBackendStatusCode(error) === 403;\n}\n\nexport function isBackendNotFound(error: unknown): boolean {\n\treturn getBackendStatusCode(error) === 404;\n}\n\nexport function createAccessDeniedError(message: string, hint?: string | null): RemixMcpError {\n\treturn new RemixMcpError({\n\t\tcode: ERROR_CODES.ACCESS_DENIED,\n\t\tmessage,\n\t\thint: hint ?? null,\n\t\tretryable: false,\n\t\tcategory: \"remote_state\",\n\t});\n}\n\nexport function createResourceNotFoundError(message: string, hint?: string | null): RemixMcpError {\n\treturn new RemixMcpError({\n\t\tcode: ERROR_CODES.RESOURCE_NOT_FOUND,\n\t\tmessage,\n\t\thint: hint ?? null,\n\t\tretryable: false,\n\t\tcategory: \"remote_state\",\n\t});\n}\n","import type { ApiClient, AppContext, InvitationRecord } from \"@remixhq/core\";\n\nimport { createApiClient } from \"./apiClient.js\";\nimport {\n\tcreateAccessDeniedError,\n\tisBackendForbidden,\n\tisBackendNotFound,\n\tloadBindingContext,\n\tmakeNotBoundError,\n\ttype ToolResult,\n\tunwrapResponseObject,\n} from \"./shared.js\";\n\ntype ScopeType = \"organization\" | \"project\" | \"app\";\ntype JsonRecord = Record<string, any>;\nconst MEMBERSHIP_PAGE_SIZE = 100;\ntype EffectiveAppRole = \"owner\" | \"maintainer\" | \"editor\" | \"viewer\" | null;\ntype PageInfo = { limit: number; offset: number; hasMore: boolean };\ntype PagedItems<T> = { items: T[]; pageInfo: PageInfo };\n\nfunction normalizePagination(params?: { limit?: number; offset?: number }) {\n\tconst rawLimit = typeof params?.limit === \"number\" ? Math.trunc(params.limit) : 25;\n\tconst rawOffset = typeof params?.offset === \"number\" ? Math.trunc(params.offset) : 0;\n\treturn {\n\t\tlimit: Math.max(1, Math.min(50, rawLimit)),\n\t\toffset: Math.max(0, rawOffset),\n\t};\n}\n\nasync function resolveScopeTarget(\n\tapi: ApiClient,\n\tparams: { scope: ScopeType; targetId?: string | null; cwd?: string },\n): Promise<{ scopeType: ScopeType; targetId: string; repoRoot: string | null }> {\n\tconst explicitTargetId = params.targetId?.trim();\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tif (explicitTargetId) {\n\t\treturn {\n\t\t\tscopeType: params.scope,\n\t\t\ttargetId: explicitTargetId,\n\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t};\n\t}\n\tif (!bindingContext.binding) {\n\t\tthrow makeNotBoundError(\"Scope target was not provided and the current repository is not bound to Remix.\");\n\t}\n\tif (params.scope === \"app\") {\n\t\treturn {\n\t\t\tscopeType: \"app\",\n\t\t\ttargetId: bindingContext.binding.currentAppId,\n\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t};\n\t}\n\tconst appContext = unwrapResponseObject<AppContext>(\n\t\tawait api.getAppContext(bindingContext.binding.currentAppId),\n\t\t\"bound app context\",\n\t);\n\tif (params.scope === \"project\") {\n\t\tif (!appContext.readableScopes.project) {\n\t\t\tthrow createAccessDeniedError(\n\t\t\t\t\"The bound app's project is not readable to the current user.\",\n\t\t\t\t\"Use `scope=app` for app-level diagnostics, or pass an explicit readable project id.\",\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\tscopeType: \"project\",\n\t\t\ttargetId: appContext.projectId,\n\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t};\n\t}\n\tif (!appContext.readableScopes.organization) {\n\t\tthrow createAccessDeniedError(\n\t\t\t\"The bound app's organization is not readable to the current user.\",\n\t\t\t\"Use `scope=app` or `scope=project` for narrower diagnostics, or pass an explicit readable organization id.\",\n\t\t);\n\t}\n\treturn {\n\t\tscopeType: \"organization\",\n\t\ttargetId: appContext.organizationId,\n\t\trepoRoot: bindingContext.repoRoot,\n\t};\n}\n\nasync function getScopeEntity(api: ApiClient, scopeType: ScopeType, targetId: string) {\n\tif (scopeType === \"organization\") {\n\t\treturn {\n\t\t\torganization: unwrapResponseObject<JsonRecord>(await api.getOrganization(targetId), \"organization\"),\n\t\t\tproject: null,\n\t\t\tapp: null,\n\t\t};\n\t}\n\tif (scopeType === \"project\") {\n\t\tconst project = unwrapResponseObject<JsonRecord>(await api.getProject(targetId), \"project\");\n\t\tconst organizationId = typeof project.organizationId === \"string\" ? project.organizationId : null;\n\t\treturn {\n\t\t\torganization:\n\t\t\t\torganizationId == null ? null : unwrapResponseObject<JsonRecord>(await api.getOrganization(organizationId), \"organization\"),\n\t\t\tproject,\n\t\t\tapp: null,\n\t\t};\n\t}\n\tconst app = unwrapResponseObject<JsonRecord>(await api.getApp(targetId), \"app\");\n\tconst projectId = typeof app.projectId === \"string\" ? app.projectId : null;\n\tconst project = projectId == null ? null : unwrapResponseObject<JsonRecord>(await api.getProject(projectId), \"project\");\n\tconst organizationId = typeof project?.organizationId === \"string\" ? project.organizationId : null;\n\treturn {\n\t\torganization:\n\t\t\torganizationId == null ? null : unwrapResponseObject<JsonRecord>(await api.getOrganization(organizationId), \"organization\"),\n\t\tproject,\n\t\tapp,\n\t};\n}\n\nfunction mapProjectRoleToAppRole(role: string | null): EffectiveAppRole {\n\tswitch (role) {\n\t\tcase \"owner\":\n\t\tcase \"maintainer\":\n\t\t\treturn \"maintainer\";\n\t\tcase \"editor\":\n\t\t\treturn \"editor\";\n\t\tcase \"viewer\":\n\t\t\treturn \"viewer\";\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\nfunction strongestRole(...roles: Array<EffectiveAppRole>): EffectiveAppRole {\n\tif (roles.includes(\"owner\")) return \"owner\";\n\tif (roles.includes(\"maintainer\")) return \"maintainer\";\n\tif (roles.includes(\"editor\")) return \"editor\";\n\tif (roles.includes(\"viewer\")) return \"viewer\";\n\treturn null;\n}\n\nfunction resolveAppAccessSource(params: {\n\tdirectAppRole: EffectiveAppRole;\n\tinheritedProjectRole: EffectiveAppRole;\n}): \"none\" | \"direct_app_membership\" | \"project_membership\" | \"both\" {\n\tif (params.directAppRole && params.inheritedProjectRole) return \"both\";\n\tif (params.directAppRole) return \"direct_app_membership\";\n\tif (params.inheritedProjectRole) return \"project_membership\";\n\treturn \"none\";\n}\n\nfunction buildEffectiveAppAccess(params: { directAppRole: string | null; projectRole: string | null }) {\n\tconst directAppRole = (params.directAppRole as EffectiveAppRole) ?? null;\n\tconst inheritedProjectRole = mapProjectRoleToAppRole(params.projectRole);\n\tconst effectiveRole = strongestRole(directAppRole, inheritedProjectRole);\n\treturn {\n\t\teffectiveRole,\n\t\tdirectAppRole,\n\t\tprojectRole: params.projectRole,\n\t\tinheritedProjectRole,\n\t\taccessSource: resolveAppAccessSource({ directAppRole, inheritedProjectRole }),\n\t\tcanReadWorkflow: effectiveRole !== null,\n\t\tcanEdit: effectiveRole === \"owner\" || effectiveRole === \"maintainer\" || effectiveRole === \"editor\",\n\t\tcanManage: effectiveRole === \"owner\" || effectiveRole === \"maintainer\",\n\t\tisOwner: directAppRole === \"owner\",\n\t};\n}\n\nasync function listMembersForScope(api: ApiClient, scopeType: ScopeType, targetId: string, params?: { limit?: number; offset?: number }): Promise<JsonRecord[]> {\n\tif (scopeType === \"organization\") {\n\t\treturn unwrapResponseObject<JsonRecord[]>(await api.listOrganizationMembers(targetId, params), \"organization members\");\n\t}\n\tif (scopeType === \"project\") {\n\t\treturn unwrapResponseObject<JsonRecord[]>(await api.listProjectMembers(targetId, params), \"project members\");\n\t}\n\treturn unwrapResponseObject<JsonRecord[]>(await api.listAppMembers(targetId, params), \"app members\");\n}\n\nasync function loadFirstPageSample<T>(fetchPage: (limit: number, offset: number) => Promise<T[]>): Promise<PagedItems<T>> {\n\tconst items = await fetchPage(MEMBERSHIP_PAGE_SIZE, 0);\n\tconst hasMore = items.length < MEMBERSHIP_PAGE_SIZE ? false : (await fetchPage(1, MEMBERSHIP_PAGE_SIZE)).length > 0;\n\treturn {\n\t\titems,\n\t\tpageInfo: {\n\t\t\tlimit: MEMBERSHIP_PAGE_SIZE,\n\t\t\toffset: 0,\n\t\t\thasMore,\n\t\t},\n\t};\n}\n\nfunction emptyFirstPageSample<T>(): PagedItems<T> {\n\treturn {\n\t\titems: [],\n\t\tpageInfo: {\n\t\t\tlimit: MEMBERSHIP_PAGE_SIZE,\n\t\t\toffset: 0,\n\t\t\thasMore: false,\n\t\t},\n\t};\n}\n\nasync function listInvitesForScope(\n\tapi: ApiClient,\n\tscopeType: ScopeType,\n\ttargetId: string,\n\tparams?: { limit?: number; offset?: number },\n): Promise<InvitationRecord[]> {\n\tif (scopeType === \"organization\") {\n\t\treturn unwrapResponseObject<InvitationRecord[]>(\n\t\t\tawait api.listOrganizationInvites(targetId, params),\n\t\t\t\"organization invites\",\n\t\t);\n\t}\n\tif (scopeType === \"project\") {\n\t\treturn unwrapResponseObject<InvitationRecord[]>(\n\t\t\tawait api.listProjectInvites(targetId, params),\n\t\t\t\"project invites\",\n\t\t);\n\t}\n\treturn unwrapResponseObject<InvitationRecord[]>(await api.listAppInvites(targetId, params), \"app invites\");\n}\n\nfunction getSelfMember(meId: string | null, members: JsonRecord[]) {\n\treturn meId == null ? null : members.find((member) => member.userId === meId || member.user_id === meId) ?? null;\n}\n\nasync function findPendingInviteForEmailForScope(\n\tapi: ApiClient,\n\tscopeType: ScopeType,\n\ttargetId: string,\n\temail: string | null,\n): Promise<InvitationRecord | null> {\n\tif (email == null) return null;\n\tlet offset = 0;\n\tfor (;;) {\n\t\tconst invites = await listInvitesForScope(api, scopeType, targetId, {\n\t\t\tlimit: MEMBERSHIP_PAGE_SIZE,\n\t\t\toffset,\n\t\t});\n\t\tconst match =\n\t\t\tinvites.find((invite) => invite.email.toLowerCase() === email && invite.state === \"pending\") ?? null;\n\t\tif (match) return match;\n\t\tif (invites.length < MEMBERSHIP_PAGE_SIZE) return null;\n\t\toffset += MEMBERSHIP_PAGE_SIZE;\n\t}\n}\n\nasync function findSelfMemberForScope(api: ApiClient, scopeType: ScopeType, targetId: string, meId: string | null): Promise<JsonRecord | null> {\n\tif (meId == null) return null;\n\tlet offset = 0;\n\tfor (;;) {\n\t\tconst members =\n\t\t\tscopeType === \"organization\"\n\t\t\t\t? unwrapResponseObject<JsonRecord[]>(\n\t\t\t\t\t\tawait api.listOrganizationMembers(targetId, { limit: MEMBERSHIP_PAGE_SIZE, offset }),\n\t\t\t\t\t\t\"organization members\",\n\t\t\t\t\t)\n\t\t\t\t: scopeType === \"project\"\n\t\t\t\t\t? unwrapResponseObject<JsonRecord[]>(\n\t\t\t\t\t\t\tawait api.listProjectMembers(targetId, { limit: MEMBERSHIP_PAGE_SIZE, offset }),\n\t\t\t\t\t\t\t\"project members\",\n\t\t\t\t\t\t)\n\t\t\t\t\t: unwrapResponseObject<JsonRecord[]>(\n\t\t\t\t\t\t\tawait api.listAppMembers(targetId, { limit: MEMBERSHIP_PAGE_SIZE, offset }),\n\t\t\t\t\t\t\t\"app members\",\n\t\t\t\t\t\t);\n\t\tconst match = getSelfMember(meId, members);\n\t\tif (match) return match;\n\t\tif (members.length < MEMBERSHIP_PAGE_SIZE) return null;\n\t\toffset += MEMBERSHIP_PAGE_SIZE;\n\t}\n}\n\nexport async function listInvites(params: {\n\tscope?: ScopeType | null;\n\ttargetId?: string | null;\n\tlimit?: number;\n\toffset?: number;\n\tcwd?: string;\n}): Promise<\n\tToolResult<{\n\t\tscopeType: ScopeType;\n\t\ttargetId: string;\n\t\tinvites: InvitationRecord[];\n\t\tpagination: { limit: number; offset: number; hasMore: boolean };\n\t}>\n> {\n\tconst api = await createApiClient();\n\tconst target = await resolveScopeTarget(api, {\n\t\tscope: params.scope ?? \"project\",\n\t\ttargetId: params.targetId,\n\t\tcwd: params.cwd,\n\t});\n\tconst pagination = normalizePagination(params);\n\tconst invites = await listInvitesForScope(api, target.scopeType, target.targetId, {\n\t\tlimit: pagination.limit + 1,\n\t\toffset: pagination.offset,\n\t});\n\treturn {\n\t\tdata: {\n\t\t\tscopeType: target.scopeType,\n\t\t\ttargetId: target.targetId,\n\t\t\tinvites: invites.slice(0, pagination.limit),\n\t\t\tpagination: {\n\t\t\t\t...pagination,\n\t\t\t\thasMore: invites.length > pagination.limit,\n\t\t\t},\n\t\t},\n\t\twarnings: [],\n\t\trecommendedNextActions:\n\t\t\tinvites.length > pagination.limit\n\t\t\t\t? [`Pass offset=${pagination.offset + pagination.limit} to load the next page.`]\n\t\t\t\t: invites.length > 0\n\t\t\t\t\t? [\"Use `remix_collab_resend_invite` or `remix_collab_revoke_invite` for lifecycle actions on a selected invite id.\"]\n\t\t\t\t: [\"Use `remix_collab_invite` if you need to create a new invitation for this scope.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: target.repoRoot,\n\t\t},\n\t};\n}\n\nexport async function resendInvite(params: {\n\tscope?: ScopeType | null;\n\ttargetId?: string | null;\n\tinviteId: string;\n\tttlDays?: number;\n\tcwd?: string;\n}): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveScopeTarget(api, {\n\t\tscope: params.scope ?? \"project\",\n\t\ttargetId: params.targetId,\n\t\tcwd: params.cwd,\n\t});\n\tconst response =\n\t\ttarget.scopeType === \"organization\"\n\t\t\t? await api.resendOrganizationInvite(target.targetId, params.inviteId, { ttlDays: params.ttlDays })\n\t\t\t: target.scopeType === \"project\"\n\t\t\t\t? await api.resendProjectInvite(target.targetId, params.inviteId, { ttlDays: params.ttlDays })\n\t\t\t\t: await api.resendAppInvite(target.targetId, params.inviteId, { ttlDays: params.ttlDays });\n\treturn {\n\t\tdata: unwrapResponseObject<JsonRecord>(response, \"resent invite\"),\n\t\twarnings: [],\n\t\trecommendedNextActions: [\"Use `remix_collab_list_invites` to confirm the refreshed expiry and delivery state.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: target.repoRoot,\n\t\t},\n\t};\n}\n\nexport async function revokeInvite(params: {\n\tscope?: ScopeType | null;\n\ttargetId?: string | null;\n\tinviteId: string;\n\tcwd?: string;\n}): Promise<ToolResult<{ scopeType: ScopeType; targetId: string; inviteId: string; revoked: boolean }>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveScopeTarget(api, {\n\t\tscope: params.scope ?? \"project\",\n\t\ttargetId: params.targetId,\n\t\tcwd: params.cwd,\n\t});\n\tif (target.scopeType === \"organization\") {\n\t\tawait api.revokeOrganizationInvite(target.targetId, params.inviteId);\n\t} else if (target.scopeType === \"project\") {\n\t\tawait api.revokeProjectInvite(target.targetId, params.inviteId);\n\t} else {\n\t\tawait api.revokeAppInvite(target.targetId, params.inviteId);\n\t}\n\treturn {\n\t\tdata: {\n\t\t\tscopeType: target.scopeType,\n\t\t\ttargetId: target.targetId,\n\t\t\tinviteId: params.inviteId,\n\t\t\trevoked: true,\n\t\t},\n\t\twarnings: [],\n\t\trecommendedNextActions: [\"Use `remix_collab_list_invites` to confirm the invite state is now `revoked`.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: target.repoRoot,\n\t\t},\n\t};\n}\n\nexport async function acceptInvitation(params: { token: string }): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst result = unwrapResponseObject<JsonRecord>(await api.acceptInvitation({ token: params.token }), \"accepted invitation\");\n\treturn {\n\t\tdata: result,\n\t\twarnings: [],\n\t\trecommendedNextActions: result.redirectPath\n\t\t\t? [`The invitation is accepted. Use the returned redirect metadata to continue with the newly granted Remix scope.`]\n\t\t\t: [],\n\t\tlogContext: {},\n\t};\n}\n\nexport async function accessDebug(params: {\n\tscope?: ScopeType | null;\n\ttargetId?: string | null;\n\tcwd?: string;\n}): Promise<\n\tToolResult<{\n\t\tviewer: JsonRecord;\n\t\tscope: { scopeType: ScopeType; targetId: string };\n\t\tentities: { organization: JsonRecord | null; project: JsonRecord | null; app: JsonRecord | null };\n\t\tbinding: { repoRoot: string | null; binding: JsonRecord | null };\n\t\taccess: {\n\t\t\tappContext: JsonRecord | null;\n\t\t\tviewerMember: JsonRecord | null;\n\t\t\tviewerProjectMember: JsonRecord | null;\n\t\t\tinviteForViewerEmail: InvitationRecord | null;\n\t\t\teffectiveAppAccess: ReturnType<typeof buildEffectiveAppAccess> | null;\n\t\t};\n\t\tmembers: JsonRecord[];\n\t\tmembersPageInfo: PageInfo;\n\t\tinvites: InvitationRecord[];\n\t\tinvitesPageInfo: PageInfo;\n\t}>\n> {\n\tconst api = await createApiClient();\n\tconst target = await resolveScopeTarget(api, {\n\t\tscope: params.scope ?? \"project\",\n\t\ttargetId: params.targetId,\n\t\tcwd: params.cwd,\n\t});\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tconst viewer = unwrapResponseObject<JsonRecord>(await api.getMe(), \"current user\");\n\tconst viewerId = typeof viewer.id === \"string\" ? viewer.id : null;\n\tconst viewerEmail = typeof viewer.email === \"string\" ? viewer.email.toLowerCase() : null;\n\tconst warnings = [...(bindingContext.binding ? [] : [\"No local Remix binding was detected for the provided cwd.\"])];\n\n\tlet entities: { organization: JsonRecord | null; project: JsonRecord | null; app: JsonRecord | null };\n\tlet appContext: AppContext | null = null;\n\tlet membersPage: PagedItems<JsonRecord> = emptyFirstPageSample();\n\tlet invitesPage: PagedItems<InvitationRecord> = emptyFirstPageSample();\n\tlet viewerMember: JsonRecord | null = null;\n\tlet viewerProjectMember: JsonRecord | null = null;\n\tlet inviteForViewerEmail: InvitationRecord | null = null;\n\tlet effectiveAppAccess: (ReturnType<typeof buildEffectiveAppAccess> & JsonRecord) | null = null;\n\n\tif (target.scopeType !== \"app\") {\n\t\t[entities, membersPage, invitesPage] = await Promise.all([\n\t\t\tgetScopeEntity(api, target.scopeType, target.targetId),\n\t\t\tloadFirstPageSample((limit, offset) => listMembersForScope(api, target.scopeType, target.targetId, { limit, offset })),\n\t\t\tloadFirstPageSample((limit, offset) => listInvitesForScope(api, target.scopeType, target.targetId, { limit, offset })),\n\t\t]);\n\t\tviewerMember = await findSelfMemberForScope(api, target.scopeType, target.targetId, viewerId);\n\t\tinviteForViewerEmail = await findPendingInviteForEmailForScope(api, target.scopeType, target.targetId, viewerEmail);\n\t} else {\n\t\tconst [app, loadedAppContext] = await Promise.all([\n\t\t\tunwrapResponseObject<JsonRecord>(await api.getApp(target.targetId), \"app\"),\n\t\t\tunwrapResponseObject<AppContext>(await api.getAppContext(target.targetId), \"app context\"),\n\t\t]);\n\t\tappContext = loadedAppContext;\n\t\tentities = {\n\t\t\torganization: null,\n\t\t\tproject: null,\n\t\t\tapp,\n\t\t};\n\n\t\tif (appContext.readableScopes.project) {\n\t\t\ttry {\n\t\t\t\tentities.project = unwrapResponseObject<JsonRecord>(await api.getProject(appContext.projectId), \"project\");\n\t\t\t} catch (error) {\n\t\t\t\tif (!isBackendForbidden(error) && !isBackendNotFound(error)) throw error;\n\t\t\t\twarnings.push(\"The app is readable, but its project/workspace metadata is not currently readable to the current user.\");\n\t\t\t}\n\t\t} else {\n\t\t\twarnings.push(\"The app is readable, but its project/workspace is not readable to the current user.\");\n\t\t}\n\n\t\tif (appContext.readableScopes.organization) {\n\t\t\ttry {\n\t\t\t\tentities.organization = unwrapResponseObject<JsonRecord>(await api.getOrganization(appContext.organizationId), \"organization\");\n\t\t\t} catch (error) {\n\t\t\t\tif (!isBackendForbidden(error) && !isBackendNotFound(error)) throw error;\n\t\t\t\twarnings.push(\"The app is readable, but its organization metadata is not currently readable to the current user.\");\n\t\t\t}\n\t\t} else {\n\t\t\twarnings.push(\"The app's organization is not readable to the current user.\");\n\t\t}\n\n\t\teffectiveAppAccess = {\n\t\t\t...buildEffectiveAppAccess({\n\t\t\t\tdirectAppRole: appContext.roles.appRole,\n\t\t\t\tprojectRole: appContext.roles.projectRole,\n\t\t\t}),\n\t\t\taccessPath: appContext.accessPath,\n\t\t\treadableScopes: appContext.readableScopes,\n\t\t\tvisibility: appContext.visibility,\n\t\t\torganizationRole: appContext.roles.organizationRole ?? null,\n\t\t};\n\n\t\tif (appContext.capabilities.canReadWorkflow) {\n\t\t\tmembersPage = await loadFirstPageSample((limit, offset) => listMembersForScope(api, \"app\", target.targetId, { limit, offset }));\n\t\t\tviewerMember = await findSelfMemberForScope(api, \"app\", target.targetId, viewerId);\n\t\t\tif (appContext.readableScopes.project) {\n\t\t\t\tviewerProjectMember = await findSelfMemberForScope(api, \"project\", appContext.projectId, viewerId);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tinvitesPage = await loadFirstPageSample((limit, offset) => listInvitesForScope(api, \"app\", target.targetId, { limit, offset }));\n\t\t\t\tinviteForViewerEmail = await findPendingInviteForEmailForScope(api, \"app\", target.targetId, viewerEmail);\n\t\t\t} catch (error) {\n\t\t\t\tif (!isBackendForbidden(error) && !isBackendNotFound(error)) throw error;\n\t\t\t\twarnings.push(\"App invite data is not readable to the current user, so invite diagnostics are partial.\");\n\t\t\t}\n\t\t} else {\n\t\t\twarnings.push(\"The current viewer can read the app, but cannot read workflow-scoped app membership data.\");\n\t\t}\n\t}\n\n\tif (membersPage.pageInfo.hasMore) {\n\t\twarnings.push(\"The `members` array is a first-page sample only; use the scope member list tool to inspect the remaining entries.\");\n\t}\n\tif (invitesPage.pageInfo.hasMore) {\n\t\twarnings.push(\"The `invites` array is a first-page sample only; use the invite list tool with pagination to inspect the remaining entries.\");\n\t}\n\n\treturn {\n\t\tdata: {\n\t\t\tviewer,\n\t\t\tscope: {\n\t\t\t\tscopeType: target.scopeType,\n\t\t\t\ttargetId: target.targetId,\n\t\t\t},\n\t\t\tentities,\n\t\t\tbinding: {\n\t\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t\t\tbinding: bindingContext.binding,\n\t\t\t},\n\t\t\taccess: {\n\t\t\t\tappContext,\n\t\t\t\tviewerMember,\n\t\t\t\tviewerProjectMember,\n\t\t\t\tinviteForViewerEmail,\n\t\t\t\teffectiveAppAccess: effectiveAppAccess ?? null,\n\t\t\t},\n\t\t\tmembers: membersPage.items,\n\t\t\tmembersPageInfo: membersPage.pageInfo,\n\t\t\tinvites: invitesPage.items,\n\t\t\tinvitesPageInfo: invitesPage.pageInfo,\n\t\t},\n\t\twarnings,\n\t\trecommendedNextActions: inviteForViewerEmail\n\t\t\t? [\"A pending invite exists for the current viewer email. Use `remix_collab_accept_invitation` if the viewer should accept it.\"]\n\t\t\t: target.scopeType === \"app\"\n\t\t\t\t? [\"Use `access.appContext` and `access.effectiveAppAccess` together to explain app-level visibility versus workspace-level visibility.\"]\n\t\t\t\t: [\"Use the member and invite lists above to explain missing access, role mismatches, or stale invite state.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: target.repoRoot,\n\t\t\tappId: entities.app?.id ?? bindingContext.binding?.currentAppId ?? null,\n\t\t},\n\t};\n}\n","import { z } from \"zod\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { ToolAnnotations } from \"@modelcontextprotocol/sdk/types.js\";\n\nimport type { ServerContext } from \"../../bootstrap/context.js\";\nimport {\n\tgetAppSuccessSchema,\n\tgetOrganizationSuccessSchema,\n\tgetProjectSuccessSchema,\n\tlistAppsSuccessSchema,\n\tlistOrganizationsSuccessSchema,\n\tlistProjectsSuccessSchema,\n\twhoamiSuccessSchema,\n\tdirectoryAppInputSchema,\n\tdirectoryListAppsInputSchema,\n\tdirectoryListProjectsInputSchema,\n\tdirectoryOrganizationInputSchema,\n\tdirectoryProjectInputSchema,\n\twhoamiInputSchema,\n} from \"../../contracts/identity.js\";\nimport {\n\tmakeErrorResult,\n\tmakeErrorSchema,\n\tmakeSuccessResult,\n\ttype ErrorEnvelope,\n\ttype SuccessEnvelope,\n\tSCHEMA_VERSION,\n} from \"../../contracts/common.js\";\nimport type { NormalizedToolError } from \"../../errors/errorCodes.js\";\nimport { normalizeToolError } from \"../../errors/normalizeError.js\";\nimport {\n\tgetApp,\n\tgetOrganization,\n\tgetProject,\n\tlistApps,\n\tlistOrganizations,\n\tlistProjects,\n\twhoAmI,\n} from \"../../domain/directoryAdapter.js\";\nimport { assertToolAccess, resolvePolicyCwd, type ToolAccess } from \"../../policy/policy.js\";\n\ntype ToolExecutionResult<T> = {\n\tdata: T;\n\twarnings?: string[];\n\trisks?: string[];\n\trecommendedNextActions?: string[];\n\tlogContext?: {\n\t\trepoRoot?: string | null;\n\t\tappId?: string | null;\n\t\tmrId?: string | null;\n\t};\n};\n\nfunction getAnnotations(access: ToolAccess): ToolAnnotations {\n\treturn {\n\t\treadOnlyHint: access === \"read\",\n\t\tdestructiveHint: false,\n\t\tidempotentHint: true,\n\t\topenWorldHint: false,\n\t};\n}\n\nfunction buildSuccessEnvelope<T>(tool: string, requestId: string | undefined, result: ToolExecutionResult<T>): SuccessEnvelope<T> {\n\treturn {\n\t\tschemaVersion: SCHEMA_VERSION,\n\t\tok: true,\n\t\ttool,\n\t\trequestId: requestId ?? null,\n\t\tdata: result.data,\n\t\twarnings: result.warnings ?? [],\n\t\trisks: result.risks ?? [],\n\t\trecommendedNextActions: result.recommendedNextActions ?? [],\n\t};\n}\n\nfunction deriveErrorRisks(normalized: NormalizedToolError): string[] {\n\tif (normalized.code === \"DESTRUCTIVE_OPERATION_BLOCKED\") {\n\t\treturn [\"A policy guard blocked a disallowed operation.\"];\n\t}\n\treturn [];\n}\n\nfunction buildErrorEnvelope(tool: string, requestId: string | undefined, error: unknown): ErrorEnvelope {\n\tconst normalized = normalizeToolError(error);\n\treturn {\n\t\tschemaVersion: SCHEMA_VERSION,\n\t\tok: false,\n\t\ttool,\n\t\trequestId: requestId ?? null,\n\t\terror: normalized,\n\t\twarnings: [],\n\t\trisks: deriveErrorRisks(normalized),\n\t\trecommendedNextActions: normalized.code === \"AUTH_REQUIRED\" ? [\"Run `remix login` or set COMERGE_ACCESS_TOKEN, then retry.\"] : [],\n\t};\n}\n\nfunction registerTool<T>(\n\tserver: McpServer,\n\tcontext: ServerContext,\n\tparams: {\n\t\tname: string;\n\t\tdescription: string;\n\t\taccess: ToolAccess;\n\t\tinputSchema: Record<string, z.ZodTypeAny>;\n\t\toutputSchema: z.ZodTypeAny;\n\t\trun: (args: Record<string, unknown>) => Promise<ToolExecutionResult<T>>;\n\t},\n) {\n\tconst errorSchema = makeErrorSchema();\n\tserver.registerTool(\n\t\tparams.name,\n\t\t{\n\t\t\ttitle: params.name,\n\t\t\tdescription: params.description,\n\t\t\tinputSchema: params.inputSchema,\n\t\t\toutputSchema: params.outputSchema,\n\t\t\tannotations: getAnnotations(params.access),\n\t\t},\n\t\tasync (rawArgs: Record<string, unknown>) => {\n\t\t\tconst requestId = typeof rawArgs.requestId === \"string\" ? rawArgs.requestId : undefined;\n\t\t\tconst startedAt = Date.now();\n\t\t\ttry {\n\t\t\t\tassertToolAccess(context.policy, params.access);\n\t\t\t\tconst result = await params.run(rawArgs);\n\t\t\t\tconst envelope = buildSuccessEnvelope(params.name, requestId, result);\n\t\t\t\tparams.outputSchema.parse(envelope);\n\t\t\t\tcontext.logger.log({\n\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\tmessage: \"tool_completed\",\n\t\t\t\t\ttool: params.name,\n\t\t\t\t\trequestId: envelope.requestId,\n\t\t\t\t\tdurationMs: Date.now() - startedAt,\n\t\t\t\t\tresult: \"success\",\n\t\t\t\t\trepoRoot: result.logContext?.repoRoot ?? null,\n\t\t\t\t\tappId: result.logContext?.appId ?? null,\n\t\t\t\t\tmrId: result.logContext?.mrId ?? null,\n\t\t\t\t});\n\t\t\t\treturn makeSuccessResult(envelope);\n\t\t\t} catch (error) {\n\t\t\t\tconst envelope = buildErrorEnvelope(params.name, requestId, error);\n\t\t\t\terrorSchema.parse(envelope);\n\t\t\t\tcontext.logger.log({\n\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\tmessage: \"tool_failed\",\n\t\t\t\t\ttool: params.name,\n\t\t\t\t\trequestId: envelope.requestId,\n\t\t\t\t\tdurationMs: Date.now() - startedAt,\n\t\t\t\t\tresult: \"error\",\n\t\t\t\t\terrorCode: envelope.error.code,\n\t\t\t\t});\n\t\t\t\treturn makeErrorResult(envelope);\n\t\t\t}\n\t\t},\n\t);\n}\n\nexport function registerIdentityTools(server: McpServer, context: ServerContext): void {\n\tregisterTool(server, context, {\n\t\tname: \"remix_identity_whoami\",\n\t\tdescription: \"Show the authenticated Remix user and, when cwd is provided, the current local binding and any immediately derivable roles for that bound workspace.\",\n\t\taccess: \"read\",\n\t\tinputSchema: whoamiInputSchema,\n\t\toutputSchema: whoamiSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(whoamiInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn whoAmI({ cwd });\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_directory_list_organizations\",\n\t\tdescription: \"List organizations visible to the authenticated Remix user.\",\n\t\taccess: \"read\",\n\t\tinputSchema: whoamiInputSchema,\n\t\toutputSchema: listOrganizationsSuccessSchema,\n\t\trun: async () => listOrganizations(),\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_directory_get_organization\",\n\t\tdescription: \"Fetch one organization by id, or infer the bound repository's organization from cwd when possible.\",\n\t\taccess: \"read\",\n\t\tinputSchema: directoryOrganizationInputSchema,\n\t\toutputSchema: getOrganizationSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(directoryOrganizationInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn getOrganization({\n\t\t\t\torganizationId: input.organizationId,\n\t\t\t\tcwd,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_directory_list_projects\",\n\t\tdescription: \"List projects visible to the authenticated user, optionally narrowed to one organization or client app.\",\n\t\taccess: \"read\",\n\t\tinputSchema: directoryListProjectsInputSchema,\n\t\toutputSchema: listProjectsSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(directoryListProjectsInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn listProjects({\n\t\t\t\torganizationId: input.organizationId,\n\t\t\t\tclientAppId: input.clientAppId,\n\t\t\t\tcwd,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_directory_get_project\",\n\t\tdescription: \"Fetch one project by id, or infer the bound repository's project from cwd when possible.\",\n\t\taccess: \"read\",\n\t\tinputSchema: directoryProjectInputSchema,\n\t\toutputSchema: getProjectSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(directoryProjectInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn getProject({\n\t\t\t\tprojectId: input.projectId,\n\t\t\t\tcwd,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_directory_list_apps\",\n\t\tdescription:\n\t\t\t\"List apps visible to the authenticated user, with optional organization, project, ownership, and access-scope filters. Defaults to membership-oriented discovery unless accessScope=all_readable is passed explicitly.\",\n\t\taccess: \"read\",\n\t\tinputSchema: directoryListAppsInputSchema,\n\t\toutputSchema: listAppsSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(directoryListAppsInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn listApps({\n\t\t\t\tprojectId: input.projectId,\n\t\t\t\torganizationId: input.organizationId,\n\t\t\t\townership: input.ownership,\n\t\t\t\taccessScope: input.accessScope,\n\t\t\t\tcreatedBy: input.createdBy,\n\t\t\t\tforked: input.forked,\n\t\t\t\tlimit: input.limit,\n\t\t\t\toffset: input.offset,\n\t\t\t\tcwd,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_directory_get_app\",\n\t\tdescription: \"Fetch one app by id, or infer the bound repository's current app from cwd when possible.\",\n\t\taccess: \"read\",\n\t\tinputSchema: directoryAppInputSchema,\n\t\toutputSchema: getAppSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(directoryAppInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn getApp({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t});\n\t\t},\n\t});\n}\n","import { z } from \"zod\";\n\nimport { commonRequestFieldsSchema, makeSuccessSchema } from \"./common.js\";\n\nconst genericRecordSchema = z.record(z.string(), z.unknown());\nconst genericArraySchema = z.array(genericRecordSchema);\nconst paginationSchema = z.object({\n\tlimit: z.number().int().positive(),\n\toffset: z.number().int().nonnegative(),\n\thasMore: z.boolean(),\n});\n\nexport const whoamiInputSchema = {\n\t...commonRequestFieldsSchema,\n};\n\nexport const directoryOrganizationInputSchema = {\n\t...commonRequestFieldsSchema,\n\torganizationId: z.string().trim().min(1).optional(),\n};\n\nexport const directoryListProjectsInputSchema = {\n\t...commonRequestFieldsSchema,\n\torganizationId: z.string().trim().min(1).optional(),\n\tclientAppId: z.string().trim().min(1).optional(),\n};\n\nexport const directoryProjectInputSchema = {\n\t...commonRequestFieldsSchema,\n\tprojectId: z.string().trim().min(1).optional(),\n};\n\nexport const directoryListAppsInputSchema = {\n\t...commonRequestFieldsSchema,\n\tprojectId: z.string().trim().min(1).optional(),\n\torganizationId: z.string().trim().min(1).optional(),\n\townership: z.enum([\"mine\", \"shared\", \"all\"]).optional(),\n\taccessScope: z.enum([\"all_readable\", \"explicit_member\"]).optional(),\n\tcreatedBy: z.string().trim().min(1).optional(),\n\tforked: z.enum([\"only\", \"exclude\", \"all\"]).optional(),\n\tlimit: z.number().int().positive().max(50).optional(),\n\toffset: z.number().int().nonnegative().optional(),\n};\n\nexport const directoryAppInputSchema = {\n\t...commonRequestFieldsSchema,\n\tappId: z.string().trim().min(1).optional(),\n};\n\nexport const whoamiDataSchema = z.object({\n\tid: z.string().nullable(),\n\tname: z.string().nullable(),\n\temail: z.string().nullable(),\n\torganizationId: z.string().nullable(),\n\troles: genericRecordSchema,\n\tbinding: genericRecordSchema.nullable(),\n});\nexport const listOrganizationsDataSchema = z.object({\n\torganizations: genericArraySchema,\n});\nexport const getOrganizationDataSchema = z.object({\n\torganization: genericRecordSchema,\n});\nexport const listProjectsDataSchema = z.object({\n\torganizationId: z.string().nullable(),\n\tprojects: genericArraySchema,\n});\nexport const getProjectDataSchema = z.object({\n\tproject: genericRecordSchema,\n});\nexport const listAppsDataSchema = z.object({\n\tapps: genericArraySchema,\n\tpagination: paginationSchema,\n\tfilters: z.object({\n\t\tprojectId: z.string().nullable(),\n\t\torganizationId: z.string().nullable(),\n\t\townership: z.enum([\"mine\", \"shared\", \"all\"]),\n\t\taccessScope: z.enum([\"all_readable\", \"explicit_member\"]),\n\t\tcreatedBy: z.string().nullable(),\n\t\tforked: z.enum([\"only\", \"exclude\", \"all\"]),\n\t}),\n});\nexport const getAppDataSchema = z.object({\n\tapp: genericRecordSchema,\n});\n\nexport const whoamiSuccessSchema = makeSuccessSchema(whoamiDataSchema);\nexport const listOrganizationsSuccessSchema = makeSuccessSchema(listOrganizationsDataSchema);\nexport const getOrganizationSuccessSchema = makeSuccessSchema(getOrganizationDataSchema);\nexport const listProjectsSuccessSchema = makeSuccessSchema(listProjectsDataSchema);\nexport const getProjectSuccessSchema = makeSuccessSchema(getProjectDataSchema);\nexport const listAppsSuccessSchema = makeSuccessSchema(listAppsDataSchema);\nexport const getAppSuccessSchema = makeSuccessSchema(getAppDataSchema);\n","import type { ApiClient, AppContext } from \"@remixhq/core\";\n\nimport { createApiClient } from \"./apiClient.js\";\nimport {\n\tcreateAccessDeniedError,\n\tisBackendForbidden,\n\tisBackendNotFound,\n\tloadBindingContext,\n\tmakeNotBoundError,\n\ttype ToolResult,\n\tunwrapResponseObject,\n} from \"./shared.js\";\n\ntype JsonRecord = Record<string, any>;\ntype EffectiveAppRole = \"owner\" | \"maintainer\" | \"editor\" | \"viewer\" | null;\n\nfunction normalizePagination(params?: { limit?: number; offset?: number }) {\n\tconst rawLimit = typeof params?.limit === \"number\" ? Math.trunc(params.limit) : 25;\n\tconst rawOffset = typeof params?.offset === \"number\" ? Math.trunc(params.offset) : 0;\n\treturn {\n\t\tlimit: Math.max(1, Math.min(50, rawLimit)),\n\t\toffset: Math.max(0, rawOffset),\n\t};\n}\n\nasync function resolveOrganizationId(api: ApiClient, params: { organizationId?: string; cwd?: string }): Promise<string> {\n\tconst explicitId = params.organizationId?.trim();\n\tif (explicitId) return explicitId;\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tif (!bindingContext.binding) {\n\t\tthrow makeNotBoundError(\"Organization id was not provided and the current repository is not bound to Remix.\");\n\t}\n\tconst appContext = unwrapResponseObject<AppContext>(\n\t\tawait api.getAppContext(bindingContext.binding.currentAppId),\n\t\t\"bound app context\",\n\t);\n\tif (!appContext.readableScopes.organization) {\n\t\tthrow createAccessDeniedError(\n\t\t\t\"The bound app's organization is not readable to the current user.\",\n\t\t\t\"Use an explicit organization id you can access, or inspect the bound app with `remix_directory_get_app` / `remix_access_debug` for app-level context.\",\n\t\t);\n\t}\n\treturn appContext.organizationId;\n}\n\nasync function resolveProjectId(api: ApiClient, params: { projectId?: string; cwd?: string }): Promise<{ projectId: string; repoRoot: string | null }> {\n\tconst explicitId = params.projectId?.trim();\n\tif (explicitId) {\n\t\tconst bindingContext = await loadBindingContext(params.cwd);\n\t\treturn { projectId: explicitId, repoRoot: bindingContext.repoRoot };\n\t}\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tif (!bindingContext.binding) {\n\t\tthrow makeNotBoundError(\"Project id was not provided and the current repository is not bound to Remix.\");\n\t}\n\tconst appContext = unwrapResponseObject<AppContext>(\n\t\tawait api.getAppContext(bindingContext.binding.currentAppId),\n\t\t\"bound app context\",\n\t);\n\tif (!appContext.readableScopes.project) {\n\t\tthrow createAccessDeniedError(\n\t\t\t\"The bound app's project is not readable to the current user.\",\n\t\t\t\"Use `remix_directory_get_app` or `remix_access_debug` for app-level diagnostics, or pass an explicit project id you can access.\",\n\t\t);\n\t}\n\treturn {\n\t\tprojectId: appContext.projectId,\n\t\trepoRoot: bindingContext.repoRoot,\n\t};\n}\n\nasync function resolveAppId(params: { appId?: string; cwd?: string }): Promise<{ appId: string; repoRoot: string | null }> {\n\tconst explicitId = params.appId?.trim();\n\tif (explicitId) {\n\t\tconst bindingContext = await loadBindingContext(params.cwd);\n\t\treturn { appId: explicitId, repoRoot: bindingContext.repoRoot };\n\t}\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tif (!bindingContext.binding) {\n\t\tthrow makeNotBoundError(\"App id was not provided and the current repository is not bound to Remix.\");\n\t}\n\treturn {\n\t\tappId: bindingContext.binding.currentAppId,\n\t\trepoRoot: bindingContext.repoRoot,\n\t};\n}\n\nfunction toEffectiveAppRole(role: string | null): EffectiveAppRole {\n\tswitch (role) {\n\t\tcase \"owner\":\n\t\tcase \"maintainer\":\n\t\tcase \"editor\":\n\t\tcase \"viewer\":\n\t\t\treturn role;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\nfunction resolveAppAccessSource(params: {\n\tdirectAppRole: EffectiveAppRole;\n\tinheritedProjectRole: EffectiveAppRole;\n}): \"none\" | \"direct_app_membership\" | \"project_membership\" | \"both\" {\n\tif (params.directAppRole && params.inheritedProjectRole) return \"both\";\n\tif (params.directAppRole) return \"direct_app_membership\";\n\tif (params.inheritedProjectRole) return \"project_membership\";\n\treturn \"none\";\n}\n\nfunction emptySelfRoles() {\n\treturn {\n\t\torganizationRole: null,\n\t\tprojectRole: null,\n\t\tappRole: null,\n\t\tdirectAppRole: null,\n\t\tinheritedProjectRole: null,\n\t\tappAccessSource: \"none\" as const,\n\t};\n}\n\nfunction resolveSelfRolesFromAppContext(appContext: AppContext | null) {\n\tif (!appContext) return emptySelfRoles();\n\tconst directAppRole = toEffectiveAppRole(appContext.roles.appRole);\n\tconst inheritedProjectRole = toEffectiveAppRole(appContext.roles.inheritedProjectRole);\n\treturn {\n\t\torganizationRole: appContext.roles.organizationRole ?? null,\n\t\tprojectRole: appContext.roles.projectRole ?? null,\n\t\tappRole: toEffectiveAppRole(appContext.roles.effectiveAppRole),\n\t\tdirectAppRole,\n\t\tinheritedProjectRole,\n\t\tappAccessSource: resolveAppAccessSource({ directAppRole, inheritedProjectRole }),\n\t};\n}\n\nexport async function whoAmI(params: { cwd?: string }): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tconst me = unwrapResponseObject<JsonRecord>(await api.getMe(), \"current user\");\n\tconst warnings: string[] = bindingContext.binding ? [] : [\"No local Remix binding was detected for the provided cwd.\"];\n\tlet boundAppContext: AppContext | null = null;\n\tlet boundProject: JsonRecord | null = null;\n\tlet boundApp: JsonRecord | null = null;\n\tif (bindingContext.binding) {\n\t\ttry {\n\t\t\tboundAppContext = unwrapResponseObject<AppContext>(\n\t\t\t\tawait api.getAppContext(bindingContext.binding.currentAppId),\n\t\t\t\t\"bound app context\",\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tif (!isBackendForbidden(error) && !isBackendNotFound(error)) throw error;\n\t\t\twarnings.push(\n\t\t\t\t\"The bound app context could not be loaded. The local binding may be stale, or the current user may no longer be able to read that app.\",\n\t\t\t);\n\t\t}\n\t\ttry {\n\t\t\tboundApp = unwrapResponseObject<JsonRecord>(await api.getApp(bindingContext.binding.currentAppId), \"app\");\n\t\t} catch (error) {\n\t\t\tif (!isBackendForbidden(error) && !isBackendNotFound(error)) throw error;\n\t\t\twarnings.push(\"The bound app metadata could not be loaded for the current user.\");\n\t\t}\n\t\tif (boundAppContext?.readableScopes.project) {\n\t\t\ttry {\n\t\t\t\tboundProject = unwrapResponseObject<JsonRecord>(await api.getProject(boundAppContext.projectId), \"project\");\n\t\t\t} catch (error) {\n\t\t\t\tif (!isBackendForbidden(error) && !isBackendNotFound(error)) throw error;\n\t\t\t\twarnings.push(\"The bound app is readable, but its project metadata is not currently readable to the current user.\");\n\t\t\t}\n\t\t} else if (boundAppContext) {\n\t\t\twarnings.push(\"The bound app is readable, but its project/workspace is not readable to the current user.\");\n\t\t}\n\t}\n\tconst roles = resolveSelfRolesFromAppContext(boundAppContext);\n\treturn {\n\t\tdata: {\n\t\t\tid: me.id ?? null,\n\t\t\tname: me.name ?? null,\n\t\t\temail: me.email ?? null,\n\t\t\torganizationId: me.organizationId ?? null,\n\t\t\troles,\n\t\t\tbinding:\n\t\t\t\tbindingContext.binding == null\n\t\t\t\t\t? null\n\t\t\t\t\t: {\n\t\t\t\t\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t\t\t\t\t\t...bindingContext.binding,\n\t\t\t\t\t\t\tprojectId: boundAppContext?.projectId ?? bindingContext.binding.projectId,\n\t\t\t\t\t\t\torganizationId: boundAppContext?.organizationId ?? null,\n\t\t\t\t\t\t\tvisibility: boundAppContext?.visibility ?? null,\n\t\t\t\t\t\t\taccessPath: boundAppContext?.accessPath ?? null,\n\t\t\t\t\t\t\treadableScopes: boundAppContext?.readableScopes ?? null,\n\t\t\t\t\t\t\tprojectName: boundProject?.name ?? null,\n\t\t\t\t\t\t\tappName: boundApp?.name ?? null,\n\t\t\t\t\t\t},\n\t\t},\n\t\twarnings,\n\t\trecommendedNextActions: bindingContext.binding\n\t\t\t? [\"Use `remix_access_debug` next when you need to explain repository binding or membership issues in this workspace.\"]\n\t\t\t: [\"Use `remix_directory_list_organizations` to inspect visible tenancy context, or run `remix_collab_init` in a repository to create a local binding.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t\tappId: bindingContext.binding?.currentAppId ?? null,\n\t\t},\n\t};\n}\n\nexport async function listOrganizations(): Promise<ToolResult<{ organizations: JsonRecord[] }>> {\n\tconst api = await createApiClient();\n\tconst organizations = unwrapResponseObject<JsonRecord[]>(await api.listOrganizations(), \"organizations\");\n\treturn {\n\t\tdata: { organizations },\n\t\twarnings: [],\n\t\trecommendedNextActions: organizations.length\n\t\t\t? [\"Use `remix_directory_get_organization` for one organization, or `remix_directory_list_projects` to inspect projects under a chosen organization.\"]\n\t\t\t: [],\n\t\tlogContext: {},\n\t};\n}\n\nexport async function getOrganization(params: { organizationId?: string; cwd?: string }): Promise<ToolResult<{ organization: JsonRecord }>> {\n\tconst api = await createApiClient();\n\tconst organizationId = await resolveOrganizationId(api, params);\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tconst organization = unwrapResponseObject<JsonRecord>(await api.getOrganization(organizationId), \"organization\");\n\treturn {\n\t\tdata: { organization },\n\t\twarnings: [],\n\t\trecommendedNextActions: [\"Use `remix_directory_list_projects` with this organization id to inspect its project directory.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t},\n\t};\n}\n\nexport async function listProjects(params: {\n\torganizationId?: string;\n\tclientAppId?: string;\n\tcwd?: string;\n}): Promise<ToolResult<{ projects: JsonRecord[]; organizationId: string | null }>> {\n\tconst api = await createApiClient();\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tconst organizationId =\n\t\tparams.organizationId !== undefined ? await resolveOrganizationId(api, { organizationId: params.organizationId, cwd: params.cwd }) : null;\n\tconst projects = unwrapResponseObject<JsonRecord[]>(\n\t\tawait api.listProjects({\n\t\t\torganizationId: organizationId ?? undefined,\n\t\t\tclientAppId: params.clientAppId,\n\t\t}),\n\t\t\"projects\",\n\t);\n\treturn {\n\t\tdata: {\n\t\t\tprojects,\n\t\t\torganizationId,\n\t\t},\n\t\twarnings: [],\n\t\trecommendedNextActions: projects.length\n\t\t\t? [\"Use `remix_directory_get_project` for one project, or `remix_directory_list_apps` to inspect apps under a chosen project or organization.\"]\n\t\t\t: [],\n\t\tlogContext: {\n\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t\tappId: bindingContext.binding?.currentAppId ?? null,\n\t\t},\n\t};\n}\n\nexport async function getProject(params: { projectId?: string; cwd?: string }): Promise<ToolResult<{ project: JsonRecord }>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveProjectId(api, params);\n\tconst project = unwrapResponseObject<JsonRecord>(await api.getProject(target.projectId), \"project\");\n\treturn {\n\t\tdata: { project },\n\t\twarnings: [],\n\t\trecommendedNextActions: [\"Use `remix_directory_list_apps` with this project id to inspect apps under the project.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: target.repoRoot,\n\t\t},\n\t};\n}\n\nexport async function listApps(params: {\n\tprojectId?: string;\n\torganizationId?: string;\n\townership?: \"mine\" | \"shared\" | \"all\";\n\taccessScope?: \"all_readable\" | \"explicit_member\";\n\tcreatedBy?: string;\n\tforked?: \"only\" | \"exclude\" | \"all\";\n\tlimit?: number;\n\toffset?: number;\n\tcwd?: string;\n}): Promise<\n\tToolResult<{\n\t\tapps: JsonRecord[];\n\t\tpagination: { limit: number; offset: number; hasMore: boolean };\n\t\tfilters: {\n\t\t\tprojectId: string | null;\n\t\t\torganizationId: string | null;\n\t\t\townership: \"mine\" | \"shared\" | \"all\";\n\t\t\taccessScope: \"all_readable\" | \"explicit_member\";\n\t\t\tcreatedBy: string | null;\n\t\t\tforked: \"only\" | \"exclude\" | \"all\";\n\t\t};\n\t}>\n> {\n\tconst api = await createApiClient();\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tconst pagination = normalizePagination(params);\n\tconst apps = unwrapResponseObject<JsonRecord[]>(\n\t\tawait api.listApps({\n\t\t\tprojectId: params.projectId,\n\t\t\torganizationId: params.organizationId,\n\t\t\townership: params.ownership ?? \"all\",\n\t\t\taccessScope: params.accessScope ?? \"explicit_member\",\n\t\t\tcreatedBy: params.createdBy,\n\t\t\tforked: params.forked,\n\t\t\tlimit: pagination.limit + 1,\n\t\t\toffset: pagination.offset,\n\t\t}),\n\t\t\"apps\",\n\t);\n\treturn {\n\t\tdata: {\n\t\t\tapps: apps.slice(0, pagination.limit),\n\t\t\tpagination: {\n\t\t\t\t...pagination,\n\t\t\t\thasMore: apps.length > pagination.limit,\n\t\t\t},\n\t\t\tfilters: {\n\t\t\t\tprojectId: params.projectId ?? null,\n\t\t\t\torganizationId: params.organizationId ?? null,\n\t\t\t\townership: params.ownership ?? \"all\",\n\t\t\t\taccessScope: params.accessScope ?? \"explicit_member\",\n\t\t\t\tcreatedBy: params.createdBy ?? null,\n\t\t\t\tforked: params.forked ?? \"all\",\n\t\t\t},\n\t\t},\n\t\twarnings: [],\n\t\trecommendedNextActions:\n\t\t\tapps.length > pagination.limit\n\t\t\t\t? [`Pass offset=${pagination.offset + pagination.limit} to load the next page.`]\n\t\t\t\t: [\"Use `remix_directory_get_app` for one app, or `remix_context_get_app_overview` for operational context on a chosen app.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t\tappId: bindingContext.binding?.currentAppId ?? null,\n\t\t},\n\t};\n}\n\nexport async function getApp(params: { appId?: string; cwd?: string }): Promise<ToolResult<{ app: JsonRecord }>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppId(params);\n\tconst app = unwrapResponseObject<JsonRecord>(await api.getApp(target.appId), \"app\");\n\treturn {\n\t\tdata: { app },\n\t\twarnings: [],\n\t\trecommendedNextActions: [\"Use `remix_context_get_app_overview` for status and capability context, or `remix_ops_list_timeline` for bounded historical activity.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: target.repoRoot,\n\t\t\tappId: target.appId,\n\t\t},\n\t};\n}\n","import { z } from \"zod\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { ToolAnnotations } from \"@modelcontextprotocol/sdk/types.js\";\n\nimport type { ServerContext } from \"../../bootstrap/context.js\";\nimport {\n changeStepDiffInputSchema,\n changeStepDiffSuccessSchema,\n memorySearchInputSchema,\n memorySearchSuccessSchema,\n memorySummaryInputSchema,\n memorySummarySuccessSchema,\n memoryTimelineInputSchema,\n memoryTimelineSuccessSchema,\n} from \"../../contracts/memory.js\";\nimport {\n makeErrorResult,\n makeErrorSchema,\n makeSuccessResult,\n type ErrorEnvelope,\n type SuccessEnvelope,\n SCHEMA_VERSION,\n} from \"../../contracts/common.js\";\nimport type { NormalizedToolError } from \"../../errors/errorCodes.js\";\nimport { normalizeToolError } from \"../../errors/normalizeError.js\";\nimport { getChangeStepDiff, getMemorySummary, getMemoryTimeline, searchMemory } from \"../../domain/memoryAdapter.js\";\nimport { assertToolAccess, resolvePolicyCwd, type ToolAccess } from \"../../policy/policy.js\";\n\ntype ToolExecutionResult<T> = {\n data: T;\n warnings?: string[];\n risks?: string[];\n recommendedNextActions?: string[];\n logContext?: {\n repoRoot?: string | null;\n appId?: string | null;\n mrId?: string | null;\n };\n};\n\nfunction getAnnotations(access: ToolAccess): ToolAnnotations {\n return {\n readOnlyHint: access === \"read\",\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n };\n}\n\nfunction buildSuccessEnvelope<T>(tool: string, requestId: string | undefined, result: ToolExecutionResult<T>): SuccessEnvelope<T> {\n return {\n schemaVersion: SCHEMA_VERSION,\n ok: true,\n tool,\n requestId: requestId ?? null,\n data: result.data,\n warnings: result.warnings ?? [],\n risks: result.risks ?? [],\n recommendedNextActions: result.recommendedNextActions ?? [],\n };\n}\n\nfunction buildErrorEnvelope(tool: string, requestId: string | undefined, error: unknown): ErrorEnvelope {\n const normalized = normalizeToolError(error);\n return {\n schemaVersion: SCHEMA_VERSION,\n ok: false,\n tool,\n requestId: requestId ?? null,\n error: normalized,\n warnings: [],\n risks: deriveErrorRisks(normalized),\n recommendedNextActions: normalized.code === \"AUTH_REQUIRED\" ? [\"Run `remix login` or set COMERGE_ACCESS_TOKEN, then retry.\"] : [],\n };\n}\n\nfunction deriveErrorRisks(normalized: NormalizedToolError): string[] {\n if (normalized.code === \"DESTRUCTIVE_OPERATION_BLOCKED\") {\n return [\"A policy guard blocked a disallowed operation.\"];\n }\n return [];\n}\n\nfunction registerTool<T>(\n server: McpServer,\n context: ServerContext,\n params: {\n name: string;\n description: string;\n access: ToolAccess;\n inputSchema: Record<string, z.ZodTypeAny>;\n outputSchema: z.ZodTypeAny;\n run: (args: Record<string, unknown>) => Promise<ToolExecutionResult<T>>;\n },\n) {\n const errorSchema = makeErrorSchema();\n server.registerTool(\n params.name,\n {\n title: params.name,\n description: params.description,\n inputSchema: params.inputSchema,\n outputSchema: params.outputSchema,\n annotations: getAnnotations(params.access),\n },\n async (rawArgs: Record<string, unknown>) => {\n const requestId = typeof rawArgs.requestId === \"string\" ? rawArgs.requestId : undefined;\n const startedAt = Date.now();\n try {\n assertToolAccess(context.policy, params.access);\n const result = await params.run(rawArgs);\n const envelope = buildSuccessEnvelope(params.name, requestId, result);\n params.outputSchema.parse(envelope);\n context.logger.log({\n level: \"info\",\n message: \"tool_completed\",\n tool: params.name,\n requestId: envelope.requestId,\n durationMs: Date.now() - startedAt,\n result: \"success\",\n repoRoot: result.logContext?.repoRoot ?? null,\n appId: result.logContext?.appId ?? null,\n mrId: result.logContext?.mrId ?? null,\n truncated: result.warnings?.some((warning) => warning.toLowerCase().includes(\"truncated\")) ?? false,\n });\n return makeSuccessResult(envelope);\n } catch (error) {\n const envelope = buildErrorEnvelope(params.name, requestId, error);\n errorSchema.parse(envelope);\n context.logger.log({\n level: \"error\",\n message: \"tool_failed\",\n tool: params.name,\n requestId: envelope.requestId,\n durationMs: Date.now() - startedAt,\n result: \"error\",\n errorCode: envelope.error.code,\n });\n return makeErrorResult(envelope);\n }\n },\n );\n}\n\nexport function registerMemoryTools(server: McpServer, context: ServerContext): void {\n registerTool(server, context, {\n name: \"remix_collab_memory_summary\",\n description:\n \"First read for a bound app's current collaboration state, recent reasoning context, and merge or reconcile history before deeper inspection or any raw git history lookup.\",\n access: \"read\",\n inputSchema: memorySummaryInputSchema,\n outputSchema: memorySummarySuccessSchema,\n run: async (args) => {\n const input = z.object(memorySummaryInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return getMemorySummary({\n cwd,\n appId: input.appId,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_memory_search\",\n description:\n \"Default tool for why/history/failed-attempt/user-intent questions. Search prompts, diffs, merge activity, reconciles, and other historical context before using raw git for exact repository facts.\",\n access: \"read\",\n inputSchema: memorySearchInputSchema,\n outputSchema: memorySearchSuccessSchema,\n run: async (args) => {\n const input = z.object(memorySearchInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return searchMemory({\n cwd,\n appId: input.appId,\n query: input.query,\n kinds: input.kinds,\n limit: input.limit,\n offset: input.offset,\n createdAfter: input.createdAfter,\n createdBefore: input.createdBefore,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_memory_timeline\",\n description:\n \"Chronological view of collaboration memory for understanding what happened and in what order, with optional filters for bounded historical inspection before any exact-facts raw git follow-up.\",\n access: \"read\",\n inputSchema: memoryTimelineInputSchema,\n outputSchema: memoryTimelineSuccessSchema,\n run: async (args) => {\n const input = z.object(memoryTimelineInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return getMemoryTimeline({\n cwd,\n appId: input.appId,\n kinds: input.kinds,\n limit: input.limit,\n offset: input.offset,\n createdAfter: input.createdAfter,\n createdBefore: input.createdBefore,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_memory_change_step_diff\",\n description:\n \"Second-hop expansion tool that fetches the full stored diff for a specific change step after memory search, timeline, or review work has identified the relevant `changeStepId`, keeping historical inspection inside Remix before raw git fallback.\",\n access: \"read\",\n inputSchema: changeStepDiffInputSchema,\n outputSchema: changeStepDiffSuccessSchema,\n run: async (args) => {\n const input = z.object(changeStepDiffInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return getChangeStepDiff({\n cwd,\n appId: input.appId,\n changeStepId: input.changeStepId,\n });\n },\n });\n}\n","import { z } from \"zod\";\n\nimport { commonRequestFieldsSchema, makeSuccessSchema } from \"./common.js\";\n\nconst genericRecordSchema = z.record(z.string(), z.unknown());\nconst genericArraySchema = z.array(genericRecordSchema);\nconst memoryKindSchema = z.enum([\"collab_turn\", \"change_step\", \"merge_request\", \"reconcile\"]);\nconst paginationSchema = z.object({\n limit: z.number().int().nonnegative(),\n offset: z.number().int().nonnegative(),\n hasMore: z.boolean(),\n});\n\nexport const memorySummaryInputSchema = {\n ...commonRequestFieldsSchema,\n appId: z.string().trim().min(1).optional(),\n};\n\nexport const memorySearchInputSchema = {\n ...commonRequestFieldsSchema,\n appId: z.string().trim().min(1).optional(),\n query: z.string().trim().min(1),\n kinds: z.array(memoryKindSchema).max(4).optional(),\n limit: z.number().int().positive().max(50).optional(),\n offset: z.number().int().nonnegative().optional(),\n createdAfter: z.string().trim().min(1).optional(),\n createdBefore: z.string().trim().min(1).optional(),\n};\n\nexport const memoryTimelineInputSchema = {\n ...commonRequestFieldsSchema,\n appId: z.string().trim().min(1).optional(),\n kinds: z.array(memoryKindSchema).max(4).optional(),\n limit: z.number().int().positive().max(50).optional(),\n offset: z.number().int().nonnegative().optional(),\n createdAfter: z.string().trim().min(1).optional(),\n createdBefore: z.string().trim().min(1).optional(),\n};\n\nexport const changeStepDiffInputSchema = {\n ...commonRequestFieldsSchema,\n appId: z.string().trim().min(1).optional(),\n changeStepId: z.string().trim().min(1),\n};\n\nexport const memorySummaryDataSchema = genericRecordSchema;\nexport const memorySearchDataSchema = z.object({\n items: genericArraySchema,\n pagination: paginationSchema,\n});\nexport const memoryTimelineDataSchema = z.object({\n items: genericArraySchema,\n pagination: paginationSchema,\n});\nexport const changeStepDiffDataSchema = z.object({\n changeStepId: z.string(),\n appId: z.string(),\n diff: z.string(),\n diffSha256: z.string(),\n contentType: z.string(),\n encoding: z.string(),\n expiresIn: z.number().int().positive(),\n});\n\nexport const memorySummarySuccessSchema = makeSuccessSchema(memorySummaryDataSchema);\nexport const memorySearchSuccessSchema = makeSuccessSchema(memorySearchDataSchema);\nexport const memoryTimelineSuccessSchema = makeSuccessSchema(memoryTimelineDataSchema);\nexport const changeStepDiffSuccessSchema = makeSuccessSchema(changeStepDiffDataSchema);\n","import type {\n AgentMemoryKind,\n AgentMemorySearchResponse,\n AgentMemorySummary,\n AgentMemoryTimelineResponse,\n ChangeStepDiffResponse,\n} from \"@remixhq/core\";\nimport { readCollabBinding } from \"@remixhq/core/binding\";\nimport { findGitRoot } from \"@remixhq/core/repo\";\n\nimport { createApiClient } from \"./apiClient.js\";\n\ntype ToolResult<T> = {\n data: T;\n warnings?: string[];\n recommendedNextActions?: string[];\n logContext?: {\n repoRoot?: string | null;\n appId?: string | null;\n };\n};\n\ntype MemoryTarget = {\n appId: string;\n repoRoot: string | null;\n};\n\nfunction buildSummaryNextActions(summary: AgentMemorySummary): string[] {\n const actions: string[] = [];\n\n actions.push(\n \"Use `remix_collab_memory_search` next for focused why/history/failed-attempt questions about this app.\",\n );\n\n const recentItemCount =\n summary.recent.collabTurns.length +\n summary.recent.changeSteps.length +\n summary.recent.mergeRequests.length +\n summary.recent.reconciles.length;\n if (recentItemCount > 0) {\n actions.push(\"Use `remix_collab_memory_timeline` next if you need the chronological sequence of recent activity.\");\n }\n\n if (summary.counts.failedChangeStepCount > 0 || summary.counts.reconcileCount > 0) {\n actions.push(\n \"For prior failures or recovery history, run `remix_collab_memory_search` with a focused query and `kinds` narrowed to `change_step` and `reconcile` when appropriate.\",\n );\n }\n\n return actions;\n}\n\nfunction getFirstChangeStepId(items: Array<{ id: string; kind: AgentMemoryKind }>): string | null {\n const changeStep = items.find((item) => item.kind === \"change_step\");\n return changeStep?.id ?? null;\n}\n\nfunction buildSearchNextActions(result: AgentMemorySearchResponse): string[] {\n if (result.items.length === 0) {\n return [\n \"Try a broader `remix_collab_memory_search` query or fewer `kinds` filters if this topic likely uses different wording.\",\n \"Use `remix_collab_memory_timeline` if you need a bounded chronological scan instead of relevance-ranked search.\",\n ];\n }\n\n const actions: string[] = [\n \"Review the top matched memory items before reaching for raw git so the relevant Remix reasoning context stays in view.\",\n ];\n const changeStepId = getFirstChangeStepId(result.items);\n if (changeStepId) {\n actions.push(\n `Use \\`remix_collab_memory_change_step_diff\\` with \\`changeStepId=${changeStepId}\\` if you need the full stored diff for the most relevant change step.`,\n );\n }\n\n if (result.pagination.hasMore) {\n actions.push(\"Narrow the search with `kinds`, `createdAfter`, or `createdBefore` if you need a tighter historical slice.\");\n }\n\n return actions;\n}\n\nfunction buildTimelineNextActions(result: AgentMemoryTimelineResponse): string[] {\n if (result.items.length === 0) {\n return [\n \"Use `remix_collab_memory_summary` for current state, then retry `remix_collab_memory_timeline` with broader filters if needed.\",\n ];\n }\n\n const actions: string[] = [\n \"Use `remix_collab_memory_search` if you need relevance-ranked results for a specific feature, bug, or design decision.\",\n ];\n const changeStepId = getFirstChangeStepId(result.items);\n if (changeStepId) {\n actions.push(\n `Use \\`remix_collab_memory_change_step_diff\\` with \\`changeStepId=${changeStepId}\\` after the timeline identifies the change step you need to inspect.`,\n );\n }\n\n if (result.pagination.hasMore) {\n actions.push(\"Apply `kinds`, `createdAfter`, or `createdBefore` filters to focus the timeline on a smaller historical window.\");\n }\n\n return actions;\n}\n\nfunction buildChangeStepDiffNextActions(changeStepId: string): string[] {\n return [\n `Inspect the stored diff for \\`changeStepId=${changeStepId}\\`, then use raw git only if you still need exact repository-level commit, blame, ancestry, or raw patch details.`,\n ];\n}\n\nfunction unwrapResponseObject<T>(resp: any, label: string): T {\n const obj = resp?.responseObject;\n if (obj === undefined || obj === null) {\n throw new Error(typeof resp?.message === \"string\" && resp.message.trim() ? resp.message : `Missing ${label} response`);\n }\n return obj as T;\n}\n\nfunction makeNotBoundError(): Error & { hint?: string } {\n const error = new Error(\"Repository is not bound to Remix.\") as Error & { hint?: string };\n error.hint = \"Run `remix_collab_init` in this repository, or pass `appId` explicitly for a direct memory read.\";\n return error;\n}\n\nasync function maybeFindGitRoot(cwd: string): Promise<string | null> {\n try {\n return await findGitRoot(cwd);\n } catch {\n return null;\n }\n}\n\nasync function resolveMemoryTarget(params: { cwd: string; appId?: string }): Promise<MemoryTarget> {\n const explicitAppId = params.appId?.trim();\n if (explicitAppId) {\n return {\n appId: explicitAppId,\n repoRoot: await maybeFindGitRoot(params.cwd),\n };\n }\n\n const repoRoot = await findGitRoot(params.cwd);\n const binding = await readCollabBinding(repoRoot);\n if (!binding) {\n throw makeNotBoundError();\n }\n\n return {\n appId: binding.currentAppId,\n repoRoot,\n };\n}\n\nexport async function getMemorySummary(params: { cwd: string; appId?: string }): Promise<ToolResult<AgentMemorySummary>> {\n const target = await resolveMemoryTarget(params);\n const api = await createApiClient();\n const resp = await api.getAgentMemorySummary(target.appId);\n const data = unwrapResponseObject<AgentMemorySummary>(resp, \"agent memory summary\");\n\n return {\n data,\n warnings: [],\n recommendedNextActions: buildSummaryNextActions(data),\n logContext: target,\n };\n}\n\nexport async function searchMemory(params: {\n cwd: string;\n appId?: string;\n query: string;\n kinds?: AgentMemoryKind[];\n limit?: number;\n offset?: number;\n createdAfter?: string;\n createdBefore?: string;\n}): Promise<ToolResult<AgentMemorySearchResponse>> {\n const target = await resolveMemoryTarget(params);\n const api = await createApiClient();\n const resp = await api.searchAgentMemory(target.appId, {\n q: params.query,\n kinds: params.kinds,\n limit: params.limit,\n offset: params.offset,\n createdAfter: params.createdAfter,\n createdBefore: params.createdBefore,\n });\n const data = unwrapResponseObject<AgentMemorySearchResponse>(resp, \"agent memory search\");\n\n return {\n data,\n warnings: [],\n recommendedNextActions: buildSearchNextActions(data),\n logContext: target,\n };\n}\n\nexport async function getMemoryTimeline(params: {\n cwd: string;\n appId?: string;\n kinds?: AgentMemoryKind[];\n limit?: number;\n offset?: number;\n createdAfter?: string;\n createdBefore?: string;\n}): Promise<ToolResult<AgentMemoryTimelineResponse>> {\n const target = await resolveMemoryTarget(params);\n const api = await createApiClient();\n const resp = await api.listAgentMemoryTimeline(target.appId, {\n kinds: params.kinds,\n limit: params.limit,\n offset: params.offset,\n createdAfter: params.createdAfter,\n createdBefore: params.createdBefore,\n });\n const data = unwrapResponseObject<AgentMemoryTimelineResponse>(resp, \"agent memory timeline\");\n\n return {\n data,\n warnings: [],\n recommendedNextActions: buildTimelineNextActions(data),\n logContext: target,\n };\n}\n\nexport async function getChangeStepDiff(params: {\n cwd: string;\n appId?: string;\n changeStepId: string;\n}): Promise<ToolResult<ChangeStepDiffResponse>> {\n const target = await resolveMemoryTarget(params);\n const api = await createApiClient();\n const resp = await api.getChangeStepDiff(target.appId, params.changeStepId);\n const data = unwrapResponseObject<ChangeStepDiffResponse>(resp, \"change step diff\");\n\n return {\n data,\n warnings: [],\n recommendedNextActions: buildChangeStepDiffNextActions(data.changeStepId),\n logContext: target,\n };\n}\n","import { z } from \"zod\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { ToolAnnotations } from \"@modelcontextprotocol/sdk/types.js\";\n\nimport type { ServerContext } from \"../../bootstrap/context.js\";\nimport {\n\tagentRunEventsInputSchema,\n\tagentRunEventsSuccessSchema,\n\tagentRunInputSchema,\n\tagentRunsInputSchema,\n\tagentRunsSuccessSchema,\n\tagentRunSuccessSchema,\n\tappJobQueueInputSchema,\n\tappJobQueueSuccessSchema,\n\tappOverviewSuccessSchema,\n\tappScopedInputSchema,\n\tbundleInputSchema,\n\tbundleSuccessSchema,\n\teditQueueInputSchema,\n\teditQueueSuccessSchema,\n\tsandboxStatusSuccessSchema,\n\ttimelineInputSchema,\n\ttimelineSuccessSchema,\n} from \"../../contracts/ops.js\";\nimport {\n\tmakeErrorResult,\n\tmakeErrorSchema,\n\tmakeSuccessResult,\n\ttype ErrorEnvelope,\n\ttype SuccessEnvelope,\n\tSCHEMA_VERSION,\n} from \"../../contracts/common.js\";\nimport type { NormalizedToolError } from \"../../errors/errorCodes.js\";\nimport { normalizeToolError } from \"../../errors/normalizeError.js\";\nimport {\n\tgetAgentRun,\n\tlistAppJobQueue,\n\tgetAppOverview,\n\tgetBundle,\n\tgetEditQueue,\n\tgetSandboxStatus,\n\tlistAgentRuns,\n\tlistAgentRunEvents,\n\tlistTimeline,\n} from \"../../domain/opsAdapter.js\";\nimport { assertToolAccess, resolvePolicyCwd, type ToolAccess } from \"../../policy/policy.js\";\n\ntype ToolExecutionResult<T> = {\n\tdata: T;\n\twarnings?: string[];\n\trisks?: string[];\n\trecommendedNextActions?: string[];\n\tlogContext?: {\n\t\trepoRoot?: string | null;\n\t\tappId?: string | null;\n\t\tmrId?: string | null;\n\t};\n};\n\nfunction getAnnotations(access: ToolAccess): ToolAnnotations {\n\treturn {\n\t\treadOnlyHint: access === \"read\",\n\t\tdestructiveHint: false,\n\t\tidempotentHint: true,\n\t\topenWorldHint: false,\n\t};\n}\n\nfunction buildSuccessEnvelope<T>(tool: string, requestId: string | undefined, result: ToolExecutionResult<T>): SuccessEnvelope<T> {\n\treturn {\n\t\tschemaVersion: SCHEMA_VERSION,\n\t\tok: true,\n\t\ttool,\n\t\trequestId: requestId ?? null,\n\t\tdata: result.data,\n\t\twarnings: result.warnings ?? [],\n\t\trisks: result.risks ?? [],\n\t\trecommendedNextActions: result.recommendedNextActions ?? [],\n\t};\n}\n\nfunction deriveErrorRisks(normalized: NormalizedToolError): string[] {\n\tif (normalized.code === \"DESTRUCTIVE_OPERATION_BLOCKED\") {\n\t\treturn [\"A policy guard blocked a disallowed operation.\"];\n\t}\n\treturn [];\n}\n\nfunction buildErrorEnvelope(tool: string, requestId: string | undefined, error: unknown): ErrorEnvelope {\n\tconst normalized = normalizeToolError(error);\n\treturn {\n\t\tschemaVersion: SCHEMA_VERSION,\n\t\tok: false,\n\t\ttool,\n\t\trequestId: requestId ?? null,\n\t\terror: normalized,\n\t\twarnings: [],\n\t\trisks: deriveErrorRisks(normalized),\n\t\trecommendedNextActions: normalized.code === \"AUTH_REQUIRED\" ? [\"Run `remix login` or set COMERGE_ACCESS_TOKEN, then retry.\"] : [],\n\t};\n}\n\nfunction registerTool<T>(\n\tserver: McpServer,\n\tcontext: ServerContext,\n\tparams: {\n\t\tname: string;\n\t\tdescription: string;\n\t\taccess: ToolAccess;\n\t\tinputSchema: Record<string, z.ZodTypeAny>;\n\t\toutputSchema: z.ZodTypeAny;\n\t\trun: (args: Record<string, unknown>) => Promise<ToolExecutionResult<T>>;\n\t},\n) {\n\tconst errorSchema = makeErrorSchema();\n\tserver.registerTool(\n\t\tparams.name,\n\t\t{\n\t\t\ttitle: params.name,\n\t\t\tdescription: params.description,\n\t\t\tinputSchema: params.inputSchema,\n\t\t\toutputSchema: params.outputSchema,\n\t\t\tannotations: getAnnotations(params.access),\n\t\t},\n\t\tasync (rawArgs: Record<string, unknown>) => {\n\t\t\tconst requestId = typeof rawArgs.requestId === \"string\" ? rawArgs.requestId : undefined;\n\t\t\tconst startedAt = Date.now();\n\t\t\ttry {\n\t\t\t\tassertToolAccess(context.policy, params.access);\n\t\t\t\tconst result = await params.run(rawArgs);\n\t\t\t\tconst envelope = buildSuccessEnvelope(params.name, requestId, result);\n\t\t\t\tparams.outputSchema.parse(envelope);\n\t\t\t\tcontext.logger.log({\n\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\tmessage: \"tool_completed\",\n\t\t\t\t\ttool: params.name,\n\t\t\t\t\trequestId: envelope.requestId,\n\t\t\t\t\tdurationMs: Date.now() - startedAt,\n\t\t\t\t\tresult: \"success\",\n\t\t\t\t\trepoRoot: result.logContext?.repoRoot ?? null,\n\t\t\t\t\tappId: result.logContext?.appId ?? null,\n\t\t\t\t\tmrId: result.logContext?.mrId ?? null,\n\t\t\t\t});\n\t\t\t\treturn makeSuccessResult(envelope);\n\t\t\t} catch (error) {\n\t\t\t\tconst envelope = buildErrorEnvelope(params.name, requestId, error);\n\t\t\t\terrorSchema.parse(envelope);\n\t\t\t\tcontext.logger.log({\n\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\tmessage: \"tool_failed\",\n\t\t\t\t\ttool: params.name,\n\t\t\t\t\trequestId: envelope.requestId,\n\t\t\t\t\tdurationMs: Date.now() - startedAt,\n\t\t\t\t\tresult: \"error\",\n\t\t\t\t\terrorCode: envelope.error.code,\n\t\t\t\t});\n\t\t\t\treturn makeErrorResult(envelope);\n\t\t\t}\n\t\t},\n\t);\n}\n\nexport function registerOpsTools(server: McpServer, context: ServerContext): void {\n\tregisterTool(server, context, {\n\t\tname: \"remix_context_get_app_overview\",\n\t\tdescription: \"Read the current app's overview, capabilities, and workflow readiness without mutating state.\",\n\t\taccess: \"read\",\n\t\tinputSchema: appScopedInputSchema,\n\t\toutputSchema: appOverviewSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(appScopedInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn getAppOverview({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_ops_get_edit_queue\",\n\t\tdescription: \"Inspect the pending edit queue for one app with bounded pagination.\",\n\t\taccess: \"read\",\n\t\tinputSchema: editQueueInputSchema,\n\t\toutputSchema: editQueueSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(editQueueInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn getEditQueue({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t\tlimit: input.limit,\n\t\t\t\toffset: input.offset,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_ops_list_app_job_queue\",\n\t\tdescription: \"Inspect bounded app-scoped workflow queue jobs for one app, including active backend work such as merge, replay, reconcile, revert, bundle, or import processing.\",\n\t\taccess: \"read\",\n\t\tinputSchema: appJobQueueInputSchema,\n\t\toutputSchema: appJobQueueSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(appJobQueueInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn listAppJobQueue({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t\tlimit: input.limit,\n\t\t\t\toffset: input.offset,\n\t\t\t\tkind: input.kind,\n\t\t\t\tstatus: input.status,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_ops_get_bundle\",\n\t\tdescription: \"Inspect one app bundle by id without downloading the artifact payload.\",\n\t\taccess: \"read\",\n\t\tinputSchema: bundleInputSchema,\n\t\toutputSchema: bundleSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(bundleInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn getBundle({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t\tbundleId: input.bundleId,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_ops_list_timeline\",\n\t\tdescription: \"List bounded timeline events for one app using the backend cursor pagination model.\",\n\t\taccess: \"read\",\n\t\tinputSchema: timelineInputSchema,\n\t\toutputSchema: timelineSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(timelineInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn listTimeline({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t\tlimit: input.limit,\n\t\t\t\tcursor: input.cursor,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_ops_get_agent_run\",\n\t\tdescription: \"Fetch one stored agent run for an app, including status, phase, and summary metadata.\",\n\t\taccess: \"read\",\n\t\tinputSchema: agentRunInputSchema,\n\t\toutputSchema: agentRunSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(agentRunInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn getAgentRun({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t\trunId: input.runId,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_ops_list_agent_runs\",\n\t\tdescription: \"List paginated agent runs for one app so run ids can be discovered before deeper inspection.\",\n\t\taccess: \"read\",\n\t\tinputSchema: agentRunsInputSchema,\n\t\toutputSchema: agentRunsSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(agentRunsInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn listAgentRuns({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t\tlimit: input.limit,\n\t\t\t\toffset: input.offset,\n\t\t\t\tstatus: input.status,\n\t\t\t\tcurrentPhase: input.currentPhase,\n\t\t\t\tcreatedAfter: input.createdAfter,\n\t\t\t\tcreatedBefore: input.createdBefore,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_ops_list_agent_run_events\",\n\t\tdescription: \"List paginated agent-run events for one stored run, with optional time bounds.\",\n\t\taccess: \"read\",\n\t\tinputSchema: agentRunEventsInputSchema,\n\t\toutputSchema: agentRunEventsSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(agentRunEventsInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn listAgentRunEvents({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t\trunId: input.runId,\n\t\t\t\tlimit: input.limit,\n\t\t\t\toffset: input.offset,\n\t\t\t\tcreatedAfter: input.createdAfter,\n\t\t\t\tcreatedBefore: input.createdBefore,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_ops_get_sandbox_status\",\n\t\tdescription: \"Read safe sandbox metadata and the latest migration status for one app without exposing execution handles or secrets.\",\n\t\taccess: \"read\",\n\t\tinputSchema: appScopedInputSchema,\n\t\toutputSchema: sandboxStatusSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(appScopedInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn getSandboxStatus({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t});\n\t\t},\n\t});\n}\n","import { z } from \"zod\";\n\nimport { commonRequestFieldsSchema, makeSuccessSchema } from \"./common.js\";\n\nconst genericRecordSchema = z.record(z.string(), z.unknown());\nconst appJobKindSchema = z.enum([\n\t\"fork\",\n\t\"edit\",\n\t\"bundle\",\n\t\"import_github\",\n\t\"import_upload\",\n\t\"merge\",\n\t\"revert\",\n\t\"change_step\",\n\t\"reconcile\",\n\t\"change_step_replay\",\n]);\nconst appJobStatusSchema = z.enum([\"pending\", \"enqueued\", \"processing\", \"succeeded\", \"failed\", \"cancelled\"]);\n\nexport const appScopedInputSchema = {\n\t...commonRequestFieldsSchema,\n\tappId: z.string().trim().min(1).optional(),\n};\n\nexport const editQueueInputSchema = {\n\t...appScopedInputSchema,\n\tlimit: z.number().int().positive().max(100).optional(),\n\toffset: z.number().int().nonnegative().optional(),\n};\n\nexport const appJobQueueInputSchema = {\n\t...appScopedInputSchema,\n\tlimit: z.number().int().positive().max(100).optional(),\n\toffset: z.number().int().nonnegative().optional(),\n\tkind: z.array(appJobKindSchema).min(1).optional(),\n\tstatus: z.array(appJobStatusSchema).min(1).optional(),\n};\n\nexport const bundleInputSchema = {\n\t...appScopedInputSchema,\n\tbundleId: z.string().trim().min(1),\n};\n\nexport const timelineInputSchema = {\n\t...appScopedInputSchema,\n\tlimit: z.number().int().positive().max(100).optional(),\n\tcursor: z.string().trim().min(1).optional(),\n};\n\nexport const agentRunsInputSchema = {\n\t...appScopedInputSchema,\n\tlimit: z.number().int().positive().max(100).optional(),\n\toffset: z.number().int().nonnegative().optional(),\n\tstatus: z.string().trim().min(1).optional(),\n\tcurrentPhase: z.string().trim().min(1).optional(),\n\tcreatedAfter: z.string().datetime().optional(),\n\tcreatedBefore: z.string().datetime().optional(),\n};\n\nexport const agentRunInputSchema = {\n\t...appScopedInputSchema,\n\trunId: z.string().trim().min(1),\n};\n\nexport const agentRunEventsInputSchema = {\n\t...appScopedInputSchema,\n\trunId: z.string().trim().min(1),\n\tlimit: z.number().int().positive().max(100).optional(),\n\toffset: z.number().int().nonnegative().optional(),\n\tcreatedAfter: z.string().datetime().optional(),\n\tcreatedBefore: z.string().datetime().optional(),\n};\n\nexport const appOverviewSuccessSchema = makeSuccessSchema(genericRecordSchema);\nexport const editQueueSuccessSchema = makeSuccessSchema(genericRecordSchema);\nexport const appJobQueueSuccessSchema = makeSuccessSchema(genericRecordSchema);\nexport const bundleSuccessSchema = makeSuccessSchema(genericRecordSchema);\nexport const timelineSuccessSchema = makeSuccessSchema(genericRecordSchema);\nexport const agentRunsSuccessSchema = makeSuccessSchema(genericRecordSchema);\nexport const agentRunSuccessSchema = makeSuccessSchema(genericRecordSchema);\nexport const agentRunEventsSuccessSchema = makeSuccessSchema(genericRecordSchema);\nexport const sandboxStatusSuccessSchema = makeSuccessSchema(genericRecordSchema);\n","import type { ApiClient } from \"@remixhq/core\";\n\nimport { createApiClient } from \"./apiClient.js\";\nimport { loadBindingContext, makeNotBoundError, type ToolResult, unwrapResponseObject } from \"./shared.js\";\n\ntype JsonRecord = Record<string, any>;\n\nasync function resolveAppTarget(\n\t_api: ApiClient,\n\tparams: { appId?: string; cwd?: string },\n): Promise<{ appId: string; repoRoot: string | null }> {\n\tconst explicitAppId = params.appId?.trim();\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tif (explicitAppId) {\n\t\treturn {\n\t\t\tappId: explicitAppId,\n\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t};\n\t}\n\tif (!bindingContext.binding) {\n\t\tthrow makeNotBoundError(\"App id was not provided and the current repository is not bound to Remix.\");\n\t}\n\treturn {\n\t\tappId: bindingContext.binding.currentAppId,\n\t\trepoRoot: bindingContext.repoRoot,\n\t};\n}\n\nexport async function getAppOverview(params: { appId?: string; cwd?: string }): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(await api.getAppOverview(target.appId), \"app overview\");\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions: [\n\t\t\t\"Use `remix_ops_list_timeline`, `remix_ops_list_agent_runs`, `remix_ops_get_edit_queue`, `remix_ops_list_app_job_queue`, or `remix_ops_get_sandbox_status` for the next operational drill-down on this app.\",\n\t\t],\n\t\tlogContext: target,\n\t};\n}\n\nexport async function getEditQueue(params: {\n\tappId?: string;\n\tcwd?: string;\n\tlimit?: number;\n\toffset?: number;\n}): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(\n\t\tawait api.listAppEditQueue(target.appId, {\n\t\t\tlimit: params.limit,\n\t\t\toffset: params.offset,\n\t\t}),\n\t\t\"edit queue\",\n\t);\n\tconst pageInfo = typeof data.pageInfo === \"object\" && data.pageInfo ? (data.pageInfo as JsonRecord) : null;\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions:\n\t\t\tpageInfo?.hasMore === true && typeof pageInfo.limit === \"number\" && typeof pageInfo.offset === \"number\"\n\t\t\t\t? [`Pass offset=${pageInfo.offset + pageInfo.limit} to load the next edit queue page.`]\n\t\t\t\t: [],\n\t\tlogContext: target,\n\t};\n}\n\nexport async function listAppJobQueue(params: {\n\tappId?: string;\n\tcwd?: string;\n\tlimit?: number;\n\toffset?: number;\n\tkind?: string[];\n\tstatus?: string[];\n}): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(\n\t\tawait api.listAppJobQueue(target.appId, {\n\t\t\tlimit: params.limit,\n\t\t\toffset: params.offset,\n\t\t\tkind: params.kind,\n\t\t\tstatus: params.status,\n\t\t}),\n\t\t\"app job queue\",\n\t);\n\tconst pageInfo = typeof data.pageInfo === \"object\" && data.pageInfo ? (data.pageInfo as JsonRecord) : null;\n\tconst items = Array.isArray(data.items) ? data.items : [];\n\tconst activeBlockingKinds = new Set([\"merge\", \"change_step\", \"change_step_replay\", \"reconcile\", \"revert\"]);\n\tconst hasBlockingJobs = items.some((item) => {\n\t\tif (!item || typeof item !== \"object\") return false;\n\t\tconst record = item as JsonRecord;\n\t\treturn (\n\t\t\ttypeof record.kind === \"string\" &&\n\t\t\tactiveBlockingKinds.has(record.kind) &&\n\t\t\t(typeof record.status !== \"string\" || [\"pending\", \"enqueued\", \"processing\"].includes(record.status))\n\t\t);\n\t});\n\tconst recommendedNextActions: string[] = [];\n\tif (hasBlockingJobs) {\n\t\trecommendedNextActions.push(\n\t\t\t\"Inspect the returned active workflow jobs before concluding that merge, replay, reconcile, or revert work is stuck. This surface reflects backend app-scoped queue state, not local finalize state.\",\n\t\t);\n\t}\n\tif (pageInfo?.hasMore === true && typeof pageInfo.limit === \"number\" && typeof pageInfo.offset === \"number\") {\n\t\trecommendedNextActions.push(`Pass offset=${pageInfo.offset + pageInfo.limit} to load the next app job queue page.`);\n\t}\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions,\n\t\tlogContext: target,\n\t};\n}\n\nexport async function getBundle(params: {\n\tappId?: string;\n\tcwd?: string;\n\tbundleId: string;\n}): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(await api.getBundle(target.appId, params.bundleId), \"bundle\");\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions: [\"Use the bundle download-url client methods only when you need the actual artifact, not just metadata inspection.\"],\n\t\tlogContext: target,\n\t};\n}\n\nexport async function listTimeline(params: {\n\tappId?: string;\n\tcwd?: string;\n\tlimit?: number;\n\tcursor?: string;\n}): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(\n\t\tawait api.listAppTimeline(target.appId, {\n\t\t\tlimit: params.limit,\n\t\t\tcursor: params.cursor,\n\t\t}),\n\t\t\"app timeline\",\n\t);\n\tconst pageInfo = typeof data.pageInfo === \"object\" && data.pageInfo ? (data.pageInfo as JsonRecord) : null;\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions:\n\t\t\tpageInfo?.hasMore === true && typeof pageInfo.nextCursor === \"string\"\n\t\t\t\t? [`Pass cursor=${pageInfo.nextCursor} to load the next timeline page.`]\n\t\t\t\t: [],\n\t\tlogContext: target,\n\t};\n}\n\nexport async function listAgentRuns(params: {\n\tappId?: string;\n\tcwd?: string;\n\tlimit?: number;\n\toffset?: number;\n\tstatus?: string;\n\tcurrentPhase?: string;\n\tcreatedAfter?: string;\n\tcreatedBefore?: string;\n}): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(\n\t\tawait api.listAgentRuns(target.appId, {\n\t\t\tlimit: params.limit,\n\t\t\toffset: params.offset,\n\t\t\tstatus: params.status,\n\t\t\tcurrentPhase: params.currentPhase,\n\t\t\tcreatedAfter: params.createdAfter,\n\t\t\tcreatedBefore: params.createdBefore,\n\t\t}),\n\t\t\"agent runs\",\n\t);\n\tconst pageInfo = typeof data.pageInfo === \"object\" && data.pageInfo ? (data.pageInfo as JsonRecord) : null;\n\tconst items = Array.isArray(data.items) ? data.items : [];\n\tconst firstRunId =\n\t\titems.length > 0 && items[0] && typeof items[0] === \"object\" && typeof (items[0] as JsonRecord).id === \"string\"\n\t\t\t? ((items[0] as JsonRecord).id as string)\n\t\t\t: null;\n\tconst recommendedNextActions: string[] = [];\n\tif (firstRunId) {\n\t\trecommendedNextActions.push(\n\t\t\t`Use \\`remix_ops_get_agent_run\\` with \\`runId=${firstRunId}\\` for the top listed run, then \\`remix_ops_list_agent_run_events\\` if you need its event stream.`,\n\t\t);\n\t}\n\tif (pageInfo?.hasMore === true && typeof pageInfo.limit === \"number\" && typeof pageInfo.offset === \"number\") {\n\t\trecommendedNextActions.push(`Pass offset=${pageInfo.offset + pageInfo.limit} to load the next agent-runs page.`);\n\t}\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions,\n\t\tlogContext: target,\n\t};\n}\n\nexport async function getAgentRun(params: {\n\tappId?: string;\n\tcwd?: string;\n\trunId: string;\n}): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(await api.getAgentRun(target.appId, params.runId), \"agent run\");\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions: [`Use \\`remix_ops_list_agent_run_events\\` with \\`runId=${params.runId}\\` for the event stream behind this run.`],\n\t\tlogContext: target,\n\t};\n}\n\nexport async function listAgentRunEvents(params: {\n\tappId?: string;\n\tcwd?: string;\n\trunId: string;\n\tlimit?: number;\n\toffset?: number;\n\tcreatedAfter?: string;\n\tcreatedBefore?: string;\n}): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(\n\t\tawait api.listAgentRunEvents(target.appId, params.runId, {\n\t\t\tlimit: params.limit,\n\t\t\toffset: params.offset,\n\t\t\tcreatedAfter: params.createdAfter,\n\t\t\tcreatedBefore: params.createdBefore,\n\t\t}),\n\t\t\"agent run events\",\n\t);\n\tconst pageInfo = typeof data.pageInfo === \"object\" && data.pageInfo ? (data.pageInfo as JsonRecord) : null;\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions:\n\t\t\tpageInfo?.hasMore === true && typeof pageInfo.limit === \"number\" && typeof pageInfo.offset === \"number\"\n\t\t\t\t? [`Pass offset=${pageInfo.offset + pageInfo.limit} to load the next event page.`]\n\t\t\t\t: [],\n\t\tlogContext: target,\n\t};\n}\n\nexport async function getSandboxStatus(params: { appId?: string; cwd?: string }): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(await api.getSandboxStatus(target.appId), \"sandbox status\");\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions: [\"Use the sandbox metadata here to decide whether a resume is plausible before attempting any write-side sandbox action.\"],\n\t\tlogContext: target,\n\t};\n}\n"],"mappings":";;;AAAA,SAAS,qBAAqB;AAE9B,SAAS,iCAAiC;;;ACF1C,SAAS,mBAAmB,qBAAqB,iBAAAA,sBAAqC;;;ACAtF,SAAS,yBAAyB,kCAAkC,2BAA2B,qBAAsC;AAGrI,eAAsB,yBAAyB,QAA6C;AAC1F,QAAM,iBAAiB,UAAW,MAAM,cAAc;AACtD,QAAM,eAAe,wBAAwB;AAC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,QAAQ,IAAIA,SAAQ,iBAAiB;AAE7C,eAAe,OAAsB;AACnC,MAAI,QAAQ,KAAK,SAAS,wBAAwB,GAAG;AACnD,UAAM,MAAM,MAAM,sBAAsB;AACxC,UAAM,0BAA0B,EAAE,IAAI,CAAC;AACvC;AAAA,EACF;AACA,QAAM,iBAAiB,EAAE,QAAQ,CAAC;AACpC;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,QAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,UAAQ,OAAO,MAAM,GAAG,OAAO;AAAA,CAAI;AACnC,UAAQ,WAAW;AACrB,CAAC;","names":["resolveConfig","resolveConfig","z","z","z","findGitRoot","findGitRoot","parseJsonObject","project","organizationId","z","z","z","genericRecordSchema","z","genericArraySchema","paginationSchema","normalizePagination","bindingContext","resolveAppAccessSource","listApps","getAnnotations","buildSuccessEnvelope","deriveErrorRisks","buildErrorEnvelope","registerTool","z","listApps","z","z","genericRecordSchema","z","genericArraySchema","paginationSchema","readCollabBinding","findGitRoot","unwrapResponseObject","makeNotBoundError","maybeFindGitRoot","findGitRoot","readCollabBinding","getAnnotations","buildSuccessEnvelope","buildErrorEnvelope","deriveErrorRisks","registerTool","z","z","z","genericRecordSchema","z","getAnnotations","buildSuccessEnvelope","deriveErrorRisks","buildErrorEnvelope","registerTool","z","require"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/domain/apiClient.ts","../src/bootstrap/auth.ts","../src/server.ts","../src/observability/logger.ts","../src/policy/policy.ts","../src/errors/normalizeError.ts","../src/errors/errorCodes.ts","../src/bootstrap/context.ts","../src/tools/collab/register.ts","../src/contracts/collab.ts","../src/contracts/common.ts","../src/domain/coreAdapter.ts","../src/domain/shared.ts","../src/domain/collabAdminAdapter.ts","../src/tools/collab/autoSpawnHistoryImport.ts","../src/tools/identity/register.ts","../src/contracts/identity.ts","../src/domain/directoryAdapter.ts","../src/tools/memory/register.ts","../src/contracts/memory.ts","../src/domain/memoryAdapter.ts","../src/tools/ops/register.ts","../src/contracts/ops.ts","../src/domain/opsAdapter.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\n\nimport { drainAsyncJobs, drainPendingFinalizeQueue } from \"@remixhq/core/collab\";\n\nimport { createCollabApiClient } from \"./domain/apiClient.js\";\nimport { startStdioServer } from \"./server.js\";\n\nconst require = createRequire(import.meta.url);\nconst { version } = require(\"../package.json\") as { version: string };\n\nasync function main(): Promise<void> {\n if (process.argv.includes(\"--drain-finalize-queue\")) {\n const api = await createCollabApiClient();\n await drainPendingFinalizeQueue({ api });\n return;\n }\n if (process.argv.includes(\"--drain-async-jobs\")) {\n const api = await createCollabApiClient();\n await drainAsyncJobs({ api });\n return;\n }\n await startStdioServer({ version });\n}\n\nmain().catch((error) => {\n const message = error instanceof Error ? error.message : String(error);\n process.stderr.write(`${message}\\n`);\n process.exitCode = 1;\n});\n","import { createApiClient as createCoreApiClient, resolveConfig, type ApiClient } from \"@remixhq/core\";\nimport type { CollabApiClient } from \"@remixhq/core/collab\";\n\nimport { createRemixTokenProvider } from \"../bootstrap/auth.js\";\n\nexport async function createCollabApiClient(): Promise<CollabApiClient> {\n const config = await resolveConfig();\n const tokenProvider = await createRemixTokenProvider(config);\n const api = createCoreApiClient(config, {\n tokenProvider,\n });\n return api as unknown as CollabApiClient;\n}\n\nexport async function createApiClient(): Promise<ApiClient> {\n const config = await resolveConfig();\n const tokenProvider = await createRemixTokenProvider(config);\n return createCoreApiClient(config, {\n tokenProvider,\n });\n}\n","import { createLocalSessionStore, createStoredSessionTokenProvider, createSupabaseAuthHelpers, resolveConfig, type CoreConfig } from \"@remixhq/core\";\nimport type { TokenProvider } from \"@remixhq/core/auth\";\n\nexport async function createRemixTokenProvider(config?: CoreConfig): Promise<TokenProvider> {\n const resolvedConfig = config ?? (await resolveConfig());\n const sessionStore = createLocalSessionStore();\n return createStoredSessionTokenProvider({\n config: resolvedConfig,\n sessionStore,\n refreshStoredSession: async ({ config: refreshConfig, session }) => {\n const supabase = createSupabaseAuthHelpers(refreshConfig);\n return supabase.refreshWithStoredSession({ session });\n },\n });\n}\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\n\nimport { createServerContext } from \"./bootstrap/context.js\";\nimport { registerCollabTools } from \"./tools/collab/register.js\";\nimport { registerIdentityTools } from \"./tools/identity/register.js\";\nimport { registerMemoryTools } from \"./tools/memory/register.js\";\nimport { registerOpsTools } from \"./tools/ops/register.js\";\n\nexport function createRemixMcpServer(params: { version: string }) {\n const context = createServerContext({ version: params.version });\n const server = new McpServer({\n name: context.serverName,\n version: context.version,\n });\n\n registerIdentityTools(server, context);\n registerCollabTools(server, context);\n registerOpsTools(server, context);\n registerMemoryTools(server, context);\n\n return { server, context };\n}\n\nexport async function startStdioServer(params: { version: string }): Promise<void> {\n const { server } = createRemixMcpServer(params);\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n","export type LogLevel = \"info\" | \"error\";\n\nexport type LogEvent = {\n level: LogLevel;\n message: string;\n tool?: string;\n requestId?: string | null;\n durationMs?: number;\n result?: \"success\" | \"error\";\n errorCode?: string | null;\n repoRoot?: string | null;\n appId?: string | null;\n mrId?: string | null;\n truncated?: boolean;\n};\n\nexport type Logger = {\n log(event: LogEvent): void;\n};\n\nexport function createLogger(): Logger {\n return {\n log(event) {\n const payload = {\n timestamp: new Date().toISOString(),\n ...event,\n };\n const line = JSON.stringify(payload);\n if (event.level === \"error\") {\n process.stderr.write(`${line}\\n`);\n return;\n }\n process.stderr.write(`${line}\\n`);\n },\n };\n}\n","import path from \"node:path\";\n\nimport { createPolicyError } from \"../errors/normalizeError.js\";\n\nexport type ToolAccess = \"read\" | \"remote_write\" | \"local_write\";\n\nexport type Policy = {\n allowLocalWrite: boolean;\n allowRemoteWrite: boolean;\n allowedRepoRoots: string[] | null;\n maxDiffBytes: number;\n maxDiffOutputChars: number;\n};\n\nfunction parseBooleanEnv(name: string, fallback: boolean): boolean {\n const raw = process.env[name];\n if (!raw) return fallback;\n const normalized = raw.trim().toLowerCase();\n return normalized === \"1\" || normalized === \"true\" || normalized === \"yes\" || normalized === \"on\";\n}\n\nfunction parsePositiveIntEnv(name: string, fallback: number): number {\n const raw = process.env[name];\n if (!raw) return fallback;\n const parsed = Number.parseInt(raw, 10);\n return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;\n}\n\nfunction parseAllowedRoots(raw: string | undefined): string[] | null {\n if (!raw) return null;\n const roots = raw\n .split(path.delimiter)\n .map((entry) => entry.trim())\n .filter(Boolean)\n .map((entry) => path.resolve(entry));\n return roots.length > 0 ? roots : null;\n}\n\nfunction isWithinRoot(root: string, candidate: string): boolean {\n const relative = path.relative(root, candidate);\n return relative === \"\" || (!relative.startsWith(\"..\") && !path.isAbsolute(relative));\n}\n\nexport function loadPolicy(): Policy {\n return {\n allowLocalWrite: parseBooleanEnv(\"COMERGE_MCP_ALLOW_LOCAL_WRITE\", true),\n allowRemoteWrite: parseBooleanEnv(\"COMERGE_MCP_ALLOW_REMOTE_WRITE\", true),\n allowedRepoRoots: parseAllowedRoots(process.env.COMERGE_MCP_ALLOWED_REPO_ROOTS),\n maxDiffBytes: parsePositiveIntEnv(\"COMERGE_MCP_MAX_DIFF_BYTES\", 1024 * 1024),\n maxDiffOutputChars: parsePositiveIntEnv(\"COMERGE_MCP_MAX_DIFF_OUTPUT_CHARS\", 20_000),\n };\n}\n\nexport function resolvePolicyCwd(policy: Policy, cwd: string | undefined): string {\n const resolved = path.resolve(cwd?.trim() || process.cwd());\n if (!policy.allowedRepoRoots) return resolved;\n if (policy.allowedRepoRoots.some((root) => isWithinRoot(root, resolved))) return resolved;\n throw createPolicyError(\"Requested working directory is outside the allowed repository roots.\", resolved);\n}\n\nexport function assertToolAccess(policy: Policy, access: ToolAccess): void {\n if (access === \"read\") return;\n if (access === \"remote_write\" && !policy.allowRemoteWrite) {\n throw createPolicyError(\"Remote-mutating Remix tools are disabled by policy.\");\n }\n if (access === \"local_write\" && !policy.allowLocalWrite) {\n throw createPolicyError(\"Local-mutating Remix tools are disabled by policy.\");\n }\n}\n\nexport function assertConfirm(confirm: boolean | undefined, operation: string): void {\n if (confirm) return;\n throw createPolicyError(`${operation} requires explicit confirmation.`, \"Pass confirm=true to run this tool.\");\n}\n\nexport function assertDiffWithinLimit(policy: Policy, diff: string): void {\n const sizeBytes = Buffer.byteLength(diff, \"utf8\");\n if (sizeBytes <= policy.maxDiffBytes) return;\n throw createPolicyError(\n \"Diff exceeds the configured maximum size for Remix MCP.\",\n `Configured limit=${policy.maxDiffBytes} bytes actual=${sizeBytes} bytes.`,\n );\n}\n\nexport function truncateText(policy: Policy, value: string): { value: string; truncated: boolean; originalChars: number } {\n const originalChars = value.length;\n if (originalChars <= policy.maxDiffOutputChars) {\n return { value, truncated: false, originalChars };\n }\n return {\n value: `${value.slice(0, policy.maxDiffOutputChars)}\\n\\n[truncated ${originalChars - policy.maxDiffOutputChars} chars]`,\n truncated: true,\n originalChars,\n };\n}\n","import { ZodError } from \"zod\";\n\nimport { ERROR_CODES, type ErrorCategory, type ErrorCode, type NormalizedToolError, RemixMcpError } from \"./errorCodes.js\";\n\ntype ErrorLike = {\n code?: unknown;\n message?: unknown;\n hint?: unknown;\n exitCode?: unknown;\n};\n\nfunction toStringOrNull(value: unknown): string | null {\n if (typeof value !== \"string\") return null;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : null;\n}\n\nfunction parseJsonObject(value: string | null): Record<string, unknown> | null {\n if (!value) return null;\n try {\n const parsed = JSON.parse(value);\n return parsed && typeof parsed === \"object\" ? (parsed as Record<string, unknown>) : null;\n } catch {\n return null;\n }\n}\n\nfunction makeNormalized(params: {\n code: ErrorCode;\n message: string;\n hint?: string | null;\n retryable?: boolean;\n category: ErrorCategory;\n}): NormalizedToolError {\n return {\n code: params.code,\n message: params.message,\n hint: params.hint ?? null,\n retryable: params.retryable ?? false,\n category: params.category,\n };\n}\n\nfunction normalizeByMessage(err: ErrorLike): NormalizedToolError {\n const code = toStringOrNull(err.code);\n const message = toStringOrNull(err.message) ?? \"Unexpected error.\";\n const hint = toStringOrNull(err.hint);\n const hintBody = parseJsonObject(hint);\n const statusCode =\n typeof hintBody?.statusCode === \"number\"\n ? hintBody.statusCode\n : typeof hintBody?.statusCode === \"string\"\n ? Number(hintBody.statusCode)\n : null;\n\n if (code === ERROR_CODES.REPO_LOCK_HELD) {\n return makeNormalized({\n code: ERROR_CODES.REPO_LOCK_HELD,\n message,\n hint,\n retryable: true,\n category: \"local_state\",\n });\n }\n\n if (code === ERROR_CODES.REPO_LOCK_TIMEOUT) {\n return makeNormalized({\n code: ERROR_CODES.REPO_LOCK_TIMEOUT,\n message,\n hint,\n retryable: true,\n category: \"local_state\",\n });\n }\n\n if (code === ERROR_CODES.REPO_STATE_CHANGED_DURING_OPERATION) {\n return makeNormalized({\n code: ERROR_CODES.REPO_STATE_CHANGED_DURING_OPERATION,\n message,\n hint,\n retryable: true,\n category: \"local_state\",\n });\n }\n\n if (code === ERROR_CODES.REPO_LOCK_STALE_RECOVERED) {\n return makeNormalized({\n code: ERROR_CODES.REPO_LOCK_STALE_RECOVERED,\n message,\n hint,\n retryable: true,\n category: \"local_state\",\n });\n }\n\n if (message === \"Not signed in.\") {\n return makeNormalized({\n code: ERROR_CODES.AUTH_REQUIRED,\n message,\n hint,\n category: \"auth\",\n });\n }\n\n if (message === \"Not inside a git repository.\") {\n return makeNormalized({\n code: ERROR_CODES.NOT_GIT_REPO,\n message,\n hint,\n category: \"local_state\",\n });\n }\n\n if (message === \"Repository is not bound to Remix.\") {\n return makeNormalized({\n code: ERROR_CODES.NOT_BOUND,\n message,\n hint,\n category: \"local_state\",\n });\n }\n\n if (message.includes(\"Working tree must be clean\")) {\n return makeNormalized({\n code: ERROR_CODES.DIRTY_WORKTREE,\n message,\n hint,\n category: \"local_state\",\n });\n }\n\n if (message.includes(\"requires a checked out local branch\") || message.includes(\"detached HEAD\")) {\n return makeNormalized({\n code: ERROR_CODES.DETACHED_HEAD,\n message,\n hint,\n category: \"local_state\",\n });\n }\n\n if (code === ERROR_CODES.PREFERRED_BRANCH_MISMATCH || message.includes(\"preferred branch\") || message.includes(\"bound branch\")) {\n return makeNormalized({\n code: ERROR_CODES.PREFERRED_BRANCH_MISMATCH,\n message,\n hint,\n category: \"local_state\",\n });\n }\n\n if (message.includes(\"Multiple canonical Remix families\") || message.includes(\"family selection is ambiguous\")) {\n return makeNormalized({\n code: ERROR_CODES.FAMILY_SELECTION_AMBIGUOUS,\n message,\n hint,\n category: \"local_state\",\n });\n }\n\n if (message.includes(\"Failed to resolve local HEAD\")) {\n return makeNormalized({\n code: ERROR_CODES.MISSING_HEAD,\n message,\n hint,\n category: \"local_state\",\n });\n }\n\n if (message.includes(\"metadata conflicts with the bound Remix app\") || message.includes(\"manual intervention\")) {\n return makeNormalized({\n code: ERROR_CODES.METADATA_CONFLICT,\n message,\n hint,\n category: \"remote_state\",\n });\n }\n\n if (statusCode === 403) {\n return makeNormalized({\n code: ERROR_CODES.ACCESS_DENIED,\n message,\n hint,\n category: \"remote_state\",\n });\n }\n\n if (statusCode === 404) {\n return makeNormalized({\n code: ERROR_CODES.RESOURCE_NOT_FOUND,\n message,\n hint,\n category: \"remote_state\",\n });\n }\n\n if (message.includes(\"Timed out\") || message.includes(\"failed\") || message.includes(\"error state\")) {\n return makeNormalized({\n code: ERROR_CODES.REMOTE_ERROR,\n message,\n hint,\n retryable: true,\n category: \"remote_state\",\n });\n }\n\n return makeNormalized({\n code: ERROR_CODES.INTERNAL_ERROR,\n message,\n hint,\n retryable: true,\n category: \"internal\",\n });\n}\n\nexport function createPolicyError(message: string, hint?: string | null): RemixMcpError {\n return new RemixMcpError(\n makeNormalized({\n code: ERROR_CODES.DESTRUCTIVE_OPERATION_BLOCKED,\n message,\n hint,\n category: \"policy\",\n }),\n );\n}\n\nexport function createAuthRequiredError(hint?: string | null): RemixMcpError {\n return new RemixMcpError(\n makeNormalized({\n code: ERROR_CODES.AUTH_REQUIRED,\n message: \"COMERGE_ACCESS_TOKEN is required.\",\n hint: hint ?? \"Set COMERGE_ACCESS_TOKEN before using Remix MCP tools that call the backend.\",\n category: \"auth\",\n }),\n );\n}\n\nexport function normalizeToolError(error: unknown): NormalizedToolError {\n if (error instanceof RemixMcpError) {\n return error.normalized;\n }\n\n if (error instanceof ZodError) {\n return makeNormalized({\n code: ERROR_CODES.INVALID_INPUT,\n message: \"Tool arguments failed validation.\",\n hint: error.issues.map((issue) => `${issue.path.join(\".\") || \"input\"}: ${issue.message}`).join(\"; \"),\n category: \"validation\",\n });\n }\n\n if (error && typeof error === \"object\") {\n return normalizeByMessage(error as ErrorLike);\n }\n\n return makeNormalized({\n code: ERROR_CODES.INTERNAL_ERROR,\n message: typeof error === \"string\" && error.trim() ? error.trim() : \"Unexpected error.\",\n hint: null,\n retryable: true,\n category: \"internal\",\n });\n}\n","export const ERROR_CODES = {\n AUTH_REQUIRED: \"AUTH_REQUIRED\",\n INVALID_INPUT: \"INVALID_INPUT\",\n NOT_GIT_REPO: \"NOT_GIT_REPO\",\n NOT_BOUND: \"NOT_BOUND\",\n DIRTY_WORKTREE: \"DIRTY_WORKTREE\",\n DETACHED_HEAD: \"DETACHED_HEAD\",\n PREFERRED_BRANCH_MISMATCH: \"PREFERRED_BRANCH_MISMATCH\",\n FAMILY_SELECTION_AMBIGUOUS: \"FAMILY_SELECTION_AMBIGUOUS\",\n MISSING_HEAD: \"MISSING_HEAD\",\n REPO_LOCK_HELD: \"REPO_LOCK_HELD\",\n REPO_LOCK_TIMEOUT: \"REPO_LOCK_TIMEOUT\",\n REPO_LOCK_STALE_RECOVERED: \"REPO_LOCK_STALE_RECOVERED\",\n REPO_STATE_CHANGED_DURING_OPERATION: \"REPO_STATE_CHANGED_DURING_OPERATION\",\n REMOTE_ERROR: \"REMOTE_ERROR\",\n METADATA_CONFLICT: \"METADATA_CONFLICT\",\n DESTRUCTIVE_OPERATION_BLOCKED: \"DESTRUCTIVE_OPERATION_BLOCKED\",\n CONFIG_INVALID: \"CONFIG_INVALID\",\n ACCESS_DENIED: \"ACCESS_DENIED\",\n RESOURCE_NOT_FOUND: \"RESOURCE_NOT_FOUND\",\n INTERNAL_ERROR: \"INTERNAL_ERROR\",\n} as const;\n\nexport type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];\n\nexport type ErrorCategory = \"auth\" | \"validation\" | \"local_state\" | \"remote_state\" | \"policy\" | \"config\" | \"internal\";\n\nexport type NormalizedToolError = {\n code: ErrorCode;\n message: string;\n hint: string | null;\n retryable: boolean;\n category: ErrorCategory;\n};\n\nexport class RemixMcpError extends Error {\n public readonly normalized: NormalizedToolError;\n\n constructor(normalized: NormalizedToolError) {\n super(normalized.message);\n this.name = \"RemixMcpError\";\n this.normalized = normalized;\n }\n}\n","import type { CollabApiClient } from \"@remixhq/core/collab\";\n\nimport { createCollabApiClient } from \"../domain/apiClient.js\";\nimport { createLogger, type Logger } from \"../observability/logger.js\";\nimport { loadPolicy, type Policy } from \"../policy/policy.js\";\n\nexport type ServerContext = {\n serverName: string;\n version: string;\n policy: Policy;\n logger: Logger;\n getCollabApiClient(): Promise<CollabApiClient>;\n agentMetadata: {\n type: string;\n name?: string;\n version?: string;\n provider?: string;\n };\n};\n\nexport function createServerContext(params: { version: string }): ServerContext {\n return {\n serverName: \"remix-mcp\",\n version: params.version,\n policy: loadPolicy(),\n logger: createLogger(),\n getCollabApiClient: () => createCollabApiClient(),\n agentMetadata: {\n type: process.env.COMERGE_AGENT_TYPE?.trim() || \"agent\",\n name: process.env.COMERGE_AGENT_NAME?.trim() || \"remix-mcp\",\n version: process.env.COMERGE_AGENT_VERSION?.trim() || params.version,\n provider: process.env.COMERGE_AGENT_PROVIDER?.trim() || \"remix\",\n },\n };\n}\n","import { z } from \"zod\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { ToolAnnotations } from \"@modelcontextprotocol/sdk/types.js\";\n\nimport type { ServerContext } from \"../../bootstrap/context.js\";\nimport {\n drainFinalizeQueueInputSchema,\n drainFinalizeQueueSuccessSchema,\n finalizeTurnInputSchema,\n finalizeTurnSuccessSchema,\n accessDebugInputSchema,\n accessDebugSuccessSchema,\n acceptInvitationInputSchema,\n acceptInvitationSuccessSchema,\n approveInputSchema,\n approveSuccessSchema,\n appMergeRequestsInputSchema,\n checkoutInputSchema,\n checkoutSuccessSchema,\n initInputSchema,\n initSuccessSchema,\n listMembersInputSchema,\n listMembersSuccessSchema,\n inviteInputSchema,\n inviteSuccessSchema,\n reAnchorInputSchema,\n reAnchorSuccessSchema,\n listInputSchema,\n listInvitesInputSchema,\n listInvitesSuccessSchema,\n listSuccessSchema,\n mergeRequestQueueSuccessSchema,\n myMergeRequestsInputSchema,\n previewInputSchema,\n reconcileSuccessSchema,\n rejectInputSchema,\n rejectSuccessSchema,\n resendInviteInputSchema,\n resendInviteSuccessSchema,\n remixInputSchema,\n revokeInviteInputSchema,\n revokeInviteSuccessSchema,\n updateMemberRoleInputSchema,\n updateMemberRoleSuccessSchema,\n reviewQueueInputSchema,\n remixSuccessSchema,\n requestMergeInputSchema,\n requestMergeSuccessSchema,\n statusInputSchema,\n statusSuccessSchema,\n syncSuccessSchema,\n syncUpstreamSuccessSchema,\n viewMergeRequestInputSchema,\n viewMergeRequestSuccessSchema,\n applyInputSchema,\n} from \"../../contracts/collab.js\";\nimport { makeErrorResult, makeErrorSchema, makeSuccessResult, type ErrorEnvelope, type SuccessEnvelope, SCHEMA_VERSION } from \"../../contracts/common.js\";\nimport type { NormalizedToolError } from \"../../errors/errorCodes.js\";\nimport { normalizeToolError } from \"../../errors/normalizeError.js\";\nimport {\n drainFinalizeQueue,\n finalizeCollabTurn,\n approveMergeRequest,\n checkoutCollab,\n getStatus,\n initCollab,\n reAnchor,\n inviteCollaborator,\n listMembers,\n listAppMergeRequests,\n listApps,\n myMergeRequests,\n reconcile,\n rejectMergeRequest,\n remixCollab,\n reviewQueue,\n requestMerge,\n syncCollab,\n syncUpstream,\n updateMemberRole,\n viewMergeRequest,\n} from \"../../domain/coreAdapter.js\";\nimport {\n accessDebug as accessDebugRead,\n acceptInvitation as acceptInvitationByToken,\n listInvites as listScopeInvites,\n resendInvite as resendScopedInvite,\n revokeInvite as revokeScopedInvite,\n} from \"../../domain/collabAdminAdapter.js\";\nimport { assertConfirm, assertToolAccess, resolvePolicyCwd, type ToolAccess } from \"../../policy/policy.js\";\nimport {\n shouldAutoSpawnHistoryImport,\n spawnHistoryImportDetached,\n} from \"./autoSpawnHistoryImport.js\";\n\ntype ToolExecutionResult<T> = {\n data: T;\n warnings?: string[];\n risks?: string[];\n recommendedNextActions?: string[];\n logContext?: {\n repoRoot?: string | null;\n appId?: string | null;\n mrId?: string | null;\n };\n};\n\nfunction getAnnotations(access: ToolAccess, options?: { idempotent?: boolean }): ToolAnnotations {\n if (access === \"read\") {\n return {\n readOnlyHint: true,\n idempotentHint: true,\n openWorldHint: false,\n };\n }\n return {\n readOnlyHint: false,\n destructiveHint: access === \"local_write\",\n idempotentHint: options?.idempotent ?? false,\n openWorldHint: false,\n };\n}\n\nfunction buildSuccessEnvelope<T>(tool: string, requestId: string | undefined, result: ToolExecutionResult<T>): SuccessEnvelope<T> {\n return {\n schemaVersion: SCHEMA_VERSION,\n ok: true,\n tool,\n requestId: requestId ?? null,\n data: result.data,\n warnings: result.warnings ?? [],\n risks: result.risks ?? [],\n recommendedNextActions: result.recommendedNextActions ?? [],\n };\n}\n\nfunction deriveErrorRisks(tool: string, normalized: NormalizedToolError): string[] {\n if (normalized.code === \"DESTRUCTIVE_OPERATION_BLOCKED\") {\n return [\"A policy guard blocked a potentially destructive or state-mutating operation.\"];\n }\n if (normalized.code === \"REPO_LOCK_TIMEOUT\") {\n return [\"Another Remix mutation was already in progress for this repository, so the local mutation did not run.\"];\n }\n if (normalized.code === \"REPO_STATE_CHANGED_DURING_OPERATION\") {\n return [\"The repository changed during the operation, so Remix aborted before applying a destructive local mutation.\"];\n }\n return [];\n}\n\nfunction buildErrorEnvelope(tool: string, requestId: string | undefined, error: unknown): ErrorEnvelope {\n const normalized = normalizeToolError(error);\n const recommendedNextActions =\n normalized.code === \"AUTH_REQUIRED\"\n ? [\"Set COMERGE_ACCESS_TOKEN, then retry the tool call.\"]\n : normalized.code === \"REPO_LOCK_TIMEOUT\"\n ? [\"Wait for the active Remix mutation to finish, then retry the tool call.\"]\n : normalized.code === \"REPO_STATE_CHANGED_DURING_OPERATION\"\n ? [\"Review local repository changes, then rerun the tool once the worktree is stable.\"]\n : normalized.code === \"PREFERRED_BRANCH_MISMATCH\"\n ? [\"Switch to the repository's preferred Remix branch, or rerun with allowBranchMismatch=true if intentional.\"]\n : [];\n return {\n schemaVersion: SCHEMA_VERSION,\n ok: false,\n tool,\n requestId: requestId ?? null,\n error: normalized,\n warnings: [],\n risks: deriveErrorRisks(tool, normalized),\n recommendedNextActions,\n };\n}\n\nfunction registerTool<T>(\n server: McpServer,\n context: ServerContext,\n params: {\n name: string;\n description: string;\n access: ToolAccess;\n annotations?: ToolAnnotations;\n inputSchema: Record<string, z.ZodTypeAny>;\n outputSchema: z.ZodTypeAny;\n run: (args: Record<string, unknown>) => Promise<ToolExecutionResult<T>>;\n },\n) {\n const errorSchema = makeErrorSchema();\n server.registerTool(\n params.name,\n {\n title: params.name,\n description: params.description,\n inputSchema: params.inputSchema,\n outputSchema: params.outputSchema,\n annotations: params.annotations ?? getAnnotations(params.access),\n },\n async (rawArgs: Record<string, unknown>) => {\n const requestId = typeof rawArgs.requestId === \"string\" ? rawArgs.requestId : undefined;\n const startedAt = Date.now();\n try {\n assertToolAccess(context.policy, params.access);\n const result = await params.run(rawArgs);\n const envelope = buildSuccessEnvelope(params.name, requestId, result);\n params.outputSchema.parse(envelope);\n context.logger.log({\n level: \"info\",\n message: \"tool_completed\",\n tool: params.name,\n requestId: envelope.requestId,\n durationMs: Date.now() - startedAt,\n result: \"success\",\n repoRoot: result.logContext?.repoRoot ?? null,\n appId: result.logContext?.appId ?? null,\n mrId: result.logContext?.mrId ?? null,\n truncated: result.warnings?.some((warning) => warning.toLowerCase().includes(\"truncated\")) ?? false,\n });\n return makeSuccessResult(envelope);\n } catch (error) {\n const envelope = buildErrorEnvelope(params.name, requestId, error);\n errorSchema.parse(envelope);\n context.logger.log({\n level: \"error\",\n message: \"tool_failed\",\n tool: params.name,\n requestId: envelope.requestId,\n durationMs: Date.now() - startedAt,\n result: \"error\",\n errorCode: envelope.error.code,\n });\n return makeErrorResult(envelope);\n }\n },\n );\n}\n\nexport function registerCollabTools(server: McpServer, context: ServerContext): void {\n registerTool(server, context, {\n name: \"remix_collab_status\",\n description: \"Required first read for a bound repository: summarize binding, worktree state, merge request counts, and sync or reconcile readiness before Remix mutations.\",\n access: \"read\",\n inputSchema: statusInputSchema,\n outputSchema: statusSuccessSchema,\n run: async (args) => {\n const input = z.object(statusInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return getStatus({\n cwd,\n includeRemote: input.includeRemote ?? true,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_init\",\n description:\n \"Import the current repository into Remix and write the local binding file. Synchronous: by the time this tool resolves, the local binding file AND the local Remix baseline are both on disk, so the very next call to remix_collab_finalize_turn will succeed. Brand-new init on the default branch typically takes ~10s; non-default-branch init can take 30-90s while the server provisions a feature lane. The result includes `reused: boolean` (false for a brand-new app, true if a binding already existed) plus the canonical app/project identifiers and the dashboard URL. Use forceNew=true only when intentionally creating a new canonical family from scratch in a previously-bound repo; do NOT use forceNew as a retry mechanism for a failed init — it creates orphan backend apps and triggers canonical-family ambiguity errors on subsequent inits in this directory.\",\n access: \"remote_write\",\n inputSchema: initInputSchema,\n outputSchema: initSuccessSchema,\n run: async (args) => {\n const input = z.object(initInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n const result = await initCollab({\n cwd,\n appName: input.appName,\n forceNew: input.forceNew,\n });\n\n // After a successful init, kick off `remix history import` in\n // the background — but only the very first time we bind this\n // repo. Gating is the absence of `<repoRoot>/.remix/.history-\n // imported`, which the importer drops on a clean run. See\n // autoSpawnHistoryImport.ts for the policy and edge cases.\n // Failures here MUST NOT propagate: the init already succeeded\n // and we don't want to fail the tool over a backgrounded\n // best-effort import.\n try {\n const repoRoot =\n result &&\n typeof result === \"object\" &&\n \"data\" in result &&\n result.data &&\n typeof (result.data as { repoRoot?: unknown }).repoRoot === \"string\"\n ? (result.data as { repoRoot: string }).repoRoot\n : null;\n if (repoRoot && shouldAutoSpawnHistoryImport(repoRoot)) {\n const spawned = spawnHistoryImportDetached(repoRoot);\n // The MCP logger has a fixed schema (no `pid`/`logPath`\n // fields), so we encode the spawn outcome into `message`.\n // The repoRoot field exists on LogEvent and is the most\n // useful pivot for ops searching after the fact.\n context.logger.log({\n level: \"info\",\n message: `history_import_auto_spawned pid=${spawned.pid ?? \"?\"} log=${spawned.logPath}`,\n tool: \"remix_collab_init\",\n repoRoot,\n });\n }\n } catch (spawnError) {\n context.logger.log({\n level: \"error\",\n message: `history_import_auto_spawn_failed: ${spawnError instanceof Error ? spawnError.message : String(spawnError)}`,\n tool: \"remix_collab_init\",\n });\n }\n\n return result;\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_list\",\n description:\n \"List Remix apps visible to the current authenticated user. Defaults to membership-oriented discovery; pass accessScope=all_readable explicitly for broader readable discovery.\",\n access: \"read\",\n inputSchema: listInputSchema,\n outputSchema: listSuccessSchema,\n run: async (args) => {\n const input = z.object(listInputSchema).parse(args);\n return listApps({\n ownership: input.ownership,\n accessScope: input.accessScope,\n createdBy: input.createdBy,\n forked: input.forked,\n limit: input.limit,\n offset: input.offset,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_remix\",\n description: \"Fork a Remix app and materialize a new local checkout bound to the remix. Prefer `outputDir` for an exact destination outside any existing git repo; `cwd` is only the parent-directory fallback.\",\n access: \"remote_write\",\n inputSchema: remixInputSchema,\n outputSchema: remixSuccessSchema,\n run: async (args) => {\n const input = z.object(remixInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n // History import auto-spawn removed; see note on\n // remix_collab_init above.\n return remixCollab({\n cwd,\n appId: input.appId,\n name: input.name,\n outputDir: input.outputDir,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_checkout\",\n description: \"Materialize an existing Remix app as-is into a new local checkout without creating a new fork. Works for original apps and fork apps; the resulting binding preserves that lineage.\",\n access: \"remote_write\",\n inputSchema: checkoutInputSchema,\n outputSchema: checkoutSuccessSchema,\n run: async (args) => {\n const input = z.object(checkoutInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n // History import auto-spawn removed; see note on\n // remix_collab_init above.\n return checkoutCollab({\n cwd,\n appId: input.appId,\n outputDir: input.outputDir,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_finalize_turn\",\n description:\n \"Primary turn recorder for the current bound repository. Required: call this exactly once before the final response on every turn that touched a Remix-bound repo. Captures the current boundary locally and queues remote processing. Queued only: no remote change step exists yet until the finalize queue drains. Runtime exception: if this turn's context contains a [Remix runtime status] system note from the Remix UserPromptSubmit hook stating that the Stop hook will record this turn automatically, do NOT call this tool — the runtime is recording it on your behalf and a manual call would create a duplicate record. The runtime note is the only sanctioned override; trivial prompts, error states, and ambiguity all still require this call.\",\n access: \"local_write\",\n inputSchema: finalizeTurnInputSchema,\n outputSchema: finalizeTurnSuccessSchema,\n annotations: getAnnotations(\"local_write\", { idempotent: true }),\n run: async (args) => {\n const input = z.object(finalizeTurnInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return finalizeCollabTurn({\n cwd,\n prompt: input.prompt,\n assistantResponse: input.assistantResponse,\n sync: input.sync,\n allowBranchMismatch: input.allowBranchMismatch ?? false,\n idempotencyKey: input.idempotencyKey,\n agent: context.agentMetadata,\n awaitingUsageDeadlineMs: 30_000,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_drain_finalize_queue\",\n description:\n \"Drain the local finalize queue and record queued finalize_turn jobs immediately. NOT required as a precondition for `remix_collab_request_merge` or `remix_collab_reconcile_apply` — those tools drain the queue internally before they run. Useful only for explicit recovery flows (e.g. status reports `await_finalize` and you want to flush before re-checking). Runtime exception: if this turn's context contains a [Remix runtime status] system note from the Remix UserPromptSubmit hook, the runtime drains the queue automatically in the background; do NOT call this tool unless an explicit recovery flow requires it.\",\n access: \"local_write\",\n inputSchema: drainFinalizeQueueInputSchema,\n outputSchema: drainFinalizeQueueSuccessSchema,\n annotations: getAnnotations(\"local_write\", { idempotent: true }),\n run: async (args) => {\n const input = z.object(drainFinalizeQueueInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return drainFinalizeQueue({ cwd });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_sync_preview\",\n description: \"Preview whether the current bound repository can pull the server delta into the working tree. Use this instead of raw git pull or rebase for bound-repo alignment.\",\n access: \"read\",\n inputSchema: previewInputSchema,\n outputSchema: syncSuccessSchema,\n run: async (args) => {\n const input = z.object(previewInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return syncCollab({ cwd, dryRun: true });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_sync_apply\",\n description: \"Pull the server delta into the local working tree without moving local git history. This is the Remix-native replacement for raw git pull or rebase in a bound repo.\",\n access: \"local_write\",\n inputSchema: applyInputSchema,\n outputSchema: syncSuccessSchema,\n run: async (args) => {\n const input = z.object(applyInputSchema).parse(args);\n assertConfirm(input.confirm, \"remix_collab_sync_apply\");\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return syncCollab({ cwd, dryRun: false, allowBranchMismatch: input.allowBranchMismatch ?? false });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_re_anchor_preview\",\n description: \"Preview whether this checkout needs a fresh local Remix baseline. Use only when status reports `re_anchor` (no local baseline exists for this lane yet — fresh clone, deleted `.remix/` state, or first init didn't seed). Re-anchor does not replace `remix_collab_finalize_turn`; ordinary local content changes (including merges, pulls, and rebases) are recorded by `finalize-turn`, not by re-anchor.\",\n access: \"read\",\n inputSchema: previewInputSchema,\n outputSchema: reAnchorSuccessSchema,\n run: async (args) => {\n const input = z.object(previewInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return reAnchor({ cwd, dryRun: true });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_re_anchor_apply\",\n description: \"Establish a local Remix baseline for the current checkout against the existing app head, without rewriting the local checkout afterward. Required only when status reports `re_anchor` (missing local baseline). It does not replace `remix_collab_finalize_turn` — local commits, pulls, merges, and rebases must still be recorded with `finalize-turn`.\",\n access: \"local_write\",\n inputSchema: reAnchorInputSchema,\n outputSchema: reAnchorSuccessSchema,\n run: async (args) => {\n const input = z.object(reAnchorInputSchema).parse(args);\n assertConfirm(input.confirm, \"remix_collab_re_anchor_apply\");\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return reAnchor({ cwd, dryRun: false, allowBranchMismatch: input.allowBranchMismatch ?? false });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_request_merge\",\n description: \"Open a prompt-backed Remix merge request from the current bound repository to its upstream app instead of merging locally with raw git.\",\n access: \"remote_write\",\n inputSchema: requestMergeInputSchema,\n outputSchema: requestMergeSuccessSchema,\n run: async (args) => {\n const input = z.object(requestMergeInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return requestMerge({ cwd });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_review_queue\",\n description: \"List reviewable merge requests: open requests the current user can actively approve or reject on target apps they administer or maintain. Optional `status` filters the results; optional `kind` defaults to `merge`.\",\n access: \"read\",\n inputSchema: reviewQueueInputSchema,\n outputSchema: mergeRequestQueueSuccessSchema,\n run: async (args) => {\n const input = z.object(reviewQueueInputSchema).parse(args);\n return reviewQueue({\n status: input.status,\n kind: input.kind,\n limit: input.limit,\n offset: input.offset,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_my_merge_requests\",\n description: \"List merge requests created by the current user across all apps visible to that user, not just the current bound checkout. This still works even when the user is not a reviewer on the target app. Optional `status` filters the results; optional `kind` defaults to `merge`.\",\n access: \"read\",\n inputSchema: myMergeRequestsInputSchema,\n outputSchema: mergeRequestQueueSuccessSchema,\n run: async (args) => {\n const input = z.object(myMergeRequestsInputSchema).parse(args);\n return myMergeRequests({\n status: input.status,\n kind: input.kind,\n limit: input.limit,\n offset: input.offset,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_list_app_merge_requests\",\n description: \"List app-scoped merge requests for the current bound checkout or an explicit `appId`. Required `queue` must be one of: `app_reviewable` (incoming requests this app can review), `app_outgoing` (requests created from this app), or `app_related_visible` (all open visible requests where this app is either source or target). Optional `status` filters the results; optional `kind` defaults to `merge`.\",\n access: \"read\",\n inputSchema: appMergeRequestsInputSchema,\n outputSchema: mergeRequestQueueSuccessSchema,\n run: async (args) => {\n const input = z.object(appMergeRequestsInputSchema).parse(args);\n const cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n return listAppMergeRequests({\n cwd,\n appId: input.appId,\n queue: input.queue,\n status: input.status,\n kind: input.kind,\n limit: input.limit,\n offset: input.offset,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_view_merge_request\",\n description: \"View Remix merge request metadata, review groups, change steps, and optionally a bounded unified diff before approval or rejection.\",\n access: \"read\",\n inputSchema: viewMergeRequestInputSchema,\n outputSchema: viewMergeRequestSuccessSchema,\n run: async (args) => {\n const input = z.object(viewMergeRequestInputSchema).parse(args);\n return viewMergeRequest({\n mrId: input.mrId,\n includeUnifiedDiff: input.includeUnifiedDiff ?? false,\n diffMaxChars: input.diffMaxChars ?? context.policy.maxDiffOutputChars,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_approve_remote\",\n description: \"Approve a merge request or upstream sync remotely and wait for terminal completion without mutating the local repository, preserving Remix as the merge authority.\",\n access: \"remote_write\",\n inputSchema: approveInputSchema,\n outputSchema: approveSuccessSchema,\n run: async (args) => {\n const input = z.object(approveInputSchema).parse(args);\n assertConfirm(input.confirm, \"remix_collab_approve_remote\");\n return approveMergeRequest({\n mrId: input.mrId,\n mode: \"remote-only\",\n allowBranchMismatch: input.allowBranchMismatch ?? false,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_approve_and_sync_target\",\n description: \"Approve a merge request, wait for completion, and sync the target repository locally through Remix rather than a local git merge flow.\",\n access: \"local_write\",\n inputSchema: approveInputSchema,\n outputSchema: approveSuccessSchema,\n run: async (args) => {\n const input = z.object(approveInputSchema).parse(args);\n assertConfirm(input.confirm, \"remix_collab_approve_and_sync_target\");\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return approveMergeRequest({\n mrId: input.mrId,\n cwd,\n mode: \"sync-target-repo\",\n allowBranchMismatch: input.allowBranchMismatch ?? false,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_reject\",\n description: \"Reject a merge request.\",\n access: \"remote_write\",\n inputSchema: rejectInputSchema,\n outputSchema: rejectSuccessSchema,\n run: async (args) => {\n const input = z.object(rejectInputSchema).parse(args);\n assertConfirm(input.confirm, \"remix_collab_reject\");\n return rejectMergeRequest({ mrId: input.mrId });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_sync_upstream\",\n description: \"Sync upstream changes into the current remix and update the local checkout through Remix-native lineage management rather than raw git pull or merge.\",\n access: \"local_write\",\n inputSchema: applyInputSchema,\n outputSchema: syncUpstreamSuccessSchema,\n run: async (args) => {\n const input = z.object(applyInputSchema).parse(args);\n assertConfirm(input.confirm, \"remix_collab_sync_upstream\");\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return syncUpstream({ cwd });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_reconcile_preview\",\n description: \"Preview the explicit Remix recovery flow when local and server state diverged beyond a simple pull.\",\n access: \"read\",\n inputSchema: previewInputSchema,\n outputSchema: reconcileSuccessSchema,\n run: async (args) => {\n const input = z.object(previewInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return reconcile({ cwd, dryRun: true });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_reconcile_apply\",\n description: \"Run the explicit Remix recovery flow for diverged local/server state.\",\n access: \"local_write\",\n inputSchema: applyInputSchema,\n outputSchema: reconcileSuccessSchema,\n run: async (args) => {\n const input = z.object(applyInputSchema).parse(args);\n assertConfirm(input.confirm, \"remix_collab_reconcile_apply\");\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return reconcile({ cwd, dryRun: false, allowBranchMismatch: input.allowBranchMismatch ?? false });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_invite\",\n description: \"Invite a collaborator to an organization, project, or app, using the current repository binding unless targetId is provided.\",\n access: \"remote_write\",\n inputSchema: inviteInputSchema,\n outputSchema: inviteSuccessSchema,\n run: async (args) => {\n const input = z.object(inviteInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return inviteCollaborator({\n cwd,\n email: input.email,\n role: input.role,\n scope: input.scope,\n targetId: input.targetId,\n ttlDays: input.ttlDays,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_list_members\",\n description: \"List organization, project, or app members, using the current repository binding unless targetId is provided.\",\n access: \"read\",\n inputSchema: listMembersInputSchema,\n outputSchema: listMembersSuccessSchema,\n run: async (args) => {\n const input = z.object(listMembersInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return listMembers({\n cwd,\n scope: input.scope,\n targetId: input.targetId,\n limit: input.limit,\n offset: input.offset,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_list_invites\",\n description: \"List invitations for an organization, project, or app, using the current repository binding unless targetId is provided.\",\n access: \"read\",\n inputSchema: listInvitesInputSchema,\n outputSchema: listInvitesSuccessSchema,\n run: async (args) => {\n const input = z.object(listInvitesInputSchema).parse(args);\n const cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n return listScopeInvites({\n cwd,\n scope: input.scope ?? \"project\",\n targetId: input.targetId,\n limit: input.limit,\n offset: input.offset,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_resend_invite\",\n description: \"Resend an existing invitation for an organization, project, or app, using the current repository binding unless targetId is provided.\",\n access: \"remote_write\",\n inputSchema: resendInviteInputSchema,\n outputSchema: resendInviteSuccessSchema,\n run: async (args) => {\n const input = z.object(resendInviteInputSchema).parse(args);\n const cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n return resendScopedInvite({\n cwd,\n scope: input.scope ?? \"project\",\n targetId: input.targetId,\n inviteId: input.inviteId,\n ttlDays: input.ttlDays,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_revoke_invite\",\n description: \"Revoke an existing invitation for an organization, project, or app, using the current repository binding unless targetId is provided.\",\n access: \"remote_write\",\n inputSchema: revokeInviteInputSchema,\n outputSchema: revokeInviteSuccessSchema,\n run: async (args) => {\n const input = z.object(revokeInviteInputSchema).parse(args);\n assertConfirm(input.confirm, \"remix_collab_revoke_invite\");\n const cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n return revokeScopedInvite({\n cwd,\n scope: input.scope ?? \"project\",\n targetId: input.targetId,\n inviteId: input.inviteId,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_accept_invitation\",\n description: \"Accept an invitation token for the currently authenticated Remix user.\",\n access: \"remote_write\",\n inputSchema: acceptInvitationInputSchema,\n outputSchema: acceptInvitationSuccessSchema,\n annotations: getAnnotations(\"remote_write\", { idempotent: true }),\n run: async (args) => {\n const input = z.object(acceptInvitationInputSchema).parse(args);\n return acceptInvitationByToken({\n token: input.token,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_access_debug\",\n description: \"Explain why the current user does or does not have access to an organization, project, or app by composing binding, membership, invite, and scope context.\",\n access: \"read\",\n inputSchema: accessDebugInputSchema,\n outputSchema: accessDebugSuccessSchema,\n run: async (args) => {\n const input = z.object(accessDebugInputSchema).parse(args);\n const cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n return accessDebugRead({\n cwd,\n scope: input.scope ?? \"project\",\n targetId: input.targetId,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_update_member_role\",\n description: \"Update an organization, project, or app member role, using the current repository binding unless targetId is provided.\",\n access: \"remote_write\",\n inputSchema: updateMemberRoleInputSchema,\n outputSchema: updateMemberRoleSuccessSchema,\n run: async (args) => {\n const input = z.object(updateMemberRoleInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return updateMemberRole({\n cwd,\n scope: input.scope,\n targetId: input.targetId,\n userId: input.userId,\n role: input.role,\n });\n },\n });\n}\n","import { z } from \"zod\";\n\nimport { commonRequestFieldsSchema, makeSuccessSchema } from \"./common.js\";\n\nconst genericRecordSchema = z.record(z.string(), z.unknown());\nconst genericArraySchema = z.array(genericRecordSchema);\nconst paginationSchema = z.object({\n limit: z.number().int().positive(),\n offset: z.number().int().nonnegative(),\n hasMore: z.boolean(),\n});\nconst mergeRequestQueueSchema = z.enum([\n \"reviewable\",\n \"created_by_me\",\n \"app_reviewable\",\n \"app_outgoing\",\n \"app_related_visible\",\n]);\nconst appScopedMergeRequestQueueSchema = z.enum([\"app_reviewable\", \"app_outgoing\", \"app_related_visible\"]);\nconst memberScopeSchema = z.enum([\"organization\", \"project\", \"app\"]);\n\nexport const statusInputSchema = {\n ...commonRequestFieldsSchema,\n includeRemote: z.boolean().optional(),\n};\n\nexport const initInputSchema = {\n ...commonRequestFieldsSchema,\n appName: z.string().trim().min(1).optional(),\n forceNew: z.boolean().optional(),\n};\n\nexport const listInputSchema = {\n requestId: z.string().trim().min(1).optional(),\n outputMode: z.enum([\"summary\", \"full\"]).optional(),\n ownership: z.enum([\"mine\", \"shared\", \"all\"]).optional(),\n accessScope: z.enum([\"all_readable\", \"explicit_member\"]).optional(),\n createdBy: z.string().trim().min(1).optional(),\n forked: z.enum([\"only\", \"exclude\", \"all\"]).optional(),\n limit: z.number().int().positive().max(50).optional(),\n offset: z.number().int().nonnegative().optional(),\n};\n\nexport const remixInputSchema = {\n ...commonRequestFieldsSchema,\n appId: z.string().trim().min(1),\n name: z.string().trim().min(1).optional(),\n outputDir: z.string().trim().min(1).optional(),\n};\n\nexport const checkoutInputSchema = {\n ...commonRequestFieldsSchema,\n appId: z.string().trim().min(1),\n outputDir: z.string().trim().min(1).optional(),\n};\n\nexport const addInputSchema = {\n ...commonRequestFieldsSchema,\n prompt: z.string().trim().min(1),\n assistantResponse: z.string().trim().min(1).optional(),\n diffSource: z.enum([\"worktree\", \"external\"]).optional(),\n externalDiff: z.string().optional(),\n allowBranchMismatch: z.boolean().optional(),\n idempotencyKey: z.string().trim().min(1).optional(),\n};\n\nexport const recordTurnInputSchema = {\n ...commonRequestFieldsSchema,\n prompt: z.string().trim().min(1),\n assistantResponse: z.string().trim().min(1),\n allowBranchMismatch: z.boolean().optional(),\n idempotencyKey: z.string().trim().min(1).optional(),\n};\n\nexport const finalizeTurnInputSchema = {\n ...commonRequestFieldsSchema,\n prompt: z.string().trim().min(1),\n assistantResponse: z.string().trim().min(1),\n sync: z.boolean().optional(),\n allowBranchMismatch: z.boolean().optional(),\n idempotencyKey: z.string().trim().min(1).optional(),\n};\n\nexport const previewInputSchema = {\n ...commonRequestFieldsSchema,\n};\n\nexport const drainFinalizeQueueInputSchema = {\n ...commonRequestFieldsSchema,\n};\n\nexport const applyInputSchema = {\n ...commonRequestFieldsSchema,\n confirm: z.boolean(),\n allowBranchMismatch: z.boolean().optional(),\n};\n\nexport const reAnchorInputSchema = {\n ...applyInputSchema,\n};\n\nexport const requestMergeInputSchema = {\n ...commonRequestFieldsSchema,\n};\n\nexport const reviewQueueInputSchema = {\n requestId: z.string().trim().min(1).optional(),\n outputMode: z.enum([\"summary\", \"full\"]).optional(),\n status: z.string().trim().min(1).optional(),\n kind: z.enum([\"merge\", \"sync\", \"all\"]).optional(),\n limit: z.number().int().positive().max(50).optional(),\n offset: z.number().int().nonnegative().optional(),\n};\n\nexport const myMergeRequestsInputSchema = {\n requestId: z.string().trim().min(1).optional(),\n outputMode: z.enum([\"summary\", \"full\"]).optional(),\n status: z.string().trim().min(1).optional(),\n kind: z.enum([\"merge\", \"sync\", \"all\"]).optional(),\n limit: z.number().int().positive().max(50).optional(),\n offset: z.number().int().nonnegative().optional(),\n};\n\nexport const appMergeRequestsInputSchema = {\n ...commonRequestFieldsSchema,\n queue: appScopedMergeRequestQueueSchema,\n appId: z.string().trim().min(1).optional(),\n status: z.string().trim().min(1).optional(),\n kind: z.enum([\"merge\", \"sync\", \"all\"]).optional(),\n limit: z.number().int().positive().max(50).optional(),\n offset: z.number().int().nonnegative().optional(),\n};\n\nexport const viewMergeRequestInputSchema = {\n requestId: z.string().trim().min(1).optional(),\n outputMode: z.enum([\"summary\", \"full\"]).optional(),\n mrId: z.string().trim().min(1),\n includeUnifiedDiff: z.boolean().optional(),\n diffMaxChars: z.number().int().positive().max(200_000).optional(),\n};\n\nexport const approveInputSchema = {\n ...commonRequestFieldsSchema,\n mrId: z.string().trim().min(1),\n confirm: z.boolean(),\n allowBranchMismatch: z.boolean().optional(),\n};\n\nexport const rejectInputSchema = {\n requestId: z.string().trim().min(1).optional(),\n mrId: z.string().trim().min(1),\n confirm: z.boolean(),\n};\n\nexport const inviteInputSchema = {\n ...commonRequestFieldsSchema,\n email: z.string().email(),\n scope: z.enum([\"organization\", \"project\", \"app\"]).optional(),\n targetId: z.string().trim().min(1).optional(),\n role: z.string().trim().min(1).optional(),\n ttlDays: z.number().int().positive().max(30).optional(),\n};\n\nexport const listMembersInputSchema = {\n ...commonRequestFieldsSchema,\n scope: memberScopeSchema,\n targetId: z.string().trim().min(1).optional(),\n limit: z.number().int().positive().max(50).optional(),\n offset: z.number().int().nonnegative().optional(),\n};\n\nexport const listInvitesInputSchema = {\n ...commonRequestFieldsSchema,\n scope: memberScopeSchema.optional(),\n targetId: z.string().trim().min(1).optional(),\n limit: z.number().int().positive().max(50).optional(),\n offset: z.number().int().nonnegative().optional(),\n};\n\nexport const resendInviteInputSchema = {\n ...commonRequestFieldsSchema,\n scope: memberScopeSchema.optional(),\n targetId: z.string().trim().min(1).optional(),\n inviteId: z.string().trim().min(1),\n ttlDays: z.number().int().positive().max(30).optional(),\n};\n\nexport const revokeInviteInputSchema = {\n ...commonRequestFieldsSchema,\n scope: memberScopeSchema.optional(),\n targetId: z.string().trim().min(1).optional(),\n inviteId: z.string().trim().min(1),\n confirm: z.boolean(),\n};\n\nexport const acceptInvitationInputSchema = {\n requestId: z.string().trim().min(1).optional(),\n token: z.string().trim().min(20),\n};\n\nexport const accessDebugInputSchema = {\n ...commonRequestFieldsSchema,\n scope: memberScopeSchema.optional(),\n targetId: z.string().trim().min(1).optional(),\n};\n\nexport const updateMemberRoleInputSchema = {\n ...commonRequestFieldsSchema,\n scope: memberScopeSchema,\n targetId: z.string().trim().min(1).optional(),\n userId: z.string().trim().min(1),\n role: z.string().trim().min(1),\n};\n\nexport const statusDataSchema = z.object({\n status: genericRecordSchema,\n riskLevel: z.enum([\"low\", \"medium\", \"high\"]),\n});\n\n// Sync-init shape: the only shape the MCP `remix_collab_init` tool currently\n// returns. The synchronous init path guarantees the local binding file AND\n// the local Remix baseline are both on disk by the time the tool resolves,\n// so the caller can immediately record turns with no further waiting.\nconst initSyncDataSchema = z.object({\n reused: z.boolean(),\n projectId: z.string(),\n appId: z.string(),\n dashboardUrl: z.string().url(),\n upstreamAppId: z.string(),\n bindingPath: z.string(),\n repoRoot: z.string(),\n bindingMode: z.enum([\"legacy\", \"lane\", \"explicit_root\"]).optional(),\n createdCanonicalFamily: z.boolean().optional(),\n baselineStatus: z.enum([\"seeded\", \"existing\", \"requires_re_anchor\", \"requires_sync\"]).optional(),\n});\n\n// Queued shape: returned by the fast-binding async init flow. NOT currently\n// part of the MCP tool's output schema — agent callers always go through the\n// synchronous path (see remix-mcp/src/domain/coreAdapter.ts and\n// remix-core/src/application/collab/collabInit.ts:`asyncSubmit`). The schema\n// is kept so the underlying core capability can be re-wired without\n// reconstructing the Zod definition. To re-enable, change `initDataSchema`\n// below to `z.union([initSyncDataSchema, initQueuedDataSchema])` and flip\n// coreAdapter back to `coreCollabInitSubmit`.\nconst initQueuedDataSchema = z.object({\n queued: z.literal(true),\n status: z.literal(\"ready_to_record\"),\n doNotRetry: z.literal(true),\n jobId: z.string(),\n projectId: z.string(),\n appId: z.string(),\n dashboardUrl: z.string(),\n upstreamAppId: z.string(),\n bindingPath: z.string(),\n repoRoot: z.string(),\n bindingMode: z.enum([\"legacy\", \"lane\", \"explicit_root\"]),\n createdCanonicalFamily: z.boolean(),\n remoteUrl: z.string().nullable(),\n defaultBranch: z.string().nullable(),\n});\n\nexport const initDataSchema = initSyncDataSchema;\nexport type InitData = z.infer<typeof initDataSchema>;\nexport type InitSyncData = z.infer<typeof initSyncDataSchema>;\n// Preserved for potential future re-introduction of async init at the MCP\n// layer; not exported from the package barrel.\nexport type InitQueuedData = z.infer<typeof initQueuedDataSchema>;\n\nexport const listDataSchema = z.object({\n apps: genericArraySchema,\n pagination: paginationSchema,\n});\n\nexport const remixDataSchema = z.object({\n appId: z.string(),\n dashboardUrl: z.string().url(),\n projectId: z.string(),\n upstreamAppId: z.string(),\n bindingPath: z.string(),\n repoRoot: z.string(),\n});\n\nexport const checkoutDataSchema = z.object({\n appId: z.string(),\n dashboardUrl: z.string().url(),\n projectId: z.string(),\n upstreamAppId: z.string(),\n bindingPath: z.string(),\n repoRoot: z.string(),\n});\n\nexport const addDataSchema = z.object({\n changeStep: genericRecordSchema,\n});\nexport const recordTurnDataSchema = genericRecordSchema;\nexport const finalizeTurnDataSchema = z.object({\n mode: z.enum([\"changed_turn\", \"no_diff_turn\"]),\n idempotencyKey: z.string().min(1),\n queued: z.boolean(),\n jobId: z.string().nullable(),\n repoState: z.string().nullable(),\n changeStep: genericRecordSchema.nullable(),\n collabTurn: genericRecordSchema.nullable(),\n autoSync: genericRecordSchema.nullable(),\n warnings: z.array(z.string()),\n});\nexport const drainFinalizeQueueDataSchema = z.object({\n processed: z.number().int().nonnegative(),\n results: z.array(genericRecordSchema),\n});\n\nexport const syncDataSchema = genericRecordSchema;\nexport const reAnchorDataSchema = genericRecordSchema;\nexport const requestMergeDataSchema = genericRecordSchema;\nexport const mergeRequestQueueDataSchema = z.object({\n queue: mergeRequestQueueSchema,\n appId: z.string().nullable(),\n mergeRequests: z.array(genericRecordSchema),\n pagination: paginationSchema,\n});\nexport const viewMergeRequestDataSchema = genericRecordSchema;\nexport const approveDataSchema = genericRecordSchema;\nexport const rejectDataSchema = genericRecordSchema;\nexport const syncUpstreamDataSchema = genericRecordSchema;\nexport const reconcileDataSchema = genericRecordSchema;\nexport const inviteDataSchema = genericRecordSchema;\nexport const memberRecordSchema = genericRecordSchema;\nexport const listMembersDataSchema = z.object({\n scopeType: memberScopeSchema,\n targetId: z.string(),\n members: z.array(memberRecordSchema),\n pagination: paginationSchema,\n});\nexport const listInvitesDataSchema = z.object({\n scopeType: memberScopeSchema,\n targetId: z.string(),\n invites: z.array(genericRecordSchema),\n pagination: paginationSchema,\n});\nexport const resendInviteDataSchema = genericRecordSchema;\nexport const revokeInviteDataSchema = z.object({\n scopeType: memberScopeSchema,\n targetId: z.string(),\n inviteId: z.string(),\n revoked: z.boolean(),\n});\nexport const acceptInvitationDataSchema = genericRecordSchema;\nexport const accessDebugDataSchema = z.object({\n viewer: genericRecordSchema,\n scope: z.object({\n scopeType: memberScopeSchema,\n targetId: z.string(),\n }),\n entities: z.object({\n organization: genericRecordSchema.nullable(),\n project: genericRecordSchema.nullable(),\n app: genericRecordSchema.nullable(),\n }),\n binding: z.object({\n repoRoot: z.string().nullable(),\n binding: genericRecordSchema.nullable(),\n }),\n access: z.object({\n appContext: genericRecordSchema.nullable(),\n viewerMember: genericRecordSchema.nullable(),\n viewerProjectMember: genericRecordSchema.nullable(),\n inviteForViewerEmail: genericRecordSchema.nullable(),\n effectiveAppAccess: genericRecordSchema.nullable(),\n }),\n members: z.array(genericRecordSchema),\n membersPageInfo: paginationSchema,\n invites: z.array(genericRecordSchema),\n invitesPageInfo: paginationSchema,\n});\nexport const updateMemberRoleDataSchema = z.object({\n scopeType: memberScopeSchema,\n targetId: z.string(),\n member: memberRecordSchema,\n});\n\nexport const statusSuccessSchema = makeSuccessSchema(statusDataSchema);\nexport const initSuccessSchema = makeSuccessSchema(initDataSchema);\nexport const listSuccessSchema = makeSuccessSchema(listDataSchema);\nexport const remixSuccessSchema = makeSuccessSchema(remixDataSchema);\nexport const checkoutSuccessSchema = makeSuccessSchema(checkoutDataSchema);\nexport const addSuccessSchema = makeSuccessSchema(addDataSchema);\nexport const recordTurnSuccessSchema = makeSuccessSchema(recordTurnDataSchema);\nexport const finalizeTurnSuccessSchema = makeSuccessSchema(finalizeTurnDataSchema);\nexport const drainFinalizeQueueSuccessSchema = makeSuccessSchema(drainFinalizeQueueDataSchema);\nexport const syncSuccessSchema = makeSuccessSchema(syncDataSchema);\nexport const reAnchorSuccessSchema = makeSuccessSchema(reAnchorDataSchema);\nexport const requestMergeSuccessSchema = makeSuccessSchema(requestMergeDataSchema);\nexport const mergeRequestQueueSuccessSchema = makeSuccessSchema(mergeRequestQueueDataSchema);\nexport const viewMergeRequestSuccessSchema = makeSuccessSchema(viewMergeRequestDataSchema);\nexport const approveSuccessSchema = makeSuccessSchema(approveDataSchema);\nexport const rejectSuccessSchema = makeSuccessSchema(rejectDataSchema);\nexport const syncUpstreamSuccessSchema = makeSuccessSchema(syncUpstreamDataSchema);\nexport const reconcileSuccessSchema = makeSuccessSchema(reconcileDataSchema);\nexport const inviteSuccessSchema = makeSuccessSchema(inviteDataSchema);\nexport const listMembersSuccessSchema = makeSuccessSchema(listMembersDataSchema);\nexport const listInvitesSuccessSchema = makeSuccessSchema(listInvitesDataSchema);\nexport const resendInviteSuccessSchema = makeSuccessSchema(resendInviteDataSchema);\nexport const revokeInviteSuccessSchema = makeSuccessSchema(revokeInviteDataSchema);\nexport const acceptInvitationSuccessSchema = makeSuccessSchema(acceptInvitationDataSchema);\nexport const accessDebugSuccessSchema = makeSuccessSchema(accessDebugDataSchema);\nexport const updateMemberRoleSuccessSchema = makeSuccessSchema(updateMemberRoleDataSchema);\n","import type { CallToolResult } from \"@modelcontextprotocol/sdk/types.js\";\nimport { z } from \"zod\";\n\nimport type { ErrorCategory, ErrorCode, NormalizedToolError } from \"../errors/errorCodes.js\";\n\nexport const SCHEMA_VERSION = 1 as const;\n\nexport const commonRequestFieldsSchema = {\n cwd: z.string().trim().min(1).optional(),\n requestId: z.string().trim().min(1).optional(),\n outputMode: z.enum([\"summary\", \"full\"]).optional(),\n};\n\nexport const errorEnvelopeSchema = z.object({\n code: z.custom<ErrorCode>(),\n message: z.string().min(1),\n hint: z.string().nullable(),\n retryable: z.boolean(),\n category: z.custom<ErrorCategory>(),\n});\n\nexport function makeSuccessSchema(dataSchema: z.ZodTypeAny) {\n return z.object({\n schemaVersion: z.literal(SCHEMA_VERSION),\n ok: z.literal(true),\n tool: z.string().min(1),\n requestId: z.string().nullable(),\n data: dataSchema,\n warnings: z.array(z.string()),\n risks: z.array(z.string()),\n recommendedNextActions: z.array(z.string()),\n });\n}\n\nexport function makeErrorSchema() {\n return z.object({\n schemaVersion: z.literal(SCHEMA_VERSION),\n ok: z.literal(false),\n tool: z.string().min(1),\n requestId: z.string().nullable(),\n error: errorEnvelopeSchema,\n warnings: z.array(z.string()),\n risks: z.array(z.string()),\n recommendedNextActions: z.array(z.string()),\n });\n}\n\nexport type SuccessEnvelope<T> = {\n schemaVersion: typeof SCHEMA_VERSION;\n ok: true;\n tool: string;\n requestId: string | null;\n data: T;\n warnings: string[];\n risks: string[];\n recommendedNextActions: string[];\n};\n\nexport type ErrorEnvelope = {\n schemaVersion: typeof SCHEMA_VERSION;\n ok: false;\n tool: string;\n requestId: string | null;\n error: NormalizedToolError;\n warnings: string[];\n risks: string[];\n recommendedNextActions: string[];\n};\n\nfunction toJsonText(value: unknown): string {\n return JSON.stringify(value, null, 2);\n}\n\nexport function makeSuccessResult<T>(envelope: SuccessEnvelope<T>): CallToolResult {\n return {\n content: [{ type: \"text\", text: toJsonText(envelope) }],\n structuredContent: envelope,\n };\n}\n\nexport function makeErrorResult(envelope: ErrorEnvelope): CallToolResult {\n return {\n content: [{ type: \"text\", text: toJsonText(envelope) }],\n structuredContent: envelope,\n isError: true,\n };\n}\n","import { spawn } from \"node:child_process\";\n\nimport {\n collabList as coreCollabList,\n collabListMembers as coreCollabListMembers,\n collabUpdateMemberRole as coreCollabUpdateMemberRole,\n drainPendingFinalizeQueue as coreDrainPendingFinalizeQueue,\n collabFinalizeTurn as coreCollabFinalizeTurn,\n collabApprove as coreCollabApprove,\n collabCheckout as coreCollabCheckout,\n collabListMergeRequests as coreCollabListMergeRequests,\n collabInit as coreCollabInit,\n collabReAnchor as coreCollabReAnchor,\n collabInvite as coreCollabInvite,\n collabReconcile as coreCollabReconcile,\n collabReject as coreCollabReject,\n collabRemix as coreCollabRemix,\n collabRequestMerge as coreCollabRequestMerge,\n collabStatus as coreCollabStatus,\n collabSync as coreCollabSync,\n collabSyncUpstream as coreCollabSyncUpstream,\n collabView as coreCollabView,\n type CollabStatus,\n type InvitationScopeType,\n type MergeRequestQueue,\n} from \"@remixhq/core/collab\";\nimport { findGitRoot } from \"@remixhq/core/repo\";\n\nimport type { InitData, InitSyncData } from \"../contracts/collab.js\";\nimport { createCollabApiClient } from \"./apiClient.js\";\n\nfunction getRiskLevel(status: CollabStatus): \"low\" | \"medium\" | \"high\" {\n if (status.recommendedAction === \"reconcile\") return \"high\";\n if (status.recommendedAction === \"choose_family\" || status.recommendedAction === \"await_finalize\") return \"medium\";\n if (status.recommendedAction === \"pull\" || status.recommendedAction === \"re_anchor\" || status.remote.incomingOpenMergeRequestCount) {\n return \"medium\";\n }\n if (status.repo.branchMismatch || !status.repo.isGitRepo || !status.binding.isBound || !status.repo.worktree.isClean) return \"medium\";\n return \"low\";\n}\n\nfunction getRecommendedNextActions(status: CollabStatus): string[] {\n if (status.repo.branchMismatch) {\n return [\n `Switch to the bound branch (${status.binding.branchName ?? \"configured in the binding\"}) before using Remix mutation tools, or rerun with allowBranchMismatch=true if this deviation is intentional.`,\n ];\n }\n switch (status.recommendedAction) {\n case \"init\":\n return [\"Run remix_collab_init to bind the repository to Remix before using any Remix collaboration mutation flow.\"];\n case \"pull\":\n return [\"Run remix_collab_sync_preview, then remix_collab_sync_apply if the preview is acceptable. This pulls the server delta into the local working tree without rewriting local git history.\"];\n case \"re_anchor\":\n return [\n \"Run remix_collab_re_anchor_preview, then remix_collab_re_anchor_apply. This seeds a local Remix baseline. It is required because no local baseline exists for this lane yet (fresh clone, deleted .remix/ state, or first init didn't seed) — not because of any specific git operation. After it succeeds, normal recording (remix_collab_finalize_turn) becomes available.\",\n ];\n case \"record\":\n return [\n \"Run remix_collab_finalize_turn to capture the local boundary delta. This is the catch-all for any local content change since the last recorded turn, regardless of whether the change came from agent edits, manual user edits, git commit, git pull, git merge, git rebase, or git reset.\",\n ];\n case \"reconcile\":\n return [\"Run remix_collab_reconcile_preview before attempting remix_collab_reconcile_apply. Reconcile applies only when both the local workspace and the server lane changed since the last agreed baseline.\"];\n case \"await_finalize\":\n return [\n \"Run remix_collab_drain_finalize_queue before merge-related or recovery flows. finalize_turn is queued only until the local finalize queue is drained.\",\n ];\n case \"review_queue\":\n return [\"Run remix_collab_review_queue to inspect reviewable merge requests instead of using local git merge flows.\"];\n case \"choose_family\":\n return [\n \"This checkout is ambiguous across multiple canonical Remix families. Continue from a checkout already bound to the intended family, or run remix_collab_init with forceNew=true to create and bind a new canonical family.\",\n ];\n default:\n return [];\n }\n}\n\nfunction collectWarnings(value: unknown): string[] {\n if (!value || !Array.isArray(value)) return [];\n return value.filter((entry): entry is string => typeof entry === \"string\" && entry.trim().length > 0);\n}\n\nfunction collectResultWarnings<T extends { warnings?: unknown }>(value: T): string[] {\n return collectWarnings(value.warnings);\n}\n\nfunction truncateText(value: string, maxChars: number): { text: string; truncated: boolean; originalChars: number } {\n if (value.length <= maxChars) {\n return {\n text: value,\n truncated: false,\n originalChars: value.length,\n };\n }\n return {\n text: `${value.slice(0, maxChars)}\\n\\n[truncated ${value.length - maxChars} chars]`,\n truncated: true,\n originalChars: value.length,\n };\n}\n\nfunction spawnFinalizeQueueDrainer(): boolean {\n const entrypoint = process.argv[1];\n if (!entrypoint) return false;\n const child = spawn(process.execPath, [...process.execArgv, entrypoint, \"--drain-finalize-queue\"], {\n detached: true,\n stdio: \"ignore\",\n env: process.env,\n });\n child.unref();\n return true;\n}\n\n// Drain the local finalize queue synchronously and surface any per-job\n// warnings as advisory strings. Used by mutation tools that require pending\n// finalize jobs to be materialized as remote change steps before they can\n// run correctly (request-merge, reconcile-apply). With this internal drain,\n// callers no longer need to call `remix_collab_drain_finalize_queue` first\n// — the runtime override in the UserPromptSubmit hook is therefore safe to\n// unconditionally instruct the model to skip drain.\nasync function drainBeforeMutation(api: Awaited<ReturnType<typeof createCollabApiClient>>): Promise<string[]> {\n const results = await coreDrainPendingFinalizeQueue({ api });\n return results.flatMap((result) => collectResultWarnings(result as { warnings?: unknown }));\n}\n\nexport async function getStatus(params: { cwd: string; includeRemote: boolean }) {\n const api = params.includeRemote ? await createCollabApiClient() : null;\n const status = await coreCollabStatus({\n api,\n cwd: params.cwd,\n });\n return {\n data: {\n status,\n riskLevel: getRiskLevel(status),\n },\n warnings: status.warnings,\n recommendedNextActions: getRecommendedNextActions(status),\n logContext: {\n repoRoot: status.repo.repoRoot,\n appId: status.binding.currentAppId,\n },\n };\n}\n\nexport async function initCollab(params: {\n cwd: string;\n appName?: string;\n forceNew?: boolean;\n}): Promise<{\n data: InitData;\n warnings: string[];\n recommendedNextActions: string[];\n logContext: { repoRoot?: string | null; appId?: string | null };\n}> {\n const api = await createCollabApiClient();\n // Synchronous init: the MCP path always returns a fully-usable binding\n // (binding file + local Remix baseline both on disk). Internally, this\n // calls `pollAppImported` which only waits for the import worker to set\n // head_commit_id (~5-15s), not the full app.status === \"ready\" pipeline\n // (which additionally waits for npm install + bundle builds — work the\n // baseline does not need). The async path (`collabInitSubmit` /\n // `init_post` drainer) is preserved in core but intentionally not wired\n // through the MCP layer — see contracts/collab.ts for the rationale and\n // re-enable instructions.\n const result = await coreCollabInit({\n api,\n cwd: params.cwd,\n appName: params.appName ?? null,\n forceNew: params.forceNew ?? false,\n asyncSubmit: false,\n });\n\n // Defensive guard: with `asyncSubmit: false` above, `collabInit` cannot\n // return the queued shape from the MCP path. If a future change ever\n // re-routes through `collabInitSubmit`, also restore `initQueuedDataSchema`\n // to the union exported as `initDataSchema` in contracts/collab.ts —\n // otherwise the queued payload would be silently rejected at the MCP\n // output validator with a less actionable error.\n if (\"queued\" in result && result.queued) {\n throw new Error(\n \"Unexpected queued init result on the MCP path. Async init is currently disabled for agent callers; \" +\n \"if you intended to re-enable it, also restore the queued shape in initDataSchema (see remix-mcp/src/contracts/collab.ts).\",\n );\n }\n\n // Sync-completed path. The optional `baselineStatus` field drives the\n // next-action recommendation.\n const syncResult = result as InitSyncData & { baselineStatus?: InitSyncData[\"baselineStatus\"] };\n return {\n data: syncResult,\n warnings: collectResultWarnings(result as { warnings?: unknown }),\n recommendedNextActions:\n syncResult.baselineStatus === \"requires_re_anchor\"\n ? [\n \"This checkout has no local Remix baseline yet. Run remix_collab_re_anchor_preview, then remix_collab_re_anchor_apply to seed one. After it succeeds, normal recording (remix_collab_finalize_turn) becomes available.\",\n ]\n : syncResult.baselineStatus === \"requires_sync\"\n ? [\n \"Run remix_collab_sync_preview, then remix_collab_sync_apply to pull the server delta and create the first local baseline for this checkout.\",\n ]\n : [\"Run remix_collab_status to inspect sync, reconcile, and merge-request readiness before mutating bound-repo state.\"],\n logContext: {\n repoRoot: syncResult.repoRoot,\n appId: syncResult.appId,\n },\n };\n}\n\nexport async function listApps(params: {\n ownership?: \"mine\" | \"shared\" | \"all\";\n accessScope?: \"all_readable\" | \"explicit_member\";\n createdBy?: \"me\" | string;\n forked?: \"only\" | \"exclude\" | \"all\";\n limit?: number;\n offset?: number;\n}) {\n const api = await createCollabApiClient();\n const result = await coreCollabList({\n api,\n ownership: params.ownership,\n accessScope: params.accessScope,\n createdBy: params.createdBy,\n forked: params.forked,\n limit: params.limit,\n offset: params.offset,\n });\n return {\n data: result,\n warnings: [],\n recommendedNextActions:\n result.pagination.hasMore ? [`Pass offset=${result.pagination.offset + result.pagination.limit} to load the next page.`] : [],\n logContext: {},\n };\n}\n\nexport async function remixCollab(params: { cwd: string; appId: string; name?: string; outputDir?: string }) {\n const api = await createCollabApiClient();\n const result = await coreCollabRemix({\n api,\n cwd: params.cwd,\n appId: params.appId,\n name: params.name ?? null,\n outputDir: params.outputDir ?? null,\n });\n return {\n data: result,\n warnings: collectResultWarnings(result as { warnings?: unknown }),\n recommendedNextActions: [\"Run remix_collab_status inside the remix checkout before using Remix mutation tools there.\"],\n logContext: {\n repoRoot: result.repoRoot,\n appId: result.appId,\n },\n };\n}\n\nexport async function checkoutCollab(params: { cwd: string; appId: string; outputDir?: string }) {\n const api = await createCollabApiClient();\n const result = await coreCollabCheckout({\n api,\n cwd: params.cwd,\n appId: params.appId,\n outputDir: params.outputDir ?? null,\n });\n return {\n data: result,\n warnings: collectResultWarnings(result as { warnings?: unknown }),\n recommendedNextActions: [\"Run remix_collab_status inside the checked out repository before using Remix mutation tools there.\"],\n logContext: {\n repoRoot: result.repoRoot,\n appId: result.appId,\n },\n };\n}\n\nexport async function finalizeCollabTurn(params: {\n cwd: string;\n prompt: string;\n assistantResponse: string;\n sync?: boolean;\n allowBranchMismatch?: boolean;\n idempotencyKey?: string;\n agent: { type: string; name?: string; version?: string; provider?: string };\n /**\n * When set and > 0, the enqueued job's `nextRetryAt` is offset this many ms into\n * the future. The drainer is NOT triggered post-enqueue in that case — ownership\n * passes to whichever caller will clear the deadline (typically the Stop hook\n * after harvesting token usage).\n */\n awaitingUsageDeadlineMs?: number | null;\n}) {\n const api = await createCollabApiClient();\n const repoRoot = await findGitRoot(params.cwd);\n const result = await coreCollabFinalizeTurn({\n api,\n cwd: params.cwd,\n prompt: params.prompt,\n assistantResponse: params.assistantResponse,\n sync: params.sync,\n allowBranchMismatch: params.allowBranchMismatch ?? false,\n idempotencyKey: params.idempotencyKey ?? null,\n actor: params.agent,\n awaitingUsageDeadlineMs: params.awaitingUsageDeadlineMs ?? null,\n });\n const hasAwaitingDeadline =\n typeof params.awaitingUsageDeadlineMs === \"number\" && params.awaitingUsageDeadlineMs > 0;\n if (result.queued && !hasAwaitingDeadline) {\n if (!spawnFinalizeQueueDrainer()) {\n await coreDrainPendingFinalizeQueue({ api });\n }\n }\n return {\n data: result,\n warnings: result.warnings,\n recommendedNextActions: result.queued\n ? [\"Run remix_collab_drain_finalize_queue before merge-related flows if you need this queued turn recorded immediately.\"]\n : [],\n logContext: {\n repoRoot,\n appId: result.changeStep?.appId ?? result.collabTurn?.appId ?? null,\n },\n };\n}\n\nexport async function drainFinalizeQueue(params: { cwd: string }) {\n const api = await createCollabApiClient();\n const repoRoot = await findGitRoot(params.cwd);\n const results = await coreDrainPendingFinalizeQueue({ api });\n const warnings = results.flatMap((result) => collectResultWarnings(result as { warnings?: unknown }));\n return {\n data: {\n processed: results.length,\n results,\n },\n warnings,\n recommendedNextActions: [],\n logContext: {\n repoRoot,\n appId: null,\n },\n };\n}\n\nexport async function syncCollab(params: { cwd: string; dryRun: boolean; allowBranchMismatch?: boolean }) {\n const api = await createCollabApiClient();\n const result = await coreCollabSync({\n api,\n cwd: params.cwd,\n dryRun: params.dryRun,\n allowBranchMismatch: params.allowBranchMismatch ?? false,\n });\n return {\n data: result,\n warnings: collectResultWarnings(result as { warnings?: unknown }),\n recommendedNextActions: params.dryRun\n ? result.status === \"delta_ready\"\n ? [\"Run remix_collab_sync_apply with confirm=true to apply this server delta into the local working tree.\"]\n : result.status === \"base_unknown\"\n ? [\n \"Direct pull is unavailable because Remix cannot diff from the last acknowledged server head.\",\n \"Run remix_collab_reconcile_preview next to inspect recovery options before applying any recovery flow.\",\n ]\n : []\n : [],\n logContext: {\n repoRoot: result.repoRoot,\n },\n };\n}\n\nexport async function reAnchor(params: { cwd: string; dryRun: boolean; allowBranchMismatch?: boolean }) {\n const api = await createCollabApiClient();\n const result = await coreCollabReAnchor({\n api,\n cwd: params.cwd,\n dryRun: params.dryRun,\n allowBranchMismatch: params.allowBranchMismatch ?? false,\n });\n return {\n data: result,\n warnings: collectWarnings((result as { warnings?: unknown }).warnings),\n recommendedNextActions: params.dryRun\n ? [\n \"Run remix_collab_re_anchor_apply with confirm=true to seed a local Remix baseline for this checkout. Re-anchor is for missing-baseline cases only and does not replace remix_collab_finalize_turn for ordinary local content changes.\",\n ]\n : [],\n logContext: {\n repoRoot: result.repoRoot,\n appId: result.currentAppId,\n },\n };\n}\n\nexport async function requestMerge(params: { cwd: string }) {\n const api = await createCollabApiClient();\n // Synchronously drain the local finalize queue before requesting a merge so\n // that any pending change steps for this repo are materialized remotely\n // first. Without this, an immediate request-merge after a code-editing turn\n // can race the detached drainer and fail because the backend row doesn't\n // exist yet. The runtime override in UserPromptSubmit relies on this\n // internal drain to remain safe.\n const drainWarnings = await drainBeforeMutation(api);\n const result = await coreCollabRequestMerge({\n api,\n cwd: params.cwd,\n });\n return {\n data: result,\n warnings: drainWarnings,\n recommendedNextActions: result.id\n ? [`Run remix_collab_view_merge_request with mrId=${String(result.id)} to inspect the request before deciding whether to approve or reject it.`]\n : [],\n logContext: {\n mrId: typeof result.id === \"string\" ? result.id : null,\n },\n };\n}\n\nexport async function reviewQueue(params: { status?: string; kind?: string; limit?: number; offset?: number }) {\n const api = await createCollabApiClient();\n const result = await coreCollabListMergeRequests({\n api,\n queue: \"reviewable\",\n status: params.status ?? \"open\",\n kind: params.kind ?? \"merge\",\n limit: params.limit,\n offset: params.offset,\n });\n return {\n data: {\n queue: result.queue,\n appId: result.appId,\n mergeRequests: result.mergeRequests,\n pagination: result.pagination,\n },\n warnings: [],\n recommendedNextActions:\n result.pagination.hasMore ? [`Pass offset=${result.pagination.offset + result.pagination.limit} to load the next page.`] : [],\n logContext: {},\n };\n}\n\nexport async function myMergeRequests(params: { status?: string; kind?: string; limit?: number; offset?: number }) {\n const api = await createCollabApiClient();\n const result = await coreCollabListMergeRequests({\n api,\n queue: \"created_by_me\",\n status: params.status ?? \"open\",\n kind: params.kind ?? \"merge\",\n limit: params.limit,\n offset: params.offset,\n });\n return {\n data: {\n queue: result.queue,\n appId: result.appId,\n mergeRequests: result.mergeRequests,\n pagination: result.pagination,\n },\n warnings: [],\n recommendedNextActions:\n result.pagination.hasMore ? [`Pass offset=${result.pagination.offset + result.pagination.limit} to load the next page.`] : [],\n logContext: {},\n };\n}\n\nexport async function listAppMergeRequests(params: {\n cwd?: string;\n appId?: string;\n queue: Extract<MergeRequestQueue, \"app_reviewable\" | \"app_outgoing\" | \"app_related_visible\">;\n status?: string;\n kind?: string;\n limit?: number;\n offset?: number;\n}) {\n const api = await createCollabApiClient();\n const result = await coreCollabListMergeRequests({\n api,\n cwd: params.cwd,\n appId: params.appId,\n queue: params.queue,\n status: params.status ?? \"open\",\n kind: params.kind ?? \"merge\",\n limit: params.limit,\n offset: params.offset,\n });\n return {\n data: {\n queue: result.queue,\n appId: result.appId,\n mergeRequests: result.mergeRequests,\n pagination: result.pagination,\n },\n warnings: [],\n recommendedNextActions:\n result.pagination.hasMore ? [`Pass offset=${result.pagination.offset + result.pagination.limit} to load the next page.`] : [],\n logContext: {\n appId: result.appId,\n },\n };\n}\n\nexport async function viewMergeRequest(params: { mrId: string; includeUnifiedDiff: boolean; diffMaxChars: number }) {\n const api = await createCollabApiClient();\n const review = await coreCollabView({\n api,\n mrId: params.mrId,\n });\n const truncatedDiff = params.includeUnifiedDiff ? truncateText(review.unifiedDiff, params.diffMaxChars) : null;\n return {\n data: {\n mergeRequest: review.mergeRequest,\n prompts: review.prompts,\n changeSteps: review.changeSteps,\n stats: review.stats,\n unifiedDiff: truncatedDiff?.text ?? null,\n diffTruncated: truncatedDiff?.truncated ?? false,\n originalUnifiedDiffChars: truncatedDiff?.originalChars ?? review.unifiedDiff.length,\n },\n warnings: truncatedDiff?.truncated ? [\"Unified diff output was truncated to respect the configured output limit.\"] : [],\n recommendedNextActions: [],\n logContext: {\n mrId: params.mrId,\n appId: review.mergeRequest.targetAppId,\n },\n };\n}\n\nexport async function approveMergeRequest(params: {\n mrId: string;\n cwd?: string;\n mode: \"remote-only\" | \"sync-target-repo\";\n allowBranchMismatch?: boolean;\n}) {\n const api = await createCollabApiClient();\n const result = await coreCollabApprove({\n api,\n mrId: params.mrId,\n cwd: params.cwd,\n mode: params.mode,\n allowBranchMismatch: params.allowBranchMismatch ?? false,\n });\n return {\n data: result,\n warnings: collectResultWarnings(result as { warnings?: unknown }),\n recommendedNextActions: [],\n logContext: {\n repoRoot: result.repoRoot ?? null,\n appId: result.targetAppId,\n mrId: result.mergeRequestId,\n },\n };\n}\n\nexport async function rejectMergeRequest(params: { mrId: string }) {\n const api = await createCollabApiClient();\n const result = await coreCollabReject({\n api,\n mrId: params.mrId,\n });\n return {\n data: result,\n warnings: [],\n recommendedNextActions: [],\n logContext: {\n mrId: params.mrId,\n },\n };\n}\n\nexport async function syncUpstream(params: { cwd: string }) {\n const api = await createCollabApiClient();\n const result = await coreCollabSyncUpstream({\n api,\n cwd: params.cwd,\n });\n return {\n data: result,\n warnings: collectResultWarnings(result as { warnings?: unknown }),\n recommendedNextActions: [],\n logContext: {\n repoRoot: result.repoRoot,\n appId: result.appId,\n mrId: \"mergeRequestId\" in result ? result.mergeRequestId ?? null : null,\n },\n };\n}\n\nexport async function reconcile(params: { cwd: string; dryRun: boolean; allowBranchMismatch?: boolean }) {\n const api = await createCollabApiClient();\n // Drain the local finalize queue synchronously before applying reconcile so\n // that any pending change steps are materialized remotely first; reconcile\n // operates on the server lane, and a stale lane caused by an unflushed\n // local queue can produce incorrect divergence-recovery decisions. Skip the\n // drain on dry-run previews to keep them side-effect-free as advertised.\n const drainWarnings = params.dryRun ? [] : await drainBeforeMutation(api);\n const result = await coreCollabReconcile({\n api,\n cwd: params.cwd,\n dryRun: params.dryRun,\n allowBranchMismatch: params.allowBranchMismatch ?? false,\n });\n return {\n data: result,\n warnings: [...drainWarnings, ...collectWarnings((result as { warnings?: unknown }).warnings)],\n recommendedNextActions: params.dryRun\n ? [\"Run remix_collab_reconcile_apply with confirm=true only if the preview is acceptable. This is the explicit Remix recovery flow for diverged state.\"]\n : [],\n risks: params.dryRun\n ? [\"Reconcile may upload local history to recover the server lane onto the latest agreed state before future recording continues.\"]\n : [],\n logContext: {\n repoRoot: (result as { repoRoot?: string | null }).repoRoot ?? null,\n },\n };\n}\n\nexport async function inviteCollaborator(params: {\n cwd: string;\n email: string;\n role?: string;\n scope?: InvitationScopeType;\n targetId?: string;\n ttlDays?: number;\n}) {\n const api = await createCollabApiClient();\n const result = await coreCollabInvite({\n api,\n cwd: params.cwd,\n email: params.email,\n role: params.role ?? null,\n scope: params.scope ?? \"project\",\n targetId: params.targetId ?? null,\n ttlDays: params.ttlDays,\n });\n return {\n data: result,\n warnings: [],\n recommendedNextActions: [],\n logContext: {},\n };\n}\n\nexport async function listMembers(params: {\n cwd: string;\n scope: InvitationScopeType;\n targetId?: string;\n limit?: number;\n offset?: number;\n}) {\n const api = await createCollabApiClient();\n const result = await coreCollabListMembers({\n api,\n cwd: params.cwd,\n scope: params.scope,\n targetId: params.targetId ?? null,\n limit: params.limit,\n offset: params.offset,\n });\n return {\n data: result,\n warnings: [],\n recommendedNextActions:\n result.pagination.hasMore ? [`Pass offset=${result.pagination.offset + result.pagination.limit} to load the next page.`] : [],\n logContext: {},\n };\n}\n\nexport async function updateMemberRole(params: {\n cwd: string;\n scope: InvitationScopeType;\n targetId?: string;\n userId: string;\n role: string;\n}) {\n const api = await createCollabApiClient();\n const result = await coreCollabUpdateMemberRole({\n api,\n cwd: params.cwd,\n scope: params.scope,\n targetId: params.targetId ?? null,\n userId: params.userId,\n role: params.role,\n });\n return {\n data: result,\n warnings: [],\n recommendedNextActions: [],\n logContext: {},\n };\n}\n","import { readCollabBinding, type CollabBinding } from \"@remixhq/core/binding\";\nimport { findGitRoot } from \"@remixhq/core/repo\";\nimport { ERROR_CODES, RemixMcpError } from \"../errors/errorCodes.js\";\n\nexport type ToolResult<T> = {\n\tdata: T;\n\twarnings?: string[];\n\trecommendedNextActions?: string[];\n\trisks?: string[];\n\tlogContext?: {\n\t\trepoRoot?: string | null;\n\t\tappId?: string | null;\n\t\tmrId?: string | null;\n\t};\n};\n\nexport type BindingContext = {\n\trepoRoot: string | null;\n\tbinding: CollabBinding | null;\n};\n\nexport function unwrapResponseObject<T>(resp: any, label: string): T {\n\tconst obj = resp?.responseObject;\n\tif (obj === undefined || obj === null) {\n\t\tthrow new Error(typeof resp?.message === \"string\" && resp.message.trim() ? resp.message : `Missing ${label} response`);\n\t}\n\treturn obj as T;\n}\n\nexport async function maybeFindGitRoot(cwd: string): Promise<string | null> {\n\ttry {\n\t\treturn await findGitRoot(cwd);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport async function loadBindingContext(cwd?: string): Promise<BindingContext> {\n\tif (!cwd) return { repoRoot: null, binding: null };\n\tconst repoRoot = await maybeFindGitRoot(cwd);\n\tif (!repoRoot) return { repoRoot: null, binding: null };\n\tconst binding = await readCollabBinding(repoRoot);\n\treturn {\n\t\trepoRoot,\n\t\tbinding,\n\t};\n}\n\nexport function makeNotBoundError(message = \"Repository is not bound to Remix.\", hint?: string): Error & { hint?: string } {\n\tconst error = new Error(message) as Error & { hint?: string };\n\terror.hint = hint ?? \"Run `remix_collab_init` in this repository, or pass the explicit id for a direct read.\";\n\treturn error;\n}\n\nfunction parseJsonObject(value: string | null): Record<string, unknown> | null {\n\tif (!value) return null;\n\ttry {\n\t\tconst parsed = JSON.parse(value);\n\t\treturn parsed && typeof parsed === \"object\" ? (parsed as Record<string, unknown>) : null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nexport function getBackendStatusCode(error: unknown): number | null {\n\tif (!error || typeof error !== \"object\") return null;\n\tconst hint =\n\t\t\"hint\" in error && typeof (error as { hint?: unknown }).hint === \"string\" ? ((error as { hint: string }).hint as string) : null;\n\tconst body = parseJsonObject(hint);\n\tif (typeof body?.statusCode === \"number\") return body.statusCode;\n\tif (typeof body?.statusCode === \"string\") {\n\t\tconst parsed = Number(body.statusCode);\n\t\treturn Number.isFinite(parsed) ? parsed : null;\n\t}\n\treturn null;\n}\n\nexport function isBackendForbidden(error: unknown): boolean {\n\treturn getBackendStatusCode(error) === 403;\n}\n\nexport function isBackendNotFound(error: unknown): boolean {\n\treturn getBackendStatusCode(error) === 404;\n}\n\nexport function createAccessDeniedError(message: string, hint?: string | null): RemixMcpError {\n\treturn new RemixMcpError({\n\t\tcode: ERROR_CODES.ACCESS_DENIED,\n\t\tmessage,\n\t\thint: hint ?? null,\n\t\tretryable: false,\n\t\tcategory: \"remote_state\",\n\t});\n}\n\nexport function createResourceNotFoundError(message: string, hint?: string | null): RemixMcpError {\n\treturn new RemixMcpError({\n\t\tcode: ERROR_CODES.RESOURCE_NOT_FOUND,\n\t\tmessage,\n\t\thint: hint ?? null,\n\t\tretryable: false,\n\t\tcategory: \"remote_state\",\n\t});\n}\n","import type { ApiClient, AppContext, InvitationRecord } from \"@remixhq/core\";\n\nimport { createApiClient } from \"./apiClient.js\";\nimport {\n\tcreateAccessDeniedError,\n\tisBackendForbidden,\n\tisBackendNotFound,\n\tloadBindingContext,\n\tmakeNotBoundError,\n\ttype ToolResult,\n\tunwrapResponseObject,\n} from \"./shared.js\";\n\ntype ScopeType = \"organization\" | \"project\" | \"app\";\ntype JsonRecord = Record<string, any>;\nconst MEMBERSHIP_PAGE_SIZE = 100;\ntype EffectiveAppRole = \"owner\" | \"maintainer\" | \"editor\" | \"viewer\" | null;\ntype PageInfo = { limit: number; offset: number; hasMore: boolean };\ntype PagedItems<T> = { items: T[]; pageInfo: PageInfo };\n\nfunction normalizePagination(params?: { limit?: number; offset?: number }) {\n\tconst rawLimit = typeof params?.limit === \"number\" ? Math.trunc(params.limit) : 25;\n\tconst rawOffset = typeof params?.offset === \"number\" ? Math.trunc(params.offset) : 0;\n\treturn {\n\t\tlimit: Math.max(1, Math.min(50, rawLimit)),\n\t\toffset: Math.max(0, rawOffset),\n\t};\n}\n\nasync function resolveScopeTarget(\n\tapi: ApiClient,\n\tparams: { scope: ScopeType; targetId?: string | null; cwd?: string },\n): Promise<{ scopeType: ScopeType; targetId: string; repoRoot: string | null }> {\n\tconst explicitTargetId = params.targetId?.trim();\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tif (explicitTargetId) {\n\t\treturn {\n\t\t\tscopeType: params.scope,\n\t\t\ttargetId: explicitTargetId,\n\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t};\n\t}\n\tif (!bindingContext.binding) {\n\t\tthrow makeNotBoundError(\"Scope target was not provided and the current repository is not bound to Remix.\");\n\t}\n\tif (params.scope === \"app\") {\n\t\treturn {\n\t\t\tscopeType: \"app\",\n\t\t\ttargetId: bindingContext.binding.currentAppId,\n\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t};\n\t}\n\tconst appContext = unwrapResponseObject<AppContext>(\n\t\tawait api.getAppContext(bindingContext.binding.currentAppId),\n\t\t\"bound app context\",\n\t);\n\tif (params.scope === \"project\") {\n\t\tif (!appContext.readableScopes.project) {\n\t\t\tthrow createAccessDeniedError(\n\t\t\t\t\"The bound app's project is not readable to the current user.\",\n\t\t\t\t\"Use `scope=app` for app-level diagnostics, or pass an explicit readable project id.\",\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\tscopeType: \"project\",\n\t\t\ttargetId: appContext.projectId,\n\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t};\n\t}\n\tif (!appContext.readableScopes.organization) {\n\t\tthrow createAccessDeniedError(\n\t\t\t\"The bound app's organization is not readable to the current user.\",\n\t\t\t\"Use `scope=app` or `scope=project` for narrower diagnostics, or pass an explicit readable organization id.\",\n\t\t);\n\t}\n\treturn {\n\t\tscopeType: \"organization\",\n\t\ttargetId: appContext.organizationId,\n\t\trepoRoot: bindingContext.repoRoot,\n\t};\n}\n\nasync function getScopeEntity(api: ApiClient, scopeType: ScopeType, targetId: string) {\n\tif (scopeType === \"organization\") {\n\t\treturn {\n\t\t\torganization: unwrapResponseObject<JsonRecord>(await api.getOrganization(targetId), \"organization\"),\n\t\t\tproject: null,\n\t\t\tapp: null,\n\t\t};\n\t}\n\tif (scopeType === \"project\") {\n\t\tconst project = unwrapResponseObject<JsonRecord>(await api.getProject(targetId), \"project\");\n\t\tconst organizationId = typeof project.organizationId === \"string\" ? project.organizationId : null;\n\t\treturn {\n\t\t\torganization:\n\t\t\t\torganizationId == null ? null : unwrapResponseObject<JsonRecord>(await api.getOrganization(organizationId), \"organization\"),\n\t\t\tproject,\n\t\t\tapp: null,\n\t\t};\n\t}\n\tconst app = unwrapResponseObject<JsonRecord>(await api.getApp(targetId), \"app\");\n\tconst projectId = typeof app.projectId === \"string\" ? app.projectId : null;\n\tconst project = projectId == null ? null : unwrapResponseObject<JsonRecord>(await api.getProject(projectId), \"project\");\n\tconst organizationId = typeof project?.organizationId === \"string\" ? project.organizationId : null;\n\treturn {\n\t\torganization:\n\t\t\torganizationId == null ? null : unwrapResponseObject<JsonRecord>(await api.getOrganization(organizationId), \"organization\"),\n\t\tproject,\n\t\tapp,\n\t};\n}\n\nfunction mapProjectRoleToAppRole(role: string | null): EffectiveAppRole {\n\tswitch (role) {\n\t\tcase \"owner\":\n\t\tcase \"maintainer\":\n\t\t\treturn \"maintainer\";\n\t\tcase \"editor\":\n\t\t\treturn \"editor\";\n\t\tcase \"viewer\":\n\t\t\treturn \"viewer\";\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\nfunction strongestRole(...roles: Array<EffectiveAppRole>): EffectiveAppRole {\n\tif (roles.includes(\"owner\")) return \"owner\";\n\tif (roles.includes(\"maintainer\")) return \"maintainer\";\n\tif (roles.includes(\"editor\")) return \"editor\";\n\tif (roles.includes(\"viewer\")) return \"viewer\";\n\treturn null;\n}\n\nfunction resolveAppAccessSource(params: {\n\tdirectAppRole: EffectiveAppRole;\n\tinheritedProjectRole: EffectiveAppRole;\n}): \"none\" | \"direct_app_membership\" | \"project_membership\" | \"both\" {\n\tif (params.directAppRole && params.inheritedProjectRole) return \"both\";\n\tif (params.directAppRole) return \"direct_app_membership\";\n\tif (params.inheritedProjectRole) return \"project_membership\";\n\treturn \"none\";\n}\n\nfunction buildEffectiveAppAccess(params: { directAppRole: string | null; projectRole: string | null }) {\n\tconst directAppRole = (params.directAppRole as EffectiveAppRole) ?? null;\n\tconst inheritedProjectRole = mapProjectRoleToAppRole(params.projectRole);\n\tconst effectiveRole = strongestRole(directAppRole, inheritedProjectRole);\n\treturn {\n\t\teffectiveRole,\n\t\tdirectAppRole,\n\t\tprojectRole: params.projectRole,\n\t\tinheritedProjectRole,\n\t\taccessSource: resolveAppAccessSource({ directAppRole, inheritedProjectRole }),\n\t\tcanReadWorkflow: effectiveRole !== null,\n\t\tcanEdit: effectiveRole === \"owner\" || effectiveRole === \"maintainer\" || effectiveRole === \"editor\",\n\t\tcanManage: effectiveRole === \"owner\" || effectiveRole === \"maintainer\",\n\t\tisOwner: directAppRole === \"owner\",\n\t};\n}\n\nasync function listMembersForScope(api: ApiClient, scopeType: ScopeType, targetId: string, params?: { limit?: number; offset?: number }): Promise<JsonRecord[]> {\n\tif (scopeType === \"organization\") {\n\t\treturn unwrapResponseObject<JsonRecord[]>(await api.listOrganizationMembers(targetId, params), \"organization members\");\n\t}\n\tif (scopeType === \"project\") {\n\t\treturn unwrapResponseObject<JsonRecord[]>(await api.listProjectMembers(targetId, params), \"project members\");\n\t}\n\treturn unwrapResponseObject<JsonRecord[]>(await api.listAppMembers(targetId, params), \"app members\");\n}\n\nasync function loadFirstPageSample<T>(fetchPage: (limit: number, offset: number) => Promise<T[]>): Promise<PagedItems<T>> {\n\tconst items = await fetchPage(MEMBERSHIP_PAGE_SIZE, 0);\n\tconst hasMore = items.length < MEMBERSHIP_PAGE_SIZE ? false : (await fetchPage(1, MEMBERSHIP_PAGE_SIZE)).length > 0;\n\treturn {\n\t\titems,\n\t\tpageInfo: {\n\t\t\tlimit: MEMBERSHIP_PAGE_SIZE,\n\t\t\toffset: 0,\n\t\t\thasMore,\n\t\t},\n\t};\n}\n\nfunction emptyFirstPageSample<T>(): PagedItems<T> {\n\treturn {\n\t\titems: [],\n\t\tpageInfo: {\n\t\t\tlimit: MEMBERSHIP_PAGE_SIZE,\n\t\t\toffset: 0,\n\t\t\thasMore: false,\n\t\t},\n\t};\n}\n\nasync function listInvitesForScope(\n\tapi: ApiClient,\n\tscopeType: ScopeType,\n\ttargetId: string,\n\tparams?: { limit?: number; offset?: number },\n): Promise<InvitationRecord[]> {\n\tif (scopeType === \"organization\") {\n\t\treturn unwrapResponseObject<InvitationRecord[]>(\n\t\t\tawait api.listOrganizationInvites(targetId, params),\n\t\t\t\"organization invites\",\n\t\t);\n\t}\n\tif (scopeType === \"project\") {\n\t\treturn unwrapResponseObject<InvitationRecord[]>(\n\t\t\tawait api.listProjectInvites(targetId, params),\n\t\t\t\"project invites\",\n\t\t);\n\t}\n\treturn unwrapResponseObject<InvitationRecord[]>(await api.listAppInvites(targetId, params), \"app invites\");\n}\n\nfunction getSelfMember(meId: string | null, members: JsonRecord[]) {\n\treturn meId == null ? null : members.find((member) => member.userId === meId || member.user_id === meId) ?? null;\n}\n\nasync function findPendingInviteForEmailForScope(\n\tapi: ApiClient,\n\tscopeType: ScopeType,\n\ttargetId: string,\n\temail: string | null,\n): Promise<InvitationRecord | null> {\n\tif (email == null) return null;\n\tlet offset = 0;\n\tfor (;;) {\n\t\tconst invites = await listInvitesForScope(api, scopeType, targetId, {\n\t\t\tlimit: MEMBERSHIP_PAGE_SIZE,\n\t\t\toffset,\n\t\t});\n\t\tconst match =\n\t\t\tinvites.find((invite) => invite.email.toLowerCase() === email && invite.state === \"pending\") ?? null;\n\t\tif (match) return match;\n\t\tif (invites.length < MEMBERSHIP_PAGE_SIZE) return null;\n\t\toffset += MEMBERSHIP_PAGE_SIZE;\n\t}\n}\n\nasync function findSelfMemberForScope(api: ApiClient, scopeType: ScopeType, targetId: string, meId: string | null): Promise<JsonRecord | null> {\n\tif (meId == null) return null;\n\tlet offset = 0;\n\tfor (;;) {\n\t\tconst members =\n\t\t\tscopeType === \"organization\"\n\t\t\t\t? unwrapResponseObject<JsonRecord[]>(\n\t\t\t\t\t\tawait api.listOrganizationMembers(targetId, { limit: MEMBERSHIP_PAGE_SIZE, offset }),\n\t\t\t\t\t\t\"organization members\",\n\t\t\t\t\t)\n\t\t\t\t: scopeType === \"project\"\n\t\t\t\t\t? unwrapResponseObject<JsonRecord[]>(\n\t\t\t\t\t\t\tawait api.listProjectMembers(targetId, { limit: MEMBERSHIP_PAGE_SIZE, offset }),\n\t\t\t\t\t\t\t\"project members\",\n\t\t\t\t\t\t)\n\t\t\t\t\t: unwrapResponseObject<JsonRecord[]>(\n\t\t\t\t\t\t\tawait api.listAppMembers(targetId, { limit: MEMBERSHIP_PAGE_SIZE, offset }),\n\t\t\t\t\t\t\t\"app members\",\n\t\t\t\t\t\t);\n\t\tconst match = getSelfMember(meId, members);\n\t\tif (match) return match;\n\t\tif (members.length < MEMBERSHIP_PAGE_SIZE) return null;\n\t\toffset += MEMBERSHIP_PAGE_SIZE;\n\t}\n}\n\nexport async function listInvites(params: {\n\tscope?: ScopeType | null;\n\ttargetId?: string | null;\n\tlimit?: number;\n\toffset?: number;\n\tcwd?: string;\n}): Promise<\n\tToolResult<{\n\t\tscopeType: ScopeType;\n\t\ttargetId: string;\n\t\tinvites: InvitationRecord[];\n\t\tpagination: { limit: number; offset: number; hasMore: boolean };\n\t}>\n> {\n\tconst api = await createApiClient();\n\tconst target = await resolveScopeTarget(api, {\n\t\tscope: params.scope ?? \"project\",\n\t\ttargetId: params.targetId,\n\t\tcwd: params.cwd,\n\t});\n\tconst pagination = normalizePagination(params);\n\tconst invites = await listInvitesForScope(api, target.scopeType, target.targetId, {\n\t\tlimit: pagination.limit + 1,\n\t\toffset: pagination.offset,\n\t});\n\treturn {\n\t\tdata: {\n\t\t\tscopeType: target.scopeType,\n\t\t\ttargetId: target.targetId,\n\t\t\tinvites: invites.slice(0, pagination.limit),\n\t\t\tpagination: {\n\t\t\t\t...pagination,\n\t\t\t\thasMore: invites.length > pagination.limit,\n\t\t\t},\n\t\t},\n\t\twarnings: [],\n\t\trecommendedNextActions:\n\t\t\tinvites.length > pagination.limit\n\t\t\t\t? [`Pass offset=${pagination.offset + pagination.limit} to load the next page.`]\n\t\t\t\t: invites.length > 0\n\t\t\t\t\t? [\"Use `remix_collab_resend_invite` or `remix_collab_revoke_invite` for lifecycle actions on a selected invite id.\"]\n\t\t\t\t: [\"Use `remix_collab_invite` if you need to create a new invitation for this scope.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: target.repoRoot,\n\t\t},\n\t};\n}\n\nexport async function resendInvite(params: {\n\tscope?: ScopeType | null;\n\ttargetId?: string | null;\n\tinviteId: string;\n\tttlDays?: number;\n\tcwd?: string;\n}): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveScopeTarget(api, {\n\t\tscope: params.scope ?? \"project\",\n\t\ttargetId: params.targetId,\n\t\tcwd: params.cwd,\n\t});\n\tconst response =\n\t\ttarget.scopeType === \"organization\"\n\t\t\t? await api.resendOrganizationInvite(target.targetId, params.inviteId, { ttlDays: params.ttlDays })\n\t\t\t: target.scopeType === \"project\"\n\t\t\t\t? await api.resendProjectInvite(target.targetId, params.inviteId, { ttlDays: params.ttlDays })\n\t\t\t\t: await api.resendAppInvite(target.targetId, params.inviteId, { ttlDays: params.ttlDays });\n\treturn {\n\t\tdata: unwrapResponseObject<JsonRecord>(response, \"resent invite\"),\n\t\twarnings: [],\n\t\trecommendedNextActions: [\"Use `remix_collab_list_invites` to confirm the refreshed expiry and delivery state.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: target.repoRoot,\n\t\t},\n\t};\n}\n\nexport async function revokeInvite(params: {\n\tscope?: ScopeType | null;\n\ttargetId?: string | null;\n\tinviteId: string;\n\tcwd?: string;\n}): Promise<ToolResult<{ scopeType: ScopeType; targetId: string; inviteId: string; revoked: boolean }>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveScopeTarget(api, {\n\t\tscope: params.scope ?? \"project\",\n\t\ttargetId: params.targetId,\n\t\tcwd: params.cwd,\n\t});\n\tif (target.scopeType === \"organization\") {\n\t\tawait api.revokeOrganizationInvite(target.targetId, params.inviteId);\n\t} else if (target.scopeType === \"project\") {\n\t\tawait api.revokeProjectInvite(target.targetId, params.inviteId);\n\t} else {\n\t\tawait api.revokeAppInvite(target.targetId, params.inviteId);\n\t}\n\treturn {\n\t\tdata: {\n\t\t\tscopeType: target.scopeType,\n\t\t\ttargetId: target.targetId,\n\t\t\tinviteId: params.inviteId,\n\t\t\trevoked: true,\n\t\t},\n\t\twarnings: [],\n\t\trecommendedNextActions: [\"Use `remix_collab_list_invites` to confirm the invite state is now `revoked`.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: target.repoRoot,\n\t\t},\n\t};\n}\n\nexport async function acceptInvitation(params: { token: string }): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst result = unwrapResponseObject<JsonRecord>(await api.acceptInvitation({ token: params.token }), \"accepted invitation\");\n\treturn {\n\t\tdata: result,\n\t\twarnings: [],\n\t\trecommendedNextActions: result.redirectPath\n\t\t\t? [`The invitation is accepted. Use the returned redirect metadata to continue with the newly granted Remix scope.`]\n\t\t\t: [],\n\t\tlogContext: {},\n\t};\n}\n\nexport async function accessDebug(params: {\n\tscope?: ScopeType | null;\n\ttargetId?: string | null;\n\tcwd?: string;\n}): Promise<\n\tToolResult<{\n\t\tviewer: JsonRecord;\n\t\tscope: { scopeType: ScopeType; targetId: string };\n\t\tentities: { organization: JsonRecord | null; project: JsonRecord | null; app: JsonRecord | null };\n\t\tbinding: { repoRoot: string | null; binding: JsonRecord | null };\n\t\taccess: {\n\t\t\tappContext: JsonRecord | null;\n\t\t\tviewerMember: JsonRecord | null;\n\t\t\tviewerProjectMember: JsonRecord | null;\n\t\t\tinviteForViewerEmail: InvitationRecord | null;\n\t\t\teffectiveAppAccess: ReturnType<typeof buildEffectiveAppAccess> | null;\n\t\t};\n\t\tmembers: JsonRecord[];\n\t\tmembersPageInfo: PageInfo;\n\t\tinvites: InvitationRecord[];\n\t\tinvitesPageInfo: PageInfo;\n\t}>\n> {\n\tconst api = await createApiClient();\n\tconst target = await resolveScopeTarget(api, {\n\t\tscope: params.scope ?? \"project\",\n\t\ttargetId: params.targetId,\n\t\tcwd: params.cwd,\n\t});\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tconst viewer = unwrapResponseObject<JsonRecord>(await api.getMe(), \"current user\");\n\tconst viewerId = typeof viewer.id === \"string\" ? viewer.id : null;\n\tconst viewerEmail = typeof viewer.email === \"string\" ? viewer.email.toLowerCase() : null;\n\tconst warnings = [...(bindingContext.binding ? [] : [\"No local Remix binding was detected for the provided cwd.\"])];\n\n\tlet entities: { organization: JsonRecord | null; project: JsonRecord | null; app: JsonRecord | null };\n\tlet appContext: AppContext | null = null;\n\tlet membersPage: PagedItems<JsonRecord> = emptyFirstPageSample();\n\tlet invitesPage: PagedItems<InvitationRecord> = emptyFirstPageSample();\n\tlet viewerMember: JsonRecord | null = null;\n\tlet viewerProjectMember: JsonRecord | null = null;\n\tlet inviteForViewerEmail: InvitationRecord | null = null;\n\tlet effectiveAppAccess: (ReturnType<typeof buildEffectiveAppAccess> & JsonRecord) | null = null;\n\n\tif (target.scopeType !== \"app\") {\n\t\t[entities, membersPage, invitesPage] = await Promise.all([\n\t\t\tgetScopeEntity(api, target.scopeType, target.targetId),\n\t\t\tloadFirstPageSample((limit, offset) => listMembersForScope(api, target.scopeType, target.targetId, { limit, offset })),\n\t\t\tloadFirstPageSample((limit, offset) => listInvitesForScope(api, target.scopeType, target.targetId, { limit, offset })),\n\t\t]);\n\t\tviewerMember = await findSelfMemberForScope(api, target.scopeType, target.targetId, viewerId);\n\t\tinviteForViewerEmail = await findPendingInviteForEmailForScope(api, target.scopeType, target.targetId, viewerEmail);\n\t} else {\n\t\tconst [app, loadedAppContext] = await Promise.all([\n\t\t\tunwrapResponseObject<JsonRecord>(await api.getApp(target.targetId), \"app\"),\n\t\t\tunwrapResponseObject<AppContext>(await api.getAppContext(target.targetId), \"app context\"),\n\t\t]);\n\t\tappContext = loadedAppContext;\n\t\tentities = {\n\t\t\torganization: null,\n\t\t\tproject: null,\n\t\t\tapp,\n\t\t};\n\n\t\tif (appContext.readableScopes.project) {\n\t\t\ttry {\n\t\t\t\tentities.project = unwrapResponseObject<JsonRecord>(await api.getProject(appContext.projectId), \"project\");\n\t\t\t} catch (error) {\n\t\t\t\tif (!isBackendForbidden(error) && !isBackendNotFound(error)) throw error;\n\t\t\t\twarnings.push(\"The app is readable, but its project/workspace metadata is not currently readable to the current user.\");\n\t\t\t}\n\t\t} else {\n\t\t\twarnings.push(\"The app is readable, but its project/workspace is not readable to the current user.\");\n\t\t}\n\n\t\tif (appContext.readableScopes.organization) {\n\t\t\ttry {\n\t\t\t\tentities.organization = unwrapResponseObject<JsonRecord>(await api.getOrganization(appContext.organizationId), \"organization\");\n\t\t\t} catch (error) {\n\t\t\t\tif (!isBackendForbidden(error) && !isBackendNotFound(error)) throw error;\n\t\t\t\twarnings.push(\"The app is readable, but its organization metadata is not currently readable to the current user.\");\n\t\t\t}\n\t\t} else {\n\t\t\twarnings.push(\"The app's organization is not readable to the current user.\");\n\t\t}\n\n\t\teffectiveAppAccess = {\n\t\t\t...buildEffectiveAppAccess({\n\t\t\t\tdirectAppRole: appContext.roles.appRole,\n\t\t\t\tprojectRole: appContext.roles.projectRole,\n\t\t\t}),\n\t\t\taccessPath: appContext.accessPath,\n\t\t\treadableScopes: appContext.readableScopes,\n\t\t\tvisibility: appContext.visibility,\n\t\t\torganizationRole: appContext.roles.organizationRole ?? null,\n\t\t};\n\n\t\tif (appContext.capabilities.canReadWorkflow) {\n\t\t\tmembersPage = await loadFirstPageSample((limit, offset) => listMembersForScope(api, \"app\", target.targetId, { limit, offset }));\n\t\t\tviewerMember = await findSelfMemberForScope(api, \"app\", target.targetId, viewerId);\n\t\t\tif (appContext.readableScopes.project) {\n\t\t\t\tviewerProjectMember = await findSelfMemberForScope(api, \"project\", appContext.projectId, viewerId);\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tinvitesPage = await loadFirstPageSample((limit, offset) => listInvitesForScope(api, \"app\", target.targetId, { limit, offset }));\n\t\t\t\tinviteForViewerEmail = await findPendingInviteForEmailForScope(api, \"app\", target.targetId, viewerEmail);\n\t\t\t} catch (error) {\n\t\t\t\tif (!isBackendForbidden(error) && !isBackendNotFound(error)) throw error;\n\t\t\t\twarnings.push(\"App invite data is not readable to the current user, so invite diagnostics are partial.\");\n\t\t\t}\n\t\t} else {\n\t\t\twarnings.push(\"The current viewer can read the app, but cannot read workflow-scoped app membership data.\");\n\t\t}\n\t}\n\n\tif (membersPage.pageInfo.hasMore) {\n\t\twarnings.push(\"The `members` array is a first-page sample only; use the scope member list tool to inspect the remaining entries.\");\n\t}\n\tif (invitesPage.pageInfo.hasMore) {\n\t\twarnings.push(\"The `invites` array is a first-page sample only; use the invite list tool with pagination to inspect the remaining entries.\");\n\t}\n\n\treturn {\n\t\tdata: {\n\t\t\tviewer,\n\t\t\tscope: {\n\t\t\t\tscopeType: target.scopeType,\n\t\t\t\ttargetId: target.targetId,\n\t\t\t},\n\t\t\tentities,\n\t\t\tbinding: {\n\t\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t\t\tbinding: bindingContext.binding,\n\t\t\t},\n\t\t\taccess: {\n\t\t\t\tappContext,\n\t\t\t\tviewerMember,\n\t\t\t\tviewerProjectMember,\n\t\t\t\tinviteForViewerEmail,\n\t\t\t\teffectiveAppAccess: effectiveAppAccess ?? null,\n\t\t\t},\n\t\t\tmembers: membersPage.items,\n\t\t\tmembersPageInfo: membersPage.pageInfo,\n\t\t\tinvites: invitesPage.items,\n\t\t\tinvitesPageInfo: invitesPage.pageInfo,\n\t\t},\n\t\twarnings,\n\t\trecommendedNextActions: inviteForViewerEmail\n\t\t\t? [\"A pending invite exists for the current viewer email. Use `remix_collab_accept_invitation` if the viewer should accept it.\"]\n\t\t\t: target.scopeType === \"app\"\n\t\t\t\t? [\"Use `access.appContext` and `access.effectiveAppAccess` together to explain app-level visibility versus workspace-level visibility.\"]\n\t\t\t\t: [\"Use the member and invite lists above to explain missing access, role mismatches, or stale invite state.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: target.repoRoot,\n\t\t\tappId: entities.app?.id ?? bindingContext.binding?.currentAppId ?? null,\n\t\t},\n\t};\n}\n","import { spawn } from \"node:child_process\";\nimport { existsSync, mkdirSync, openSync } from \"node:fs\";\nimport path from \"node:path\";\n\n// Auto-spawn helper for `remix history import` from inside the MCP\n// server. Mirrors `remix-cli/src/services/historyImport/autoSpawn.ts`\n// — see that file for the full design rationale (marker-file gating,\n// idempotency, self-healing on crashed first import, etc.).\n//\n// The MCP version differs from the CLI version in exactly one place:\n// it spawns the `remix` binary from PATH instead of re-invoking\n// `process.execPath` + `process.argv[1]`. The MCP process is started\n// by the user's agent client (Claude Code, Cursor); we have no\n// guarantee its argv points at anything useful, so PATH lookup is\n// the only sound option. The Remix CLI is a hard prerequisite for the\n// MCP server anyway (the user installed both together) so PATH should\n// always resolve.\n\nconst MARKER_REL_PATH = path.join(\".remix\", \".history-imported\");\nconst LOG_REL_PATH = path.join(\".remix\", \"history-import.log\");\n\nexport function shouldAutoSpawnHistoryImport(repoRoot: string): boolean {\n try {\n return !existsSync(path.join(repoRoot, MARKER_REL_PATH));\n } catch {\n return false;\n }\n}\n\nexport type AutoSpawnResult = {\n pid: number | undefined;\n logPath: string;\n};\n\nexport function spawnHistoryImportDetached(repoRoot: string): AutoSpawnResult {\n const remixDir = path.join(repoRoot, \".remix\");\n try {\n mkdirSync(remixDir, { recursive: true });\n } catch {\n // ignore — log open below will surface any real error\n }\n const logPath = path.join(repoRoot, LOG_REL_PATH);\n const out = openSync(logPath, \"a\");\n const err = openSync(logPath, \"a\");\n\n const child = spawn(\n \"remix\",\n [\n \"history\",\n \"import\",\n \"--repo\",\n repoRoot,\n // Include prompt text for parity with the CLI auto-spawn path:\n // first-time UX is a lot worse if the dashboard renders every\n // historical row as \"(prompt not uploaded)\".\n \"--include-prompt-text\",\n ],\n {\n detached: true,\n stdio: [\"ignore\", out, err],\n env: { ...process.env, REMIX_HISTORY_AUTO_SPAWN: \"1\" },\n },\n );\n child.unref();\n return { pid: child.pid, logPath };\n}\n","import { z } from \"zod\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { ToolAnnotations } from \"@modelcontextprotocol/sdk/types.js\";\n\nimport type { ServerContext } from \"../../bootstrap/context.js\";\nimport {\n\tgetAppSuccessSchema,\n\tgetOrganizationSuccessSchema,\n\tgetProjectSuccessSchema,\n\tlistAppsSuccessSchema,\n\tlistOrganizationsSuccessSchema,\n\tlistProjectsSuccessSchema,\n\twhoamiSuccessSchema,\n\tdirectoryAppInputSchema,\n\tdirectoryListAppsInputSchema,\n\tdirectoryListProjectsInputSchema,\n\tdirectoryOrganizationInputSchema,\n\tdirectoryProjectInputSchema,\n\twhoamiInputSchema,\n} from \"../../contracts/identity.js\";\nimport {\n\tmakeErrorResult,\n\tmakeErrorSchema,\n\tmakeSuccessResult,\n\ttype ErrorEnvelope,\n\ttype SuccessEnvelope,\n\tSCHEMA_VERSION,\n} from \"../../contracts/common.js\";\nimport type { NormalizedToolError } from \"../../errors/errorCodes.js\";\nimport { normalizeToolError } from \"../../errors/normalizeError.js\";\nimport {\n\tgetApp,\n\tgetOrganization,\n\tgetProject,\n\tlistApps,\n\tlistOrganizations,\n\tlistProjects,\n\twhoAmI,\n} from \"../../domain/directoryAdapter.js\";\nimport { assertToolAccess, resolvePolicyCwd, type ToolAccess } from \"../../policy/policy.js\";\n\ntype ToolExecutionResult<T> = {\n\tdata: T;\n\twarnings?: string[];\n\trisks?: string[];\n\trecommendedNextActions?: string[];\n\tlogContext?: {\n\t\trepoRoot?: string | null;\n\t\tappId?: string | null;\n\t\tmrId?: string | null;\n\t};\n};\n\nfunction getAnnotations(access: ToolAccess): ToolAnnotations {\n\treturn {\n\t\treadOnlyHint: access === \"read\",\n\t\tdestructiveHint: false,\n\t\tidempotentHint: true,\n\t\topenWorldHint: false,\n\t};\n}\n\nfunction buildSuccessEnvelope<T>(tool: string, requestId: string | undefined, result: ToolExecutionResult<T>): SuccessEnvelope<T> {\n\treturn {\n\t\tschemaVersion: SCHEMA_VERSION,\n\t\tok: true,\n\t\ttool,\n\t\trequestId: requestId ?? null,\n\t\tdata: result.data,\n\t\twarnings: result.warnings ?? [],\n\t\trisks: result.risks ?? [],\n\t\trecommendedNextActions: result.recommendedNextActions ?? [],\n\t};\n}\n\nfunction deriveErrorRisks(normalized: NormalizedToolError): string[] {\n\tif (normalized.code === \"DESTRUCTIVE_OPERATION_BLOCKED\") {\n\t\treturn [\"A policy guard blocked a disallowed operation.\"];\n\t}\n\treturn [];\n}\n\nfunction buildErrorEnvelope(tool: string, requestId: string | undefined, error: unknown): ErrorEnvelope {\n\tconst normalized = normalizeToolError(error);\n\treturn {\n\t\tschemaVersion: SCHEMA_VERSION,\n\t\tok: false,\n\t\ttool,\n\t\trequestId: requestId ?? null,\n\t\terror: normalized,\n\t\twarnings: [],\n\t\trisks: deriveErrorRisks(normalized),\n\t\trecommendedNextActions: normalized.code === \"AUTH_REQUIRED\" ? [\"Run `remix login` or set COMERGE_ACCESS_TOKEN, then retry.\"] : [],\n\t};\n}\n\nfunction registerTool<T>(\n\tserver: McpServer,\n\tcontext: ServerContext,\n\tparams: {\n\t\tname: string;\n\t\tdescription: string;\n\t\taccess: ToolAccess;\n\t\tinputSchema: Record<string, z.ZodTypeAny>;\n\t\toutputSchema: z.ZodTypeAny;\n\t\trun: (args: Record<string, unknown>) => Promise<ToolExecutionResult<T>>;\n\t},\n) {\n\tconst errorSchema = makeErrorSchema();\n\tserver.registerTool(\n\t\tparams.name,\n\t\t{\n\t\t\ttitle: params.name,\n\t\t\tdescription: params.description,\n\t\t\tinputSchema: params.inputSchema,\n\t\t\toutputSchema: params.outputSchema,\n\t\t\tannotations: getAnnotations(params.access),\n\t\t},\n\t\tasync (rawArgs: Record<string, unknown>) => {\n\t\t\tconst requestId = typeof rawArgs.requestId === \"string\" ? rawArgs.requestId : undefined;\n\t\t\tconst startedAt = Date.now();\n\t\t\ttry {\n\t\t\t\tassertToolAccess(context.policy, params.access);\n\t\t\t\tconst result = await params.run(rawArgs);\n\t\t\t\tconst envelope = buildSuccessEnvelope(params.name, requestId, result);\n\t\t\t\tparams.outputSchema.parse(envelope);\n\t\t\t\tcontext.logger.log({\n\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\tmessage: \"tool_completed\",\n\t\t\t\t\ttool: params.name,\n\t\t\t\t\trequestId: envelope.requestId,\n\t\t\t\t\tdurationMs: Date.now() - startedAt,\n\t\t\t\t\tresult: \"success\",\n\t\t\t\t\trepoRoot: result.logContext?.repoRoot ?? null,\n\t\t\t\t\tappId: result.logContext?.appId ?? null,\n\t\t\t\t\tmrId: result.logContext?.mrId ?? null,\n\t\t\t\t});\n\t\t\t\treturn makeSuccessResult(envelope);\n\t\t\t} catch (error) {\n\t\t\t\tconst envelope = buildErrorEnvelope(params.name, requestId, error);\n\t\t\t\terrorSchema.parse(envelope);\n\t\t\t\tcontext.logger.log({\n\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\tmessage: \"tool_failed\",\n\t\t\t\t\ttool: params.name,\n\t\t\t\t\trequestId: envelope.requestId,\n\t\t\t\t\tdurationMs: Date.now() - startedAt,\n\t\t\t\t\tresult: \"error\",\n\t\t\t\t\terrorCode: envelope.error.code,\n\t\t\t\t});\n\t\t\t\treturn makeErrorResult(envelope);\n\t\t\t}\n\t\t},\n\t);\n}\n\nexport function registerIdentityTools(server: McpServer, context: ServerContext): void {\n\tregisterTool(server, context, {\n\t\tname: \"remix_identity_whoami\",\n\t\tdescription: \"Show the authenticated Remix user and, when cwd is provided, the current local binding and any immediately derivable roles for that bound workspace.\",\n\t\taccess: \"read\",\n\t\tinputSchema: whoamiInputSchema,\n\t\toutputSchema: whoamiSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(whoamiInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn whoAmI({ cwd });\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_directory_list_organizations\",\n\t\tdescription: \"List organizations visible to the authenticated Remix user.\",\n\t\taccess: \"read\",\n\t\tinputSchema: whoamiInputSchema,\n\t\toutputSchema: listOrganizationsSuccessSchema,\n\t\trun: async () => listOrganizations(),\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_directory_get_organization\",\n\t\tdescription: \"Fetch one organization by id, or infer the bound repository's organization from cwd when possible.\",\n\t\taccess: \"read\",\n\t\tinputSchema: directoryOrganizationInputSchema,\n\t\toutputSchema: getOrganizationSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(directoryOrganizationInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn getOrganization({\n\t\t\t\torganizationId: input.organizationId,\n\t\t\t\tcwd,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_directory_list_projects\",\n\t\tdescription: \"List projects visible to the authenticated user, optionally narrowed to one organization or client app.\",\n\t\taccess: \"read\",\n\t\tinputSchema: directoryListProjectsInputSchema,\n\t\toutputSchema: listProjectsSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(directoryListProjectsInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn listProjects({\n\t\t\t\torganizationId: input.organizationId,\n\t\t\t\tclientAppId: input.clientAppId,\n\t\t\t\tcwd,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_directory_get_project\",\n\t\tdescription: \"Fetch one project by id, or infer the bound repository's project from cwd when possible.\",\n\t\taccess: \"read\",\n\t\tinputSchema: directoryProjectInputSchema,\n\t\toutputSchema: getProjectSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(directoryProjectInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn getProject({\n\t\t\t\tprojectId: input.projectId,\n\t\t\t\tcwd,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_directory_list_apps\",\n\t\tdescription:\n\t\t\t\"List apps visible to the authenticated user, with optional organization, project, ownership, and access-scope filters. Defaults to membership-oriented discovery unless accessScope=all_readable is passed explicitly.\",\n\t\taccess: \"read\",\n\t\tinputSchema: directoryListAppsInputSchema,\n\t\toutputSchema: listAppsSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(directoryListAppsInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn listApps({\n\t\t\t\tprojectId: input.projectId,\n\t\t\t\torganizationId: input.organizationId,\n\t\t\t\townership: input.ownership,\n\t\t\t\taccessScope: input.accessScope,\n\t\t\t\tcreatedBy: input.createdBy,\n\t\t\t\tforked: input.forked,\n\t\t\t\tlimit: input.limit,\n\t\t\t\toffset: input.offset,\n\t\t\t\tcwd,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_directory_get_app\",\n\t\tdescription: \"Fetch one app by id, or infer the bound repository's current app from cwd when possible.\",\n\t\taccess: \"read\",\n\t\tinputSchema: directoryAppInputSchema,\n\t\toutputSchema: getAppSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(directoryAppInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn getApp({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t});\n\t\t},\n\t});\n}\n","import { z } from \"zod\";\n\nimport { commonRequestFieldsSchema, makeSuccessSchema } from \"./common.js\";\n\nconst genericRecordSchema = z.record(z.string(), z.unknown());\nconst genericArraySchema = z.array(genericRecordSchema);\nconst paginationSchema = z.object({\n\tlimit: z.number().int().positive(),\n\toffset: z.number().int().nonnegative(),\n\thasMore: z.boolean(),\n});\n\nexport const whoamiInputSchema = {\n\t...commonRequestFieldsSchema,\n};\n\nexport const directoryOrganizationInputSchema = {\n\t...commonRequestFieldsSchema,\n\torganizationId: z.string().trim().min(1).optional(),\n};\n\nexport const directoryListProjectsInputSchema = {\n\t...commonRequestFieldsSchema,\n\torganizationId: z.string().trim().min(1).optional(),\n\tclientAppId: z.string().trim().min(1).optional(),\n};\n\nexport const directoryProjectInputSchema = {\n\t...commonRequestFieldsSchema,\n\tprojectId: z.string().trim().min(1).optional(),\n};\n\nexport const directoryListAppsInputSchema = {\n\t...commonRequestFieldsSchema,\n\tprojectId: z.string().trim().min(1).optional(),\n\torganizationId: z.string().trim().min(1).optional(),\n\townership: z.enum([\"mine\", \"shared\", \"all\"]).optional(),\n\taccessScope: z.enum([\"all_readable\", \"explicit_member\"]).optional(),\n\tcreatedBy: z.string().trim().min(1).optional(),\n\tforked: z.enum([\"only\", \"exclude\", \"all\"]).optional(),\n\tlimit: z.number().int().positive().max(50).optional(),\n\toffset: z.number().int().nonnegative().optional(),\n};\n\nexport const directoryAppInputSchema = {\n\t...commonRequestFieldsSchema,\n\tappId: z.string().trim().min(1).optional(),\n};\n\nexport const whoamiDataSchema = z.object({\n\tid: z.string().nullable(),\n\tname: z.string().nullable(),\n\temail: z.string().nullable(),\n\torganizationId: z.string().nullable(),\n\troles: genericRecordSchema,\n\tbinding: genericRecordSchema.nullable(),\n});\nexport const listOrganizationsDataSchema = z.object({\n\torganizations: genericArraySchema,\n});\nexport const getOrganizationDataSchema = z.object({\n\torganization: genericRecordSchema,\n});\nexport const listProjectsDataSchema = z.object({\n\torganizationId: z.string().nullable(),\n\tprojects: genericArraySchema,\n});\nexport const getProjectDataSchema = z.object({\n\tproject: genericRecordSchema,\n});\nexport const listAppsDataSchema = z.object({\n\tapps: genericArraySchema,\n\tpagination: paginationSchema,\n\tfilters: z.object({\n\t\tprojectId: z.string().nullable(),\n\t\torganizationId: z.string().nullable(),\n\t\townership: z.enum([\"mine\", \"shared\", \"all\"]),\n\t\taccessScope: z.enum([\"all_readable\", \"explicit_member\"]),\n\t\tcreatedBy: z.string().nullable(),\n\t\tforked: z.enum([\"only\", \"exclude\", \"all\"]),\n\t}),\n});\nexport const getAppDataSchema = z.object({\n\tapp: genericRecordSchema,\n});\n\nexport const whoamiSuccessSchema = makeSuccessSchema(whoamiDataSchema);\nexport const listOrganizationsSuccessSchema = makeSuccessSchema(listOrganizationsDataSchema);\nexport const getOrganizationSuccessSchema = makeSuccessSchema(getOrganizationDataSchema);\nexport const listProjectsSuccessSchema = makeSuccessSchema(listProjectsDataSchema);\nexport const getProjectSuccessSchema = makeSuccessSchema(getProjectDataSchema);\nexport const listAppsSuccessSchema = makeSuccessSchema(listAppsDataSchema);\nexport const getAppSuccessSchema = makeSuccessSchema(getAppDataSchema);\n","import type { ApiClient, AppContext } from \"@remixhq/core\";\n\nimport { createApiClient } from \"./apiClient.js\";\nimport {\n\tcreateAccessDeniedError,\n\tisBackendForbidden,\n\tisBackendNotFound,\n\tloadBindingContext,\n\tmakeNotBoundError,\n\ttype ToolResult,\n\tunwrapResponseObject,\n} from \"./shared.js\";\n\ntype JsonRecord = Record<string, any>;\ntype EffectiveAppRole = \"owner\" | \"maintainer\" | \"editor\" | \"viewer\" | null;\n\nfunction normalizePagination(params?: { limit?: number; offset?: number }) {\n\tconst rawLimit = typeof params?.limit === \"number\" ? Math.trunc(params.limit) : 25;\n\tconst rawOffset = typeof params?.offset === \"number\" ? Math.trunc(params.offset) : 0;\n\treturn {\n\t\tlimit: Math.max(1, Math.min(50, rawLimit)),\n\t\toffset: Math.max(0, rawOffset),\n\t};\n}\n\nasync function resolveOrganizationId(api: ApiClient, params: { organizationId?: string; cwd?: string }): Promise<string> {\n\tconst explicitId = params.organizationId?.trim();\n\tif (explicitId) return explicitId;\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tif (!bindingContext.binding) {\n\t\tthrow makeNotBoundError(\"Organization id was not provided and the current repository is not bound to Remix.\");\n\t}\n\tconst appContext = unwrapResponseObject<AppContext>(\n\t\tawait api.getAppContext(bindingContext.binding.currentAppId),\n\t\t\"bound app context\",\n\t);\n\tif (!appContext.readableScopes.organization) {\n\t\tthrow createAccessDeniedError(\n\t\t\t\"The bound app's organization is not readable to the current user.\",\n\t\t\t\"Use an explicit organization id you can access, or inspect the bound app with `remix_directory_get_app` / `remix_access_debug` for app-level context.\",\n\t\t);\n\t}\n\treturn appContext.organizationId;\n}\n\nasync function resolveProjectId(api: ApiClient, params: { projectId?: string; cwd?: string }): Promise<{ projectId: string; repoRoot: string | null }> {\n\tconst explicitId = params.projectId?.trim();\n\tif (explicitId) {\n\t\tconst bindingContext = await loadBindingContext(params.cwd);\n\t\treturn { projectId: explicitId, repoRoot: bindingContext.repoRoot };\n\t}\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tif (!bindingContext.binding) {\n\t\tthrow makeNotBoundError(\"Project id was not provided and the current repository is not bound to Remix.\");\n\t}\n\tconst appContext = unwrapResponseObject<AppContext>(\n\t\tawait api.getAppContext(bindingContext.binding.currentAppId),\n\t\t\"bound app context\",\n\t);\n\tif (!appContext.readableScopes.project) {\n\t\tthrow createAccessDeniedError(\n\t\t\t\"The bound app's project is not readable to the current user.\",\n\t\t\t\"Use `remix_directory_get_app` or `remix_access_debug` for app-level diagnostics, or pass an explicit project id you can access.\",\n\t\t);\n\t}\n\treturn {\n\t\tprojectId: appContext.projectId,\n\t\trepoRoot: bindingContext.repoRoot,\n\t};\n}\n\nasync function resolveAppId(params: { appId?: string; cwd?: string }): Promise<{ appId: string; repoRoot: string | null }> {\n\tconst explicitId = params.appId?.trim();\n\tif (explicitId) {\n\t\tconst bindingContext = await loadBindingContext(params.cwd);\n\t\treturn { appId: explicitId, repoRoot: bindingContext.repoRoot };\n\t}\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tif (!bindingContext.binding) {\n\t\tthrow makeNotBoundError(\"App id was not provided and the current repository is not bound to Remix.\");\n\t}\n\treturn {\n\t\tappId: bindingContext.binding.currentAppId,\n\t\trepoRoot: bindingContext.repoRoot,\n\t};\n}\n\nfunction toEffectiveAppRole(role: string | null): EffectiveAppRole {\n\tswitch (role) {\n\t\tcase \"owner\":\n\t\tcase \"maintainer\":\n\t\tcase \"editor\":\n\t\tcase \"viewer\":\n\t\t\treturn role;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\nfunction resolveAppAccessSource(params: {\n\tdirectAppRole: EffectiveAppRole;\n\tinheritedProjectRole: EffectiveAppRole;\n}): \"none\" | \"direct_app_membership\" | \"project_membership\" | \"both\" {\n\tif (params.directAppRole && params.inheritedProjectRole) return \"both\";\n\tif (params.directAppRole) return \"direct_app_membership\";\n\tif (params.inheritedProjectRole) return \"project_membership\";\n\treturn \"none\";\n}\n\nfunction emptySelfRoles() {\n\treturn {\n\t\torganizationRole: null,\n\t\tprojectRole: null,\n\t\tappRole: null,\n\t\tdirectAppRole: null,\n\t\tinheritedProjectRole: null,\n\t\tappAccessSource: \"none\" as const,\n\t};\n}\n\nfunction resolveSelfRolesFromAppContext(appContext: AppContext | null) {\n\tif (!appContext) return emptySelfRoles();\n\tconst directAppRole = toEffectiveAppRole(appContext.roles.appRole);\n\tconst inheritedProjectRole = toEffectiveAppRole(appContext.roles.inheritedProjectRole);\n\treturn {\n\t\torganizationRole: appContext.roles.organizationRole ?? null,\n\t\tprojectRole: appContext.roles.projectRole ?? null,\n\t\tappRole: toEffectiveAppRole(appContext.roles.effectiveAppRole),\n\t\tdirectAppRole,\n\t\tinheritedProjectRole,\n\t\tappAccessSource: resolveAppAccessSource({ directAppRole, inheritedProjectRole }),\n\t};\n}\n\nexport async function whoAmI(params: { cwd?: string }): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tconst me = unwrapResponseObject<JsonRecord>(await api.getMe(), \"current user\");\n\tconst warnings: string[] = bindingContext.binding ? [] : [\"No local Remix binding was detected for the provided cwd.\"];\n\tlet boundAppContext: AppContext | null = null;\n\tlet boundProject: JsonRecord | null = null;\n\tlet boundApp: JsonRecord | null = null;\n\tif (bindingContext.binding) {\n\t\ttry {\n\t\t\tboundAppContext = unwrapResponseObject<AppContext>(\n\t\t\t\tawait api.getAppContext(bindingContext.binding.currentAppId),\n\t\t\t\t\"bound app context\",\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tif (!isBackendForbidden(error) && !isBackendNotFound(error)) throw error;\n\t\t\twarnings.push(\n\t\t\t\t\"The bound app context could not be loaded. The local binding may be stale, or the current user may no longer be able to read that app.\",\n\t\t\t);\n\t\t}\n\t\ttry {\n\t\t\tboundApp = unwrapResponseObject<JsonRecord>(await api.getApp(bindingContext.binding.currentAppId), \"app\");\n\t\t} catch (error) {\n\t\t\tif (!isBackendForbidden(error) && !isBackendNotFound(error)) throw error;\n\t\t\twarnings.push(\"The bound app metadata could not be loaded for the current user.\");\n\t\t}\n\t\tif (boundAppContext?.readableScopes.project) {\n\t\t\ttry {\n\t\t\t\tboundProject = unwrapResponseObject<JsonRecord>(await api.getProject(boundAppContext.projectId), \"project\");\n\t\t\t} catch (error) {\n\t\t\t\tif (!isBackendForbidden(error) && !isBackendNotFound(error)) throw error;\n\t\t\t\twarnings.push(\"The bound app is readable, but its project metadata is not currently readable to the current user.\");\n\t\t\t}\n\t\t} else if (boundAppContext) {\n\t\t\twarnings.push(\"The bound app is readable, but its project/workspace is not readable to the current user.\");\n\t\t}\n\t}\n\tconst roles = resolveSelfRolesFromAppContext(boundAppContext);\n\treturn {\n\t\tdata: {\n\t\t\tid: me.id ?? null,\n\t\t\tname: me.name ?? null,\n\t\t\temail: me.email ?? null,\n\t\t\torganizationId: me.organizationId ?? null,\n\t\t\troles,\n\t\t\tbinding:\n\t\t\t\tbindingContext.binding == null\n\t\t\t\t\t? null\n\t\t\t\t\t: {\n\t\t\t\t\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t\t\t\t\t\t...bindingContext.binding,\n\t\t\t\t\t\t\tprojectId: boundAppContext?.projectId ?? bindingContext.binding.projectId,\n\t\t\t\t\t\t\torganizationId: boundAppContext?.organizationId ?? null,\n\t\t\t\t\t\t\tvisibility: boundAppContext?.visibility ?? null,\n\t\t\t\t\t\t\taccessPath: boundAppContext?.accessPath ?? null,\n\t\t\t\t\t\t\treadableScopes: boundAppContext?.readableScopes ?? null,\n\t\t\t\t\t\t\tprojectName: boundProject?.name ?? null,\n\t\t\t\t\t\t\tappName: boundApp?.name ?? null,\n\t\t\t\t\t\t},\n\t\t},\n\t\twarnings,\n\t\trecommendedNextActions: bindingContext.binding\n\t\t\t? [\"Use `remix_access_debug` next when you need to explain repository binding or membership issues in this workspace.\"]\n\t\t\t: [\"Use `remix_directory_list_organizations` to inspect visible tenancy context, or run `remix_collab_init` in a repository to create a local binding.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t\tappId: bindingContext.binding?.currentAppId ?? null,\n\t\t},\n\t};\n}\n\nexport async function listOrganizations(): Promise<ToolResult<{ organizations: JsonRecord[] }>> {\n\tconst api = await createApiClient();\n\tconst organizations = unwrapResponseObject<JsonRecord[]>(await api.listOrganizations(), \"organizations\");\n\treturn {\n\t\tdata: { organizations },\n\t\twarnings: [],\n\t\trecommendedNextActions: organizations.length\n\t\t\t? [\"Use `remix_directory_get_organization` for one organization, or `remix_directory_list_projects` to inspect projects under a chosen organization.\"]\n\t\t\t: [],\n\t\tlogContext: {},\n\t};\n}\n\nexport async function getOrganization(params: { organizationId?: string; cwd?: string }): Promise<ToolResult<{ organization: JsonRecord }>> {\n\tconst api = await createApiClient();\n\tconst organizationId = await resolveOrganizationId(api, params);\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tconst organization = unwrapResponseObject<JsonRecord>(await api.getOrganization(organizationId), \"organization\");\n\treturn {\n\t\tdata: { organization },\n\t\twarnings: [],\n\t\trecommendedNextActions: [\"Use `remix_directory_list_projects` with this organization id to inspect its project directory.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t},\n\t};\n}\n\nexport async function listProjects(params: {\n\torganizationId?: string;\n\tclientAppId?: string;\n\tcwd?: string;\n}): Promise<ToolResult<{ projects: JsonRecord[]; organizationId: string | null }>> {\n\tconst api = await createApiClient();\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tconst organizationId =\n\t\tparams.organizationId !== undefined ? await resolveOrganizationId(api, { organizationId: params.organizationId, cwd: params.cwd }) : null;\n\tconst projects = unwrapResponseObject<JsonRecord[]>(\n\t\tawait api.listProjects({\n\t\t\torganizationId: organizationId ?? undefined,\n\t\t\tclientAppId: params.clientAppId,\n\t\t}),\n\t\t\"projects\",\n\t);\n\treturn {\n\t\tdata: {\n\t\t\tprojects,\n\t\t\torganizationId,\n\t\t},\n\t\twarnings: [],\n\t\trecommendedNextActions: projects.length\n\t\t\t? [\"Use `remix_directory_get_project` for one project, or `remix_directory_list_apps` to inspect apps under a chosen project or organization.\"]\n\t\t\t: [],\n\t\tlogContext: {\n\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t\tappId: bindingContext.binding?.currentAppId ?? null,\n\t\t},\n\t};\n}\n\nexport async function getProject(params: { projectId?: string; cwd?: string }): Promise<ToolResult<{ project: JsonRecord }>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveProjectId(api, params);\n\tconst project = unwrapResponseObject<JsonRecord>(await api.getProject(target.projectId), \"project\");\n\treturn {\n\t\tdata: { project },\n\t\twarnings: [],\n\t\trecommendedNextActions: [\"Use `remix_directory_list_apps` with this project id to inspect apps under the project.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: target.repoRoot,\n\t\t},\n\t};\n}\n\nexport async function listApps(params: {\n\tprojectId?: string;\n\torganizationId?: string;\n\townership?: \"mine\" | \"shared\" | \"all\";\n\taccessScope?: \"all_readable\" | \"explicit_member\";\n\tcreatedBy?: string;\n\tforked?: \"only\" | \"exclude\" | \"all\";\n\tlimit?: number;\n\toffset?: number;\n\tcwd?: string;\n}): Promise<\n\tToolResult<{\n\t\tapps: JsonRecord[];\n\t\tpagination: { limit: number; offset: number; hasMore: boolean };\n\t\tfilters: {\n\t\t\tprojectId: string | null;\n\t\t\torganizationId: string | null;\n\t\t\townership: \"mine\" | \"shared\" | \"all\";\n\t\t\taccessScope: \"all_readable\" | \"explicit_member\";\n\t\t\tcreatedBy: string | null;\n\t\t\tforked: \"only\" | \"exclude\" | \"all\";\n\t\t};\n\t}>\n> {\n\tconst api = await createApiClient();\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tconst pagination = normalizePagination(params);\n\tconst apps = unwrapResponseObject<JsonRecord[]>(\n\t\tawait api.listApps({\n\t\t\tprojectId: params.projectId,\n\t\t\torganizationId: params.organizationId,\n\t\t\townership: params.ownership ?? \"all\",\n\t\t\taccessScope: params.accessScope ?? \"explicit_member\",\n\t\t\tcreatedBy: params.createdBy,\n\t\t\tforked: params.forked,\n\t\t\tlimit: pagination.limit + 1,\n\t\t\toffset: pagination.offset,\n\t\t}),\n\t\t\"apps\",\n\t);\n\treturn {\n\t\tdata: {\n\t\t\tapps: apps.slice(0, pagination.limit),\n\t\t\tpagination: {\n\t\t\t\t...pagination,\n\t\t\t\thasMore: apps.length > pagination.limit,\n\t\t\t},\n\t\t\tfilters: {\n\t\t\t\tprojectId: params.projectId ?? null,\n\t\t\t\torganizationId: params.organizationId ?? null,\n\t\t\t\townership: params.ownership ?? \"all\",\n\t\t\t\taccessScope: params.accessScope ?? \"explicit_member\",\n\t\t\t\tcreatedBy: params.createdBy ?? null,\n\t\t\t\tforked: params.forked ?? \"all\",\n\t\t\t},\n\t\t},\n\t\twarnings: [],\n\t\trecommendedNextActions:\n\t\t\tapps.length > pagination.limit\n\t\t\t\t? [`Pass offset=${pagination.offset + pagination.limit} to load the next page.`]\n\t\t\t\t: [\"Use `remix_directory_get_app` for one app, or `remix_context_get_app_overview` for operational context on a chosen app.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t\tappId: bindingContext.binding?.currentAppId ?? null,\n\t\t},\n\t};\n}\n\nexport async function getApp(params: { appId?: string; cwd?: string }): Promise<ToolResult<{ app: JsonRecord }>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppId(params);\n\tconst app = unwrapResponseObject<JsonRecord>(await api.getApp(target.appId), \"app\");\n\treturn {\n\t\tdata: { app },\n\t\twarnings: [],\n\t\trecommendedNextActions: [\"Use `remix_context_get_app_overview` for status and capability context, or `remix_ops_list_timeline` for bounded historical activity.\"],\n\t\tlogContext: {\n\t\t\trepoRoot: target.repoRoot,\n\t\t\tappId: target.appId,\n\t\t},\n\t};\n}\n","import { z } from \"zod\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { ToolAnnotations } from \"@modelcontextprotocol/sdk/types.js\";\n\nimport type { ServerContext } from \"../../bootstrap/context.js\";\nimport {\n changeStepDiffInputSchema,\n changeStepDiffSuccessSchema,\n memorySearchInputSchema,\n memorySearchSuccessSchema,\n memorySummaryInputSchema,\n memorySummarySuccessSchema,\n memoryTimelineInputSchema,\n memoryTimelineSuccessSchema,\n} from \"../../contracts/memory.js\";\nimport {\n makeErrorResult,\n makeErrorSchema,\n makeSuccessResult,\n type ErrorEnvelope,\n type SuccessEnvelope,\n SCHEMA_VERSION,\n} from \"../../contracts/common.js\";\nimport type { NormalizedToolError } from \"../../errors/errorCodes.js\";\nimport { normalizeToolError } from \"../../errors/normalizeError.js\";\nimport { getChangeStepDiff, getMemorySummary, getMemoryTimeline, searchMemory } from \"../../domain/memoryAdapter.js\";\nimport { assertToolAccess, resolvePolicyCwd, type ToolAccess } from \"../../policy/policy.js\";\n\ntype ToolExecutionResult<T> = {\n data: T;\n warnings?: string[];\n risks?: string[];\n recommendedNextActions?: string[];\n logContext?: {\n repoRoot?: string | null;\n appId?: string | null;\n mrId?: string | null;\n };\n};\n\nfunction getAnnotations(access: ToolAccess): ToolAnnotations {\n return {\n readOnlyHint: access === \"read\",\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n };\n}\n\nfunction buildSuccessEnvelope<T>(tool: string, requestId: string | undefined, result: ToolExecutionResult<T>): SuccessEnvelope<T> {\n return {\n schemaVersion: SCHEMA_VERSION,\n ok: true,\n tool,\n requestId: requestId ?? null,\n data: result.data,\n warnings: result.warnings ?? [],\n risks: result.risks ?? [],\n recommendedNextActions: result.recommendedNextActions ?? [],\n };\n}\n\nfunction buildErrorEnvelope(tool: string, requestId: string | undefined, error: unknown): ErrorEnvelope {\n const normalized = normalizeToolError(error);\n return {\n schemaVersion: SCHEMA_VERSION,\n ok: false,\n tool,\n requestId: requestId ?? null,\n error: normalized,\n warnings: [],\n risks: deriveErrorRisks(normalized),\n recommendedNextActions: normalized.code === \"AUTH_REQUIRED\" ? [\"Run `remix login` or set COMERGE_ACCESS_TOKEN, then retry.\"] : [],\n };\n}\n\nfunction deriveErrorRisks(normalized: NormalizedToolError): string[] {\n if (normalized.code === \"DESTRUCTIVE_OPERATION_BLOCKED\") {\n return [\"A policy guard blocked a disallowed operation.\"];\n }\n return [];\n}\n\nfunction registerTool<T>(\n server: McpServer,\n context: ServerContext,\n params: {\n name: string;\n description: string;\n access: ToolAccess;\n inputSchema: Record<string, z.ZodTypeAny>;\n outputSchema: z.ZodTypeAny;\n run: (args: Record<string, unknown>) => Promise<ToolExecutionResult<T>>;\n },\n) {\n const errorSchema = makeErrorSchema();\n server.registerTool(\n params.name,\n {\n title: params.name,\n description: params.description,\n inputSchema: params.inputSchema,\n outputSchema: params.outputSchema,\n annotations: getAnnotations(params.access),\n },\n async (rawArgs: Record<string, unknown>) => {\n const requestId = typeof rawArgs.requestId === \"string\" ? rawArgs.requestId : undefined;\n const startedAt = Date.now();\n try {\n assertToolAccess(context.policy, params.access);\n const result = await params.run(rawArgs);\n const envelope = buildSuccessEnvelope(params.name, requestId, result);\n params.outputSchema.parse(envelope);\n context.logger.log({\n level: \"info\",\n message: \"tool_completed\",\n tool: params.name,\n requestId: envelope.requestId,\n durationMs: Date.now() - startedAt,\n result: \"success\",\n repoRoot: result.logContext?.repoRoot ?? null,\n appId: result.logContext?.appId ?? null,\n mrId: result.logContext?.mrId ?? null,\n truncated: result.warnings?.some((warning) => warning.toLowerCase().includes(\"truncated\")) ?? false,\n });\n return makeSuccessResult(envelope);\n } catch (error) {\n const envelope = buildErrorEnvelope(params.name, requestId, error);\n errorSchema.parse(envelope);\n context.logger.log({\n level: \"error\",\n message: \"tool_failed\",\n tool: params.name,\n requestId: envelope.requestId,\n durationMs: Date.now() - startedAt,\n result: \"error\",\n errorCode: envelope.error.code,\n });\n return makeErrorResult(envelope);\n }\n },\n );\n}\n\nexport function registerMemoryTools(server: McpServer, context: ServerContext): void {\n registerTool(server, context, {\n name: \"remix_collab_memory_summary\",\n description:\n \"First read for a bound app's current collaboration state, recent reasoning context, and merge or reconcile history before deeper inspection or any raw git history lookup.\",\n access: \"read\",\n inputSchema: memorySummaryInputSchema,\n outputSchema: memorySummarySuccessSchema,\n run: async (args) => {\n const input = z.object(memorySummaryInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return getMemorySummary({\n cwd,\n appId: input.appId,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_memory_search\",\n description:\n \"Default tool for why/history/failed-attempt/user-intent questions. Search prompts, diffs, merge activity, reconciles, and other historical context before using raw git for exact repository facts.\",\n access: \"read\",\n inputSchema: memorySearchInputSchema,\n outputSchema: memorySearchSuccessSchema,\n run: async (args) => {\n const input = z.object(memorySearchInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return searchMemory({\n cwd,\n appId: input.appId,\n query: input.query,\n kinds: input.kinds,\n limit: input.limit,\n offset: input.offset,\n createdAfter: input.createdAfter,\n createdBefore: input.createdBefore,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_memory_timeline\",\n description:\n \"Chronological view of collaboration memory for understanding what happened and in what order, with optional filters for bounded historical inspection before any exact-facts raw git follow-up.\",\n access: \"read\",\n inputSchema: memoryTimelineInputSchema,\n outputSchema: memoryTimelineSuccessSchema,\n run: async (args) => {\n const input = z.object(memoryTimelineInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return getMemoryTimeline({\n cwd,\n appId: input.appId,\n kinds: input.kinds,\n limit: input.limit,\n offset: input.offset,\n createdAfter: input.createdAfter,\n createdBefore: input.createdBefore,\n });\n },\n });\n\n registerTool(server, context, {\n name: \"remix_collab_memory_change_step_diff\",\n description:\n \"Second-hop expansion tool that fetches the full stored diff for a specific change step after memory search, timeline, or review work has identified the relevant `changeStepId`, keeping historical inspection inside Remix before raw git fallback.\",\n access: \"read\",\n inputSchema: changeStepDiffInputSchema,\n outputSchema: changeStepDiffSuccessSchema,\n run: async (args) => {\n const input = z.object(changeStepDiffInputSchema).parse(args);\n const cwd = resolvePolicyCwd(context.policy, input.cwd);\n return getChangeStepDiff({\n cwd,\n appId: input.appId,\n changeStepId: input.changeStepId,\n });\n },\n });\n}\n","import { z } from \"zod\";\n\nimport { commonRequestFieldsSchema, makeSuccessSchema } from \"./common.js\";\n\nconst genericRecordSchema = z.record(z.string(), z.unknown());\nconst genericArraySchema = z.array(genericRecordSchema);\nconst memoryKindSchema = z.enum([\"collab_turn\", \"change_step\", \"merge_request\", \"reconcile\"]);\nconst paginationSchema = z.object({\n limit: z.number().int().nonnegative(),\n offset: z.number().int().nonnegative(),\n hasMore: z.boolean(),\n});\n\nexport const memorySummaryInputSchema = {\n ...commonRequestFieldsSchema,\n appId: z.string().trim().min(1).optional(),\n};\n\nexport const memorySearchInputSchema = {\n ...commonRequestFieldsSchema,\n appId: z.string().trim().min(1).optional(),\n query: z.string().trim().min(1),\n kinds: z.array(memoryKindSchema).max(4).optional(),\n limit: z.number().int().positive().max(50).optional(),\n offset: z.number().int().nonnegative().optional(),\n createdAfter: z.string().trim().min(1).optional(),\n createdBefore: z.string().trim().min(1).optional(),\n};\n\nexport const memoryTimelineInputSchema = {\n ...commonRequestFieldsSchema,\n appId: z.string().trim().min(1).optional(),\n kinds: z.array(memoryKindSchema).max(4).optional(),\n limit: z.number().int().positive().max(50).optional(),\n offset: z.number().int().nonnegative().optional(),\n createdAfter: z.string().trim().min(1).optional(),\n createdBefore: z.string().trim().min(1).optional(),\n};\n\nexport const changeStepDiffInputSchema = {\n ...commonRequestFieldsSchema,\n appId: z.string().trim().min(1).optional(),\n changeStepId: z.string().trim().min(1),\n};\n\nexport const memorySummaryDataSchema = genericRecordSchema;\nexport const memorySearchDataSchema = z.object({\n items: genericArraySchema,\n pagination: paginationSchema,\n});\nexport const memoryTimelineDataSchema = z.object({\n items: genericArraySchema,\n pagination: paginationSchema,\n});\nexport const changeStepDiffDataSchema = z.object({\n changeStepId: z.string(),\n appId: z.string(),\n diff: z.string(),\n diffSha256: z.string(),\n contentType: z.string(),\n encoding: z.string(),\n expiresIn: z.number().int().positive(),\n});\n\nexport const memorySummarySuccessSchema = makeSuccessSchema(memorySummaryDataSchema);\nexport const memorySearchSuccessSchema = makeSuccessSchema(memorySearchDataSchema);\nexport const memoryTimelineSuccessSchema = makeSuccessSchema(memoryTimelineDataSchema);\nexport const changeStepDiffSuccessSchema = makeSuccessSchema(changeStepDiffDataSchema);\n","import type {\n AgentMemoryKind,\n AgentMemorySearchResponse,\n AgentMemorySummary,\n AgentMemoryTimelineResponse,\n ChangeStepDiffResponse,\n} from \"@remixhq/core\";\nimport { readCollabBinding } from \"@remixhq/core/binding\";\nimport { findGitRoot } from \"@remixhq/core/repo\";\n\nimport { createApiClient } from \"./apiClient.js\";\n\ntype ToolResult<T> = {\n data: T;\n warnings?: string[];\n recommendedNextActions?: string[];\n logContext?: {\n repoRoot?: string | null;\n appId?: string | null;\n };\n};\n\ntype MemoryTarget = {\n appId: string;\n repoRoot: string | null;\n};\n\nfunction buildSummaryNextActions(summary: AgentMemorySummary): string[] {\n const actions: string[] = [];\n\n actions.push(\n \"Use `remix_collab_memory_search` next for focused why/history/failed-attempt questions about this app.\",\n );\n\n const recentItemCount =\n summary.recent.collabTurns.length +\n summary.recent.changeSteps.length +\n summary.recent.mergeRequests.length +\n summary.recent.reconciles.length;\n if (recentItemCount > 0) {\n actions.push(\"Use `remix_collab_memory_timeline` next if you need the chronological sequence of recent activity.\");\n }\n\n if (summary.counts.failedChangeStepCount > 0 || summary.counts.reconcileCount > 0) {\n actions.push(\n \"For prior failures or recovery history, run `remix_collab_memory_search` with a focused query and `kinds` narrowed to `change_step` and `reconcile` when appropriate.\",\n );\n }\n\n return actions;\n}\n\nfunction getFirstChangeStepId(items: Array<{ id: string; kind: AgentMemoryKind }>): string | null {\n const changeStep = items.find((item) => item.kind === \"change_step\");\n return changeStep?.id ?? null;\n}\n\nfunction buildSearchNextActions(result: AgentMemorySearchResponse): string[] {\n if (result.items.length === 0) {\n return [\n \"Try a broader `remix_collab_memory_search` query or fewer `kinds` filters if this topic likely uses different wording.\",\n \"Use `remix_collab_memory_timeline` if you need a bounded chronological scan instead of relevance-ranked search.\",\n ];\n }\n\n const actions: string[] = [\n \"Review the top matched memory items before reaching for raw git so the relevant Remix reasoning context stays in view.\",\n ];\n const changeStepId = getFirstChangeStepId(result.items);\n if (changeStepId) {\n actions.push(\n `Use \\`remix_collab_memory_change_step_diff\\` with \\`changeStepId=${changeStepId}\\` if you need the full stored diff for the most relevant change step.`,\n );\n }\n\n if (result.pagination.hasMore) {\n actions.push(\"Narrow the search with `kinds`, `createdAfter`, or `createdBefore` if you need a tighter historical slice.\");\n }\n\n return actions;\n}\n\nfunction buildTimelineNextActions(result: AgentMemoryTimelineResponse): string[] {\n if (result.items.length === 0) {\n return [\n \"Use `remix_collab_memory_summary` for current state, then retry `remix_collab_memory_timeline` with broader filters if needed.\",\n ];\n }\n\n const actions: string[] = [\n \"Use `remix_collab_memory_search` if you need relevance-ranked results for a specific feature, bug, or design decision.\",\n ];\n const changeStepId = getFirstChangeStepId(result.items);\n if (changeStepId) {\n actions.push(\n `Use \\`remix_collab_memory_change_step_diff\\` with \\`changeStepId=${changeStepId}\\` after the timeline identifies the change step you need to inspect.`,\n );\n }\n\n if (result.pagination.hasMore) {\n actions.push(\"Apply `kinds`, `createdAfter`, or `createdBefore` filters to focus the timeline on a smaller historical window.\");\n }\n\n return actions;\n}\n\nfunction buildChangeStepDiffNextActions(changeStepId: string): string[] {\n return [\n `Inspect the stored diff for \\`changeStepId=${changeStepId}\\`, then use raw git only if you still need exact repository-level commit, blame, ancestry, or raw patch details.`,\n ];\n}\n\nfunction unwrapResponseObject<T>(resp: any, label: string): T {\n const obj = resp?.responseObject;\n if (obj === undefined || obj === null) {\n throw new Error(typeof resp?.message === \"string\" && resp.message.trim() ? resp.message : `Missing ${label} response`);\n }\n return obj as T;\n}\n\nfunction makeNotBoundError(): Error & { hint?: string } {\n const error = new Error(\"Repository is not bound to Remix.\") as Error & { hint?: string };\n error.hint = \"Run `remix_collab_init` in this repository, or pass `appId` explicitly for a direct memory read.\";\n return error;\n}\n\nasync function maybeFindGitRoot(cwd: string): Promise<string | null> {\n try {\n return await findGitRoot(cwd);\n } catch {\n return null;\n }\n}\n\nasync function resolveMemoryTarget(params: { cwd: string; appId?: string }): Promise<MemoryTarget> {\n const explicitAppId = params.appId?.trim();\n if (explicitAppId) {\n return {\n appId: explicitAppId,\n repoRoot: await maybeFindGitRoot(params.cwd),\n };\n }\n\n const repoRoot = await findGitRoot(params.cwd);\n const binding = await readCollabBinding(repoRoot);\n if (!binding) {\n throw makeNotBoundError();\n }\n\n return {\n appId: binding.currentAppId,\n repoRoot,\n };\n}\n\nexport async function getMemorySummary(params: { cwd: string; appId?: string }): Promise<ToolResult<AgentMemorySummary>> {\n const target = await resolveMemoryTarget(params);\n const api = await createApiClient();\n const resp = await api.getAgentMemorySummary(target.appId);\n const data = unwrapResponseObject<AgentMemorySummary>(resp, \"agent memory summary\");\n\n return {\n data,\n warnings: [],\n recommendedNextActions: buildSummaryNextActions(data),\n logContext: target,\n };\n}\n\nexport async function searchMemory(params: {\n cwd: string;\n appId?: string;\n query: string;\n kinds?: AgentMemoryKind[];\n limit?: number;\n offset?: number;\n createdAfter?: string;\n createdBefore?: string;\n}): Promise<ToolResult<AgentMemorySearchResponse>> {\n const target = await resolveMemoryTarget(params);\n const api = await createApiClient();\n const resp = await api.searchAgentMemory(target.appId, {\n q: params.query,\n kinds: params.kinds,\n limit: params.limit,\n offset: params.offset,\n createdAfter: params.createdAfter,\n createdBefore: params.createdBefore,\n });\n const data = unwrapResponseObject<AgentMemorySearchResponse>(resp, \"agent memory search\");\n\n return {\n data,\n warnings: [],\n recommendedNextActions: buildSearchNextActions(data),\n logContext: target,\n };\n}\n\nexport async function getMemoryTimeline(params: {\n cwd: string;\n appId?: string;\n kinds?: AgentMemoryKind[];\n limit?: number;\n offset?: number;\n createdAfter?: string;\n createdBefore?: string;\n}): Promise<ToolResult<AgentMemoryTimelineResponse>> {\n const target = await resolveMemoryTarget(params);\n const api = await createApiClient();\n const resp = await api.listAgentMemoryTimeline(target.appId, {\n kinds: params.kinds,\n limit: params.limit,\n offset: params.offset,\n createdAfter: params.createdAfter,\n createdBefore: params.createdBefore,\n });\n const data = unwrapResponseObject<AgentMemoryTimelineResponse>(resp, \"agent memory timeline\");\n\n return {\n data,\n warnings: [],\n recommendedNextActions: buildTimelineNextActions(data),\n logContext: target,\n };\n}\n\nexport async function getChangeStepDiff(params: {\n cwd: string;\n appId?: string;\n changeStepId: string;\n}): Promise<ToolResult<ChangeStepDiffResponse>> {\n const target = await resolveMemoryTarget(params);\n const api = await createApiClient();\n const resp = await api.getChangeStepDiff(target.appId, params.changeStepId);\n const data = unwrapResponseObject<ChangeStepDiffResponse>(resp, \"change step diff\");\n\n return {\n data,\n warnings: [],\n recommendedNextActions: buildChangeStepDiffNextActions(data.changeStepId),\n logContext: target,\n };\n}\n","import { z } from \"zod\";\nimport type { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport type { ToolAnnotations } from \"@modelcontextprotocol/sdk/types.js\";\n\nimport type { ServerContext } from \"../../bootstrap/context.js\";\nimport {\n\tagentRunEventsInputSchema,\n\tagentRunEventsSuccessSchema,\n\tagentRunInputSchema,\n\tagentRunsInputSchema,\n\tagentRunsSuccessSchema,\n\tagentRunSuccessSchema,\n\tappJobQueueInputSchema,\n\tappJobQueueSuccessSchema,\n\tappOverviewSuccessSchema,\n\tappScopedInputSchema,\n\tbundleInputSchema,\n\tbundleSuccessSchema,\n\teditQueueInputSchema,\n\teditQueueSuccessSchema,\n\tsandboxStatusSuccessSchema,\n\ttimelineInputSchema,\n\ttimelineSuccessSchema,\n} from \"../../contracts/ops.js\";\nimport {\n\tmakeErrorResult,\n\tmakeErrorSchema,\n\tmakeSuccessResult,\n\ttype ErrorEnvelope,\n\ttype SuccessEnvelope,\n\tSCHEMA_VERSION,\n} from \"../../contracts/common.js\";\nimport type { NormalizedToolError } from \"../../errors/errorCodes.js\";\nimport { normalizeToolError } from \"../../errors/normalizeError.js\";\nimport {\n\tgetAgentRun,\n\tlistAppJobQueue,\n\tgetAppOverview,\n\tgetBundle,\n\tgetEditQueue,\n\tgetSandboxStatus,\n\tlistAgentRuns,\n\tlistAgentRunEvents,\n\tlistTimeline,\n} from \"../../domain/opsAdapter.js\";\nimport { assertToolAccess, resolvePolicyCwd, type ToolAccess } from \"../../policy/policy.js\";\n\ntype ToolExecutionResult<T> = {\n\tdata: T;\n\twarnings?: string[];\n\trisks?: string[];\n\trecommendedNextActions?: string[];\n\tlogContext?: {\n\t\trepoRoot?: string | null;\n\t\tappId?: string | null;\n\t\tmrId?: string | null;\n\t};\n};\n\nfunction getAnnotations(access: ToolAccess): ToolAnnotations {\n\treturn {\n\t\treadOnlyHint: access === \"read\",\n\t\tdestructiveHint: false,\n\t\tidempotentHint: true,\n\t\topenWorldHint: false,\n\t};\n}\n\nfunction buildSuccessEnvelope<T>(tool: string, requestId: string | undefined, result: ToolExecutionResult<T>): SuccessEnvelope<T> {\n\treturn {\n\t\tschemaVersion: SCHEMA_VERSION,\n\t\tok: true,\n\t\ttool,\n\t\trequestId: requestId ?? null,\n\t\tdata: result.data,\n\t\twarnings: result.warnings ?? [],\n\t\trisks: result.risks ?? [],\n\t\trecommendedNextActions: result.recommendedNextActions ?? [],\n\t};\n}\n\nfunction deriveErrorRisks(normalized: NormalizedToolError): string[] {\n\tif (normalized.code === \"DESTRUCTIVE_OPERATION_BLOCKED\") {\n\t\treturn [\"A policy guard blocked a disallowed operation.\"];\n\t}\n\treturn [];\n}\n\nfunction buildErrorEnvelope(tool: string, requestId: string | undefined, error: unknown): ErrorEnvelope {\n\tconst normalized = normalizeToolError(error);\n\treturn {\n\t\tschemaVersion: SCHEMA_VERSION,\n\t\tok: false,\n\t\ttool,\n\t\trequestId: requestId ?? null,\n\t\terror: normalized,\n\t\twarnings: [],\n\t\trisks: deriveErrorRisks(normalized),\n\t\trecommendedNextActions: normalized.code === \"AUTH_REQUIRED\" ? [\"Run `remix login` or set COMERGE_ACCESS_TOKEN, then retry.\"] : [],\n\t};\n}\n\nfunction registerTool<T>(\n\tserver: McpServer,\n\tcontext: ServerContext,\n\tparams: {\n\t\tname: string;\n\t\tdescription: string;\n\t\taccess: ToolAccess;\n\t\tinputSchema: Record<string, z.ZodTypeAny>;\n\t\toutputSchema: z.ZodTypeAny;\n\t\trun: (args: Record<string, unknown>) => Promise<ToolExecutionResult<T>>;\n\t},\n) {\n\tconst errorSchema = makeErrorSchema();\n\tserver.registerTool(\n\t\tparams.name,\n\t\t{\n\t\t\ttitle: params.name,\n\t\t\tdescription: params.description,\n\t\t\tinputSchema: params.inputSchema,\n\t\t\toutputSchema: params.outputSchema,\n\t\t\tannotations: getAnnotations(params.access),\n\t\t},\n\t\tasync (rawArgs: Record<string, unknown>) => {\n\t\t\tconst requestId = typeof rawArgs.requestId === \"string\" ? rawArgs.requestId : undefined;\n\t\t\tconst startedAt = Date.now();\n\t\t\ttry {\n\t\t\t\tassertToolAccess(context.policy, params.access);\n\t\t\t\tconst result = await params.run(rawArgs);\n\t\t\t\tconst envelope = buildSuccessEnvelope(params.name, requestId, result);\n\t\t\t\tparams.outputSchema.parse(envelope);\n\t\t\t\tcontext.logger.log({\n\t\t\t\t\tlevel: \"info\",\n\t\t\t\t\tmessage: \"tool_completed\",\n\t\t\t\t\ttool: params.name,\n\t\t\t\t\trequestId: envelope.requestId,\n\t\t\t\t\tdurationMs: Date.now() - startedAt,\n\t\t\t\t\tresult: \"success\",\n\t\t\t\t\trepoRoot: result.logContext?.repoRoot ?? null,\n\t\t\t\t\tappId: result.logContext?.appId ?? null,\n\t\t\t\t\tmrId: result.logContext?.mrId ?? null,\n\t\t\t\t});\n\t\t\t\treturn makeSuccessResult(envelope);\n\t\t\t} catch (error) {\n\t\t\t\tconst envelope = buildErrorEnvelope(params.name, requestId, error);\n\t\t\t\terrorSchema.parse(envelope);\n\t\t\t\tcontext.logger.log({\n\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\tmessage: \"tool_failed\",\n\t\t\t\t\ttool: params.name,\n\t\t\t\t\trequestId: envelope.requestId,\n\t\t\t\t\tdurationMs: Date.now() - startedAt,\n\t\t\t\t\tresult: \"error\",\n\t\t\t\t\terrorCode: envelope.error.code,\n\t\t\t\t});\n\t\t\t\treturn makeErrorResult(envelope);\n\t\t\t}\n\t\t},\n\t);\n}\n\nexport function registerOpsTools(server: McpServer, context: ServerContext): void {\n\tregisterTool(server, context, {\n\t\tname: \"remix_context_get_app_overview\",\n\t\tdescription: \"Read the current app's overview, capabilities, and workflow readiness without mutating state.\",\n\t\taccess: \"read\",\n\t\tinputSchema: appScopedInputSchema,\n\t\toutputSchema: appOverviewSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(appScopedInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn getAppOverview({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_ops_get_edit_queue\",\n\t\tdescription: \"Inspect the pending edit queue for one app with bounded pagination.\",\n\t\taccess: \"read\",\n\t\tinputSchema: editQueueInputSchema,\n\t\toutputSchema: editQueueSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(editQueueInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn getEditQueue({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t\tlimit: input.limit,\n\t\t\t\toffset: input.offset,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_ops_list_app_job_queue\",\n\t\tdescription: \"Inspect bounded app-scoped workflow queue jobs for one app, including active backend work such as merge, replay, reconcile, revert, bundle, or import processing.\",\n\t\taccess: \"read\",\n\t\tinputSchema: appJobQueueInputSchema,\n\t\toutputSchema: appJobQueueSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(appJobQueueInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn listAppJobQueue({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t\tlimit: input.limit,\n\t\t\t\toffset: input.offset,\n\t\t\t\tkind: input.kind,\n\t\t\t\tstatus: input.status,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_ops_get_bundle\",\n\t\tdescription: \"Inspect one app bundle by id without downloading the artifact payload.\",\n\t\taccess: \"read\",\n\t\tinputSchema: bundleInputSchema,\n\t\toutputSchema: bundleSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(bundleInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn getBundle({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t\tbundleId: input.bundleId,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_ops_list_timeline\",\n\t\tdescription: \"List bounded timeline events for one app using the backend cursor pagination model.\",\n\t\taccess: \"read\",\n\t\tinputSchema: timelineInputSchema,\n\t\toutputSchema: timelineSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(timelineInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn listTimeline({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t\tlimit: input.limit,\n\t\t\t\tcursor: input.cursor,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_ops_get_agent_run\",\n\t\tdescription: \"Fetch one stored agent run for an app, including status, phase, and summary metadata.\",\n\t\taccess: \"read\",\n\t\tinputSchema: agentRunInputSchema,\n\t\toutputSchema: agentRunSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(agentRunInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn getAgentRun({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t\trunId: input.runId,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_ops_list_agent_runs\",\n\t\tdescription: \"List paginated agent runs for one app so run ids can be discovered before deeper inspection.\",\n\t\taccess: \"read\",\n\t\tinputSchema: agentRunsInputSchema,\n\t\toutputSchema: agentRunsSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(agentRunsInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn listAgentRuns({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t\tlimit: input.limit,\n\t\t\t\toffset: input.offset,\n\t\t\t\tstatus: input.status,\n\t\t\t\tcurrentPhase: input.currentPhase,\n\t\t\t\tcreatedAfter: input.createdAfter,\n\t\t\t\tcreatedBefore: input.createdBefore,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_ops_list_agent_run_events\",\n\t\tdescription: \"List paginated agent-run events for one stored run, with optional time bounds.\",\n\t\taccess: \"read\",\n\t\tinputSchema: agentRunEventsInputSchema,\n\t\toutputSchema: agentRunEventsSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(agentRunEventsInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn listAgentRunEvents({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t\trunId: input.runId,\n\t\t\t\tlimit: input.limit,\n\t\t\t\toffset: input.offset,\n\t\t\t\tcreatedAfter: input.createdAfter,\n\t\t\t\tcreatedBefore: input.createdBefore,\n\t\t\t});\n\t\t},\n\t});\n\n\tregisterTool(server, context, {\n\t\tname: \"remix_ops_get_sandbox_status\",\n\t\tdescription: \"Read safe sandbox metadata and the latest migration status for one app without exposing execution handles or secrets.\",\n\t\taccess: \"read\",\n\t\tinputSchema: appScopedInputSchema,\n\t\toutputSchema: sandboxStatusSuccessSchema,\n\t\trun: async (args) => {\n\t\t\tconst input = z.object(appScopedInputSchema).parse(args);\n\t\t\tconst cwd = input.cwd ? resolvePolicyCwd(context.policy, input.cwd) : undefined;\n\t\t\treturn getSandboxStatus({\n\t\t\t\tappId: input.appId,\n\t\t\t\tcwd,\n\t\t\t});\n\t\t},\n\t});\n}\n","import { z } from \"zod\";\n\nimport { commonRequestFieldsSchema, makeSuccessSchema } from \"./common.js\";\n\nconst genericRecordSchema = z.record(z.string(), z.unknown());\nconst appJobKindSchema = z.enum([\n\t\"fork\",\n\t\"edit\",\n\t\"bundle\",\n\t\"import_github\",\n\t\"import_upload\",\n\t\"merge\",\n\t\"revert\",\n\t\"change_step\",\n\t\"reconcile\",\n\t\"change_step_replay\",\n]);\nconst appJobStatusSchema = z.enum([\"pending\", \"enqueued\", \"processing\", \"succeeded\", \"failed\", \"cancelled\"]);\n\nexport const appScopedInputSchema = {\n\t...commonRequestFieldsSchema,\n\tappId: z.string().trim().min(1).optional(),\n};\n\nexport const editQueueInputSchema = {\n\t...appScopedInputSchema,\n\tlimit: z.number().int().positive().max(100).optional(),\n\toffset: z.number().int().nonnegative().optional(),\n};\n\nexport const appJobQueueInputSchema = {\n\t...appScopedInputSchema,\n\tlimit: z.number().int().positive().max(100).optional(),\n\toffset: z.number().int().nonnegative().optional(),\n\tkind: z.array(appJobKindSchema).min(1).optional(),\n\tstatus: z.array(appJobStatusSchema).min(1).optional(),\n};\n\nexport const bundleInputSchema = {\n\t...appScopedInputSchema,\n\tbundleId: z.string().trim().min(1),\n};\n\nexport const timelineInputSchema = {\n\t...appScopedInputSchema,\n\tlimit: z.number().int().positive().max(100).optional(),\n\tcursor: z.string().trim().min(1).optional(),\n};\n\nexport const agentRunsInputSchema = {\n\t...appScopedInputSchema,\n\tlimit: z.number().int().positive().max(100).optional(),\n\toffset: z.number().int().nonnegative().optional(),\n\tstatus: z.string().trim().min(1).optional(),\n\tcurrentPhase: z.string().trim().min(1).optional(),\n\tcreatedAfter: z.string().datetime().optional(),\n\tcreatedBefore: z.string().datetime().optional(),\n};\n\nexport const agentRunInputSchema = {\n\t...appScopedInputSchema,\n\trunId: z.string().trim().min(1),\n};\n\nexport const agentRunEventsInputSchema = {\n\t...appScopedInputSchema,\n\trunId: z.string().trim().min(1),\n\tlimit: z.number().int().positive().max(100).optional(),\n\toffset: z.number().int().nonnegative().optional(),\n\tcreatedAfter: z.string().datetime().optional(),\n\tcreatedBefore: z.string().datetime().optional(),\n};\n\nexport const appOverviewSuccessSchema = makeSuccessSchema(genericRecordSchema);\nexport const editQueueSuccessSchema = makeSuccessSchema(genericRecordSchema);\nexport const appJobQueueSuccessSchema = makeSuccessSchema(genericRecordSchema);\nexport const bundleSuccessSchema = makeSuccessSchema(genericRecordSchema);\nexport const timelineSuccessSchema = makeSuccessSchema(genericRecordSchema);\nexport const agentRunsSuccessSchema = makeSuccessSchema(genericRecordSchema);\nexport const agentRunSuccessSchema = makeSuccessSchema(genericRecordSchema);\nexport const agentRunEventsSuccessSchema = makeSuccessSchema(genericRecordSchema);\nexport const sandboxStatusSuccessSchema = makeSuccessSchema(genericRecordSchema);\n","import type { ApiClient } from \"@remixhq/core\";\n\nimport { createApiClient } from \"./apiClient.js\";\nimport { loadBindingContext, makeNotBoundError, type ToolResult, unwrapResponseObject } from \"./shared.js\";\n\ntype JsonRecord = Record<string, any>;\n\nasync function resolveAppTarget(\n\t_api: ApiClient,\n\tparams: { appId?: string; cwd?: string },\n): Promise<{ appId: string; repoRoot: string | null }> {\n\tconst explicitAppId = params.appId?.trim();\n\tconst bindingContext = await loadBindingContext(params.cwd);\n\tif (explicitAppId) {\n\t\treturn {\n\t\t\tappId: explicitAppId,\n\t\t\trepoRoot: bindingContext.repoRoot,\n\t\t};\n\t}\n\tif (!bindingContext.binding) {\n\t\tthrow makeNotBoundError(\"App id was not provided and the current repository is not bound to Remix.\");\n\t}\n\treturn {\n\t\tappId: bindingContext.binding.currentAppId,\n\t\trepoRoot: bindingContext.repoRoot,\n\t};\n}\n\nexport async function getAppOverview(params: { appId?: string; cwd?: string }): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(await api.getAppOverview(target.appId), \"app overview\");\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions: [\n\t\t\t\"Use `remix_ops_list_timeline`, `remix_ops_list_agent_runs`, `remix_ops_get_edit_queue`, `remix_ops_list_app_job_queue`, or `remix_ops_get_sandbox_status` for the next operational drill-down on this app.\",\n\t\t],\n\t\tlogContext: target,\n\t};\n}\n\nexport async function getEditQueue(params: {\n\tappId?: string;\n\tcwd?: string;\n\tlimit?: number;\n\toffset?: number;\n}): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(\n\t\tawait api.listAppEditQueue(target.appId, {\n\t\t\tlimit: params.limit,\n\t\t\toffset: params.offset,\n\t\t}),\n\t\t\"edit queue\",\n\t);\n\tconst pageInfo = typeof data.pageInfo === \"object\" && data.pageInfo ? (data.pageInfo as JsonRecord) : null;\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions:\n\t\t\tpageInfo?.hasMore === true && typeof pageInfo.limit === \"number\" && typeof pageInfo.offset === \"number\"\n\t\t\t\t? [`Pass offset=${pageInfo.offset + pageInfo.limit} to load the next edit queue page.`]\n\t\t\t\t: [],\n\t\tlogContext: target,\n\t};\n}\n\nexport async function listAppJobQueue(params: {\n\tappId?: string;\n\tcwd?: string;\n\tlimit?: number;\n\toffset?: number;\n\tkind?: string[];\n\tstatus?: string[];\n}): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(\n\t\tawait api.listAppJobQueue(target.appId, {\n\t\t\tlimit: params.limit,\n\t\t\toffset: params.offset,\n\t\t\tkind: params.kind,\n\t\t\tstatus: params.status,\n\t\t}),\n\t\t\"app job queue\",\n\t);\n\tconst pageInfo = typeof data.pageInfo === \"object\" && data.pageInfo ? (data.pageInfo as JsonRecord) : null;\n\tconst items = Array.isArray(data.items) ? data.items : [];\n\tconst activeBlockingKinds = new Set([\"merge\", \"change_step\", \"change_step_replay\", \"reconcile\", \"revert\"]);\n\tconst hasBlockingJobs = items.some((item) => {\n\t\tif (!item || typeof item !== \"object\") return false;\n\t\tconst record = item as JsonRecord;\n\t\treturn (\n\t\t\ttypeof record.kind === \"string\" &&\n\t\t\tactiveBlockingKinds.has(record.kind) &&\n\t\t\t(typeof record.status !== \"string\" || [\"pending\", \"enqueued\", \"processing\"].includes(record.status))\n\t\t);\n\t});\n\tconst recommendedNextActions: string[] = [];\n\tif (hasBlockingJobs) {\n\t\trecommendedNextActions.push(\n\t\t\t\"Inspect the returned active workflow jobs before concluding that merge, replay, reconcile, or revert work is stuck. This surface reflects backend app-scoped queue state, not local finalize state.\",\n\t\t);\n\t}\n\tif (pageInfo?.hasMore === true && typeof pageInfo.limit === \"number\" && typeof pageInfo.offset === \"number\") {\n\t\trecommendedNextActions.push(`Pass offset=${pageInfo.offset + pageInfo.limit} to load the next app job queue page.`);\n\t}\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions,\n\t\tlogContext: target,\n\t};\n}\n\nexport async function getBundle(params: {\n\tappId?: string;\n\tcwd?: string;\n\tbundleId: string;\n}): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(await api.getBundle(target.appId, params.bundleId), \"bundle\");\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions: [\"Use the bundle download-url client methods only when you need the actual artifact, not just metadata inspection.\"],\n\t\tlogContext: target,\n\t};\n}\n\nexport async function listTimeline(params: {\n\tappId?: string;\n\tcwd?: string;\n\tlimit?: number;\n\tcursor?: string;\n}): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(\n\t\tawait api.listAppTimeline(target.appId, {\n\t\t\tlimit: params.limit,\n\t\t\tcursor: params.cursor,\n\t\t}),\n\t\t\"app timeline\",\n\t);\n\tconst pageInfo = typeof data.pageInfo === \"object\" && data.pageInfo ? (data.pageInfo as JsonRecord) : null;\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions:\n\t\t\tpageInfo?.hasMore === true && typeof pageInfo.nextCursor === \"string\"\n\t\t\t\t? [`Pass cursor=${pageInfo.nextCursor} to load the next timeline page.`]\n\t\t\t\t: [],\n\t\tlogContext: target,\n\t};\n}\n\nexport async function listAgentRuns(params: {\n\tappId?: string;\n\tcwd?: string;\n\tlimit?: number;\n\toffset?: number;\n\tstatus?: string;\n\tcurrentPhase?: string;\n\tcreatedAfter?: string;\n\tcreatedBefore?: string;\n}): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(\n\t\tawait api.listAgentRuns(target.appId, {\n\t\t\tlimit: params.limit,\n\t\t\toffset: params.offset,\n\t\t\tstatus: params.status,\n\t\t\tcurrentPhase: params.currentPhase,\n\t\t\tcreatedAfter: params.createdAfter,\n\t\t\tcreatedBefore: params.createdBefore,\n\t\t}),\n\t\t\"agent runs\",\n\t);\n\tconst pageInfo = typeof data.pageInfo === \"object\" && data.pageInfo ? (data.pageInfo as JsonRecord) : null;\n\tconst items = Array.isArray(data.items) ? data.items : [];\n\tconst firstRunId =\n\t\titems.length > 0 && items[0] && typeof items[0] === \"object\" && typeof (items[0] as JsonRecord).id === \"string\"\n\t\t\t? ((items[0] as JsonRecord).id as string)\n\t\t\t: null;\n\tconst recommendedNextActions: string[] = [];\n\tif (firstRunId) {\n\t\trecommendedNextActions.push(\n\t\t\t`Use \\`remix_ops_get_agent_run\\` with \\`runId=${firstRunId}\\` for the top listed run, then \\`remix_ops_list_agent_run_events\\` if you need its event stream.`,\n\t\t);\n\t}\n\tif (pageInfo?.hasMore === true && typeof pageInfo.limit === \"number\" && typeof pageInfo.offset === \"number\") {\n\t\trecommendedNextActions.push(`Pass offset=${pageInfo.offset + pageInfo.limit} to load the next agent-runs page.`);\n\t}\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions,\n\t\tlogContext: target,\n\t};\n}\n\nexport async function getAgentRun(params: {\n\tappId?: string;\n\tcwd?: string;\n\trunId: string;\n}): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(await api.getAgentRun(target.appId, params.runId), \"agent run\");\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions: [`Use \\`remix_ops_list_agent_run_events\\` with \\`runId=${params.runId}\\` for the event stream behind this run.`],\n\t\tlogContext: target,\n\t};\n}\n\nexport async function listAgentRunEvents(params: {\n\tappId?: string;\n\tcwd?: string;\n\trunId: string;\n\tlimit?: number;\n\toffset?: number;\n\tcreatedAfter?: string;\n\tcreatedBefore?: string;\n}): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(\n\t\tawait api.listAgentRunEvents(target.appId, params.runId, {\n\t\t\tlimit: params.limit,\n\t\t\toffset: params.offset,\n\t\t\tcreatedAfter: params.createdAfter,\n\t\t\tcreatedBefore: params.createdBefore,\n\t\t}),\n\t\t\"agent run events\",\n\t);\n\tconst pageInfo = typeof data.pageInfo === \"object\" && data.pageInfo ? (data.pageInfo as JsonRecord) : null;\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions:\n\t\t\tpageInfo?.hasMore === true && typeof pageInfo.limit === \"number\" && typeof pageInfo.offset === \"number\"\n\t\t\t\t? [`Pass offset=${pageInfo.offset + pageInfo.limit} to load the next event page.`]\n\t\t\t\t: [],\n\t\tlogContext: target,\n\t};\n}\n\nexport async function getSandboxStatus(params: { appId?: string; cwd?: string }): Promise<ToolResult<JsonRecord>> {\n\tconst api = await createApiClient();\n\tconst target = await resolveAppTarget(api, params);\n\tconst data = unwrapResponseObject<JsonRecord>(await api.getSandboxStatus(target.appId), \"sandbox status\");\n\treturn {\n\t\tdata,\n\t\twarnings: [],\n\t\trecommendedNextActions: [\"Use the sandbox metadata here to decide whether a resume is plausible before attempting any write-side sandbox action.\"],\n\t\tlogContext: target,\n\t};\n}\n"],"mappings":";;;AAAA,SAAS,qBAAqB;AAE9B,SAAS,gBAAgB,iCAAiC;;;ACF1D,SAAS,mBAAmB,qBAAqB,iBAAAA,sBAAqC;;;ACAtF,SAAS,yBAAyB,kCAAkC,2BAA2B,qBAAsC;AAGrI,eAAsB,yBAAyB,QAA6C;AAC1F,QAAM,iBAAiB,UAAW,MAAM,cAAc;AACtD,QAAM,eAAe,wBAAwB;AAC7C,SAAO,iCAAiC;AAAA,IACtC,QAAQ;AAAA,IACR;AAAA,IACA,sBAAsB,OAAO,EAAE,QAAQ,eAAe,QAAQ,MAAM;AAClE,YAAM,WAAW,0BAA0B,aAAa;AACxD,aAAO,SAAS,yBAAyB,EAAE,QAAQ,CAAC;AAAA,IACtD;AAAA,EACF,CAAC;AACH;;;ADTA,eAAsB,wBAAkD;AACtE,QAAM,SAAS,MAAMC,eAAc;AACnC,QAAM,gBAAgB,MAAM,yBAAyB,MAAM;AAC3D,QAAM,MAAM,oBAAoB,QAAQ;AAAA,IACtC;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAEA,eAAsB,kBAAsC;AAC1D,QAAM,SAAS,MAAMA,eAAc;AACnC,QAAM,gBAAgB,MAAM,yBAAyB,MAAM;AAC3D,SAAO,oBAAoB,QAAQ;AAAA,IACjC;AAAA,EACF,CAAC;AACH;;;AEpBA,SAAS,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EAAE,QAAQ,CAAC;AACpC;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,QAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AACrE,UAAQ,OAAO,MAAM,GAAG,OAAO;AAAA,CAAI;AACnC,UAAQ,WAAW;AACrB,CAAC;","names":["resolveConfig","resolveConfig","z","z","z","findGitRoot","findGitRoot","parseJsonObject","project","organizationId","spawn","path","z","z","z","genericRecordSchema","z","genericArraySchema","paginationSchema","normalizePagination","bindingContext","resolveAppAccessSource","listApps","getAnnotations","buildSuccessEnvelope","deriveErrorRisks","buildErrorEnvelope","registerTool","z","listApps","z","z","genericRecordSchema","z","genericArraySchema","paginationSchema","readCollabBinding","findGitRoot","unwrapResponseObject","makeNotBoundError","maybeFindGitRoot","findGitRoot","readCollabBinding","getAnnotations","buildSuccessEnvelope","buildErrorEnvelope","deriveErrorRisks","registerTool","z","z","z","genericRecordSchema","z","getAnnotations","buildSuccessEnvelope","deriveErrorRisks","buildErrorEnvelope","registerTool","z","require"]}
|